1.1系统起来后如果udev有脚本关联网络,则会启动网络(etc/udev/rules.d/autonet.rules)
# Handle network interface setup
SUBSYSTEM=="net", ACTION=="add" RUN+="/etc/udev/scripts/network.sh"
SUBSYSTEM=="net", ACTION=="remove" RUN+="/etc/udev/scripts/network.sh"
1.2 运行network.sh命令则会运行ifup命令(etc/udev/scripts/network.sh)
if grep -q "iface \+$INTERFACE" /etc/network/interfaces; then
case $ACTION in
add)
ifconfig | grep -q "^$INTERFACE" || ifup $INTERFACE
;;
remove)
ifdown $INTERFACE
;;
esac
exit 0
fi
1.3.操作ifup时会检测/etc/network/interface,里面定义的字段有dhcp则会自动调用udhcpc命令来获取ip
root@zedboardPrj:/etc# udhcpc
udhcpc (v1.24.1) started
Sending discover...
Sending discover...
macb e000b000.ethernet eth0: link