12

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.

Aaron
  • 223
  • 1
  • 2
  • 6

2 Answers2

7

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.

BillThor
  • 27,354
  • 3
  • 35
  • 69
  • 1
    "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 Jul 20 '13 at 16:01
  • auto-generated by the kernel, it seems, see edit above. – Aaron Jul 20 '13 at 22:45
6

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
MarcH
  • 171
  • 1
  • 7