I am using a Wandboard (imx6) device running Ubuntu 15.04 for a kiosk-like purpose. I use zeroconf networking for initial configuration and after moving between networks (no keyboard access in the field). I'm having problems with the network interface not working after changing networks to the zeroconf setting. Here are my repro steps (let me know if there are more useful things to drop into my diag script):
- I reset to zeroconf settings and reboot with the device still plugged into lan
wandboard@lnm:~$ ./network-diag.sh
+ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 169.254.254.254
netmask 255.255.0.0
gateway 1.1.1.1
+ ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:1f:7b:b2:14:96 brd ff:ff:ff:ff:ff:ff
inet 169.254.254.254/16 brd 169.254.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::21f:7bff:feb2:1496/64 scope link
valid_lft forever preferred_lft forever
+ ip route
169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.254.254
+ systemctl status sys-subsystem-net-devices-eth0.device
� sys-subsystem-net-devices-eth0.device - /sys/subsystem/net/devices/eth0
Loaded: loaded
Active: active (plugged) since Fri 2016-08-12 18:40:17 UTC; 1min 17s ago
Device: /sys/devices/soc0/soc.1/2100000.aips-bus/2188000.ethernet/net/eth0
- Unplug cable, plug into ad-hoc zeroconf network
wandboard@lnm:~$ ./network-diag.sh
+ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 169.254.254.254
netmask 255.255.0.0
gateway 1.1.1.1
+ ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:1f:7b:b2:14:96 brd ff:ff:ff:ff:ff:ff
inet6 fe80::21f:7bff:feb2:1496/64 scope link
valid_lft forever preferred_lft forever
+ ip route
+ systemctl status sys-subsystem-net-devices-eth0.device
� sys-subsystem-net-devices-eth0.device - /sys/subsystem/net/devices/eth0
Loaded: loaded
Active: active (plugged) since Fri 2016-08-12 18:40:17 UTC; 5min ago
Device: /sys/devices/soc0/soc.1/2100000.aips-bus/2188000.ethernet/net/eth0
- Device is now unreachable from a Windows machine in zeroconf mode. Pings return "destination host unreachable". But with a quick networking restart...
wandboard@lnm:~$ sudo service networking restart
wandboard@lnm:~$ ./network-diag.sh
+ cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
address 169.254.254.254
netmask 255.255.0.0
gateway 1.1.1.1
+ ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:1f:7b:b2:14:96 brd ff:ff:ff:ff:ff:ff
inet 169.254.254.254/16 brd 169.254.255.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::21f:7bff:feb2:1496/64 scope link
valid_lft forever preferred_lft forever
+ ip route
169.254.0.0/16 dev eth0 proto kernel scope link src 169.254.254.254
+ systemctl status sys-subsystem-net-devices-eth0.device
� sys-subsystem-net-devices-eth0.device - /sys/subsystem/net/devices/eth0
Loaded: loaded
Active: active (plugged) since Fri 2016-08-12 18:40:17 UTC; 7min ago
Device: /sys/devices/soc0/soc.1/2100000.aips-bus/2188000.ethernet/net/eth0
Then everything is fine again. Pings from the Windows machine immediately start completing.
This is confusing to the user in the field and they end up power cycling the unit until it responds. How can I make the network reconnect as expected in zeroconf mode after a cable switch event?
Update: allow-hotplug eth0
doesn't seem to change anything.
Update-update:
Following maxf's suggestion, many of my problems went away simply after installing ifplugd (and configuring it!). NB: You must configure ifplugd in /etc/default/ifplugd if you want it to monitor your interface. I found that my interface came online correctly in all but one situation:
╔═══════════╦═══════════════╦═══════════╦═════════╗
║ Boot with ║ bad link ║ good link ║ no link ║
╠═══════════╬═══════════════╬═══════════╬═════════╣
║ dhcp ║ ok ║ ok ║ ok ║
║ zeroconf ║ needs restart ║ ok ║ ok ║
╚═══════════╩═══════════════╩═══════════╩═════════╝
In this table, I would boot the device configured with dhcp/zeroconf-static and with the cable either plugged into the opposite network than it needed (bad link), the proper network (good link) or unconnected (no link). I'd then connect it to the correct network and see if the interface came online correctly. I found that only the zeroconf configuration when booted connected to my LAN failed to connect to the zeroconf laptop ad-hoc network.
Here's my action script in /etc/ifplugd/action.d/
#!/bin/sh
LNM_LOG=/tmp/ifplug.log
ZEROCONF_IP=169.254.254.254
date >> $LNM_LOG
echo $1 $2 >> $LNM_LOG
if [ "$1" = "eth0" -a "$2" = "up" -a $(grep -c $ZEROCONF_IP /etc/network/interfaces) -ne 0 ] ; then
echo "eth0 plugged in for zeroconf, restart networking" >> $LNM_LOG
service networking restart
echo "network restarted" >> $LNM_LOG
fi