需求
禁用dhcp ip。
原理机制
系统启动时,通过/etc/rc.local文件 设置了静态ip地址,并开启了udhcp服务。

/etc/rc.local出厂内容:
root@E2000-debian:~# cat /etc/rc.local
#!/bin/sh
ifconfig eth1 up
dhclient eth1 &
/usr/share/vt/ip_addr_manage 3 eth1 &
ifconfig eth0 192.168.10.1 up
ifconfig eth2 192.168.20.1 up
ifconfig eth3 192.168.30.1 up
sleep 1
udhcpd -fS /usr/share/vt/dhcp_eth0.conf &
udhcpd -fS /usr/share/vt/dhcp_eth2.conf &
udhcpd -fS /usr/share/vt/dhcp_eth3.conf &
sleep 1
ln -sf /sys/bus/i2c/devices/i2c-0/0-0050/eeprom /dev/eeprom
静态IP实现方案
- 注释rc.local 中的udhcpd命令;
- 修改ifconfig eth0命令,改成如下:
ifconfig eth0 192.168.10.1 netmask 255.255.255.0 up
修改之后的/etc/rc.local文件:
root@E2000-debian:~# cat /etc/rc.local
#!/bin/sh
ifconfig eth1 up
dhclient eth1 &
/usr/share/vt/ip_addr_manage 3 eth1 &
ifconfig eth0 172.28.251.230 netmask 255.255.255.0 up
ifconfig eth2 192.168.20.1 up
ifconfig eth3 192.168.251.230 netmask 255.255.255.0 up
sleep 1
#udhcpd -fS /usr/share/vt/dhcp_eth0.conf &
udhcpd -fS /usr/share/vt/dhcp_eth2.conf &
#udhcpd -fS /usr/share/vt/dhcp_eth3.conf &
sleep 1
ln -sf /sys/bus/i2c/devices/i2c-0/0-0050/eeprom /dev/eeprom