8

There's a difference in behavior between IPv4 and IPv6 addresses assigned to a network interface: when the link is dropped, as with "ip link set down dev eth0", IPv4 addresses are retained, but IPv6 addresses are flushed. If the link is brought up again, IPv4 addresses can immediately be used to pass traffic, but IPv6 addresses must be assigned.

Is this a bug, or by design? If by design, where can I find this explicitly documented?

One co-worker has argued that it's a bug, to be fixed in an upcoming kernel; another has argued that it is by design, as IPv6 assumes dynamic addressing. I've found identical behavior in several different Linux distributions and different kernel versions, so I'm nearly certain that this is by design, but I want to find documentation, as in a citation from an RFC, to settle the matter.

If there's a workaround that forces the retention of manually-assigned IPv6 addresses, that'd be useful to know as well.

7
  • 1
    After the link cycle, are you saying that you need to manually run a config command to reinstate the v6 address? Or rather that the interface just comes up with no IP, and then the system assigns the address several seconds later? While I don't have a well defined answer, IPv6 relies VERY heavily on neighbor discovery via ICMPv6 packets. That ties right in with Router Advertisements, and then with address assignment. Apr 4, 2017 at 17:13
  • The former. This is in an environment without an IPv6 router and without DHCP, in which we use shell scripts to manually configure IPv4 and IPv6 addresses for local networking. The interface comes up with a link-local IPv6 address, but no other IPv6 address until I assign it one. Or run radvd on that subnet.
    – bgvaughan
    Apr 4, 2017 at 17:20
  • 1
    OK, what I was mentioning about ND and RA packets still applies. Almost any, if not all, IPv6 compliant routes support RA messages, which are what Stateless Auto-configuration (SLAAC) uses to assign addresses via the router's advertised subnet and a randomly generated segment. SLAAC is a core IPv6 feature, but I have never seen anything in all of the documentation that I have looked through about persistent static IPs not being allowed. Apr 4, 2017 at 18:32
  • What Linux version? Some versions of Ubuntu have a bug that causes similar issues, according to the Amazon AWS documentation on ipv6.
    – Moshe Katz
    Apr 6, 2017 at 17:48
  • I've seen identical behavior in Red Hat 6.9, Red Hat 7.3, Fedora 25, Debian Sid, and Arch Linux, and across kernels in the 2.6, 3.0, 4.9, and 4.10 series.
    – bgvaughan
    Apr 6, 2017 at 17:57

1 Answer 1

7
+50

It sounds like the setting you are looking for is keep_addr_on_down which was introduced in Linux 4.6. Quoting Documentation/networking/ip-sysctl.txt:

keep_addr_on_down - INTEGER
    Keep all IPv6 addresses on an interface down event. If set static
    global addresses with no expiration time are not flushed.
      >0 : enabled
       0 : system default
      <0 : disabled

    Default: 0 (addresses are removed)

If you are using an older Linux version than 4.6 the best workaround I can suggest is to assign the address to a dummy interface which you keep up even if the physical interface is brought down:

modprobe dummy
ip -6 addr add dev dummy0 2001:db8::42/128
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .