3

I'm working on an embedded-x86 Linux device that runs Debian (Linux 3.8.13). This device has two Ethernet ports, eth0 and eth1.

If I boot up this device with only eth0 connected to a switch, and ssh in to it and do an 'ifconfig', I get this:

root@msli-DCP-11234772:~# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:1c:ab:00:0a:60
          inet6 addr: fe80::21c:abff:fe00:a60/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:5659 errors:0 dropped:4102 overruns:0 frame:0
          TX packets:1071 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:1313254 (1.2 MiB)  TX bytes:224889 (219.6 KiB)
          Interrupt:16 Memory:fc500000-fc520000

eth1      Link encap:Ethernet  HWaddr 00:1c:ab:00:0a:61
          UP BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:17 Memory:fc520000-fc540000

Note that eth0 has an "inet6 addr" assigned to it, while eth1 does not.

If/when I plug eth1 into a network switch, an "inet6 addr" line will appear in ifconfig's output at that time (and it will stay present even if I unplug the Ethernet cable from eth1 again).

So it seems that Linux doesn't bother associating an Ethernet device with its IPv6 address until the first time that Ethernet device is actually connected to something.

That sort-of-works, but I have some programs that are supposed to send IPv6 multicast packets out of both ports at all times, and they can't do that on a port that doesn't have an IPv6 address assigned to it.

So what I'd like to do is find a way to force Linux to associate the device's self-assigned IPv6 address (i.e. fe80::blah, where blah is derived from the MAC address on the Ethernet chip) during startup, rather than waiting until the Ethernet port is actually connected. Is there a way to do that?

(The advantage would be that my programs could just scan the list of network devices during launch and use them -- currently they have to set up an AF_NETLINK socket to be notified of network-config changes, which sort-of works but is more complicated than I'd like, and also a bit slow to react)

2

ifconfig doesn't show you enough information here. The general key is if the link is up. iproute2's ip addr will show the lower-level status as well as the lifetime of addresses as applicable.

Link-local addresses are only supposed to be present if the link itself is up. No link, no address. There are also a bunch of other cases where it won't appear, like sub-interfaces in bonded set (group/team/master etc, depending on what choice of words you want to use)

The behavior you observed of a link-local address not being removed after a cable was removed I think is in error, it should have been removed when nothing else was using it and the lifetime counter expires, and I suspect it's been fixed in newer kernels (I'm not in a position to test right now).

Beyond that, do you care if it's the kernel or userspace that creates the fe80:: address? If it doesn't matter, you can create it from userspace, and the kernel won't remove it.

0

How are the interfaces configured in /etc/network/interfaces? I assume they are set to allow-hotplug which enables the interface when a link is detected. Try changing it to auto so your config looks like:

auto eth0
iface eth0 ....
    ....

auto eth1
iface eth1 ....
    ....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.