IPv6 scope ID vs IPv4
Asked Answered
L

1

7

Recently I was working with the Berkeley socket API for IPv6, and noticed that IPv6 addresses (sockaddr_in6) have a field called sin6_scope_id, which was not part of IPv4 addresses.

After searching around a bit, I’ve learned that scope_id is meant to identify the network interface, because multiple network interfaces can have the same link-local IPv6 address. This made sense, but then what I didn’t understand is how IPv4 handles this issue, if there’s no equivalent of scope ID there?

Is there a mechanism in the kernel that prevents multiple IPv4 interfaces from being assigned the same link-local address?

If that’s the case, then why was it necessary to invent scope ID for IPv6 instead of going with the same solution as IPv4?

Also, is the scope_id only used to distinguish between interfaces with identical link-local addresses, or are there other use cases too?

Lovemaking answered 18/1, 2018 at 19:33 Comment(2)
It's really that multiple interfaces all have the same IPv6 link-local network. The destination address is what determines which interface is used, and if the destination is a link-local address, the host cannot determine which interface to use because they all have the same network. Multiple interfaces with the same network can be a problem for IPv4.Slatternly
While IPv4 has link local addresses, they're rarely used, and their presence usually indicates a serious problem. With IPv6, every interface always has a link local address, and they are often used.Archfiend
S
6

In short, no, there is no well-defined mechanism for handling link-local IPv4 addresses on hosts with multiple interfaces. There is nothing stopping the same link-local address being selected for two different interfaces (however if the two interfaces are on the same network link, then ARP-based conflict detection will cause at least one of them to be reassigned).

RFC 3927 section 3.2 covers the issues of "address ambiguity":

Given that the IP stack must have the outbound interface associated with a packet that needs to be sent to a Link-Local destination address, interface selection must occur. The outbound interface cannot be derived from the packet's header parameters such as source or destination address (e.g., by using the forwarding table lookup). Therefore, outbound interface association must be done explicitly through other means. The specification does not stipulate those means.

And also in section 6.3:

Application software run on a multi-homed host that supports IPv4 Link-Local address configuration on more than one interface may fail.

This is because application software assumes that an IPv4 address is unambiguous, that it can refer to only one host. IPv4 Link-Local addresses are unique only on a single link. A host attached to multiple links can easily encounter a situation where the same address is present on more than one interface, or first on one interface, later on another; in any case associated with more than one host. Most existing software is not prepared for this ambiguity. In the future, application programming interfaces could be developed to prevent this problem.

This problem was solved in IPv6 by the introduction of a scope ID.

At present scope id is only used for link-local addressing.

Sosthenna answered 29/7, 2019 at 16:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.