我正在使用运行Ubuntu 15.04的Wandboard(imx6)设备来实现类似自助服务终端的目的。在网络之间移动(现场无键盘访问)后,我将zeroconf网络用于初始配置。将网络更改为zeroconf设置后,网络接口无法正常工作。这是我的再现步骤(让我知道是否还有其他有用的内容可放入我的diag脚本中):
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
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
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
然后一切都很好。Windows计算机上的Ping立即开始完成。
这在现场给用户带来了困惑,他们最终关闭了设备并重新打开电源,直到设备响应为止。电缆切换事件发生后,如何在Zeroconf模式下按预期方式重新连接网络?
更新:allow-hotplug eth0
似乎没有任何改变。
更新-更新:
遵循maxf的建议,仅在安装ifplugd(并对其进行配置!)之后,我的许多问题就消失了。注意:如果希望它监视接口,则必须在/ etc / default / ifplugd中配置ifplugd。我发现除了一种情况外,我的界面都可以正常联机:
╔═══════════╦═══════════════╦═══════════╦═════════╗
║ Boot with ║ bad link ║ good link ║ no link ║
╠═══════════╬═══════════════╬═══════════╬═════════╣
║ dhcp ║ ok ║ ok ║ ok ║
║ zeroconf ║ needs restart ║ ok ║ ok ║
╚═══════════╩═══════════════╩═══════════╩═════════╝
在此表中,我将引导配置了dhcp / zeroconf-static的设备,并且电缆插入所需的相对网络(坏链路),正确的网络(正常链路)或未连接(无链路)。然后,我将其连接到正确的网络,并查看接口是否正确联机。我发现只有在启动时连接到我的LAN的zeroconf配置无法连接到Zeroconf便携式计算机的临时网络。
这是我在/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
从理论上讲,不必重新启动网络。尝试在“ auto eth0”行之后将“ allow-hotplug eth0”添加到/ etc / network / interfaces中,以查看是否可以解决该问题。
至于您最初的问题:您可以使用ifplugd。Ifplugd基本上是一个小的守护程序,它监视以太网接口的链接状态并在更改时调用用户定义的脚本(默认为/etc/ifplugd/ifplugd.action)。该脚本获取单个参数(“ up”或“ down”),设置后,您可以使用以下参数:
#!/bin/sh
if [ "$1" = "up" ] ; then
service networking restart
fi
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句