Debian 7 how are IPv6 link local addresses set?

19,040

Solution 1

Link local addresses are derived from the MAC address of the device. They are auto-generated as a part of bringing the interface up. Auto-configuration includes a discovery process to ensure that the address is unique on the network.

A similar process is used to auto-configure routable addresses when a router advertisement is available. These addresses may be regenerated periodically to provide privacy.

RFC 4862 specifies the processes to be followed.

Solution 2

Found it! This command is not enough:

ifconfig eth0 up

Instead I must do:

ifconfig eth0 up
sysctl -w net.ipv6.conf.eth0.disable_ipv6=0

Only the latter does restore the IPv6 link local address on eth0.

In other words, my distro seems to have some code hidden somewhere which dynamically changes net.ipv6.conf.eth0.disable_ipv6 every time it is asked to bring the network brought up or down. Your mileage may vary.

I got to the bottom of this thanks to a mere:

sysctl -a | grep ipv6
Share:
19,040

Related videos on Youtube

Aaron
Author by

Aaron

Linux software engineer

Updated on September 18, 2022

Comments

  • Aaron
    Aaron almost 2 years

    It seems like when dhclient runs on eth0 I get an IPv4 address from the DHCP server and a Scope:Link IPv6 address attached to eth0:

    inet6 addr: fe80::a00:27ff:fed0:4d41/64 Scope:Link
    

    But I can't see from dhclient-script how that address is being added. On another interface with a static IP address, I'd like to add a link local IPv6 address, and I was wondering if there was a generic command to do that without knowing the mac.

    Edit:
    It looks like the kernel assigns the link local address when you do "ip link set dev ethX up" or "ifconfig ethX up". However, in my case I had a cable plugged in to the interface that was DHCP'ing and no cable plugged into the interface I was setting up statically. Can't verify until Monday but I'm guessing the kernel does not assign link local addresses to the interface if there's no link.

    • Admin
      Admin almost 11 years
      Neither has anything to do with the other.
    • Admin
      Admin almost 11 years
      No, you do not get an IPv6 link-local address from running dhclient.
  • Aaron
    Aaron almost 11 years
    "They are auto-generated as part of bringing the interface up". Right, this is what I'm looking for, who is autogenerating it? It's not auto-generated when you assign a static IPv4 address, but it is when dhclient runs. So is dhclient implementing RFC 4862, or is it a side effect of some command in the dhclient-script? How do I replicate it on a static interface without writing my own implementation of RFC 4862?
  • Aaron
    Aaron almost 11 years
    auto-generated by the kernel, it seems, see edit above.
  • Cbhihe
    Cbhihe almost 7 years
    This applies perfectly to Ubuntu 16.04. Thanks.