1,配置静态ip

nano /etc/network/interfaces  默认内容不要动,加入:
iface lo inet loopback

#auto eth0
#iface eth0 inet dhcp
auto eth0
iface eth0 inet static
address 192.168.8.123
netmask 255.255.255.0
gateway 192.168.8.1

如果ip配置失败用/etc/init.d/network restart检查一下报错信息

2,配置dhcp服务器

ubuntu下:
sudo apt-get install isc-dhcp-serve

buildroot下menuconfig打开dhcp-serve这个选项
vi /etc/dhcp/dhcpd.conf
subnet 192.168.18.0 netmask 255.255.255.0 {
range 192.168.18.120 192.168.18.128;
option routers 192.168.18.2;
option subnet-mask 255.255.255.0;
option broadcast-address 192.168.18.255;
option domain-name-servers 192.168.18.1, 192.168.18.2;
}

IP地址范围为:192.168.18.120-192.168.18.128
默认网关:192.168.18.1
子网掩码:255.255.255.0
dns:192.168.18.1, 192.168.18.2
可根据需要修改上述配置文件,完成后重启服务 sudo service isc-dhcp-server restart。

 

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐