subnet 10.10.10.0 netmask 255.255.255.0 {
range 10.10.10.2 10.10.10.254;
option routers 10.10.10.1;
option broadcast-address 10.10.10.255;
option subnet-mask 255.255.255.0;
option domain-name-servers 114.114.114.14;
default-lease-time 86400;
max-lease-time 172800;
}
subnet 20.20.20.0 netmask 255.255.255.0 {
range 20.20.20.2 20.20.20.254;
option routers 20.20.20.1;
option broadcast-address 20.20.20.255;
option subnet-mask 255.255.255.0;
option domain-name-servers 114.114.114.114;
default-lease-time 86400;
max-lease-time 172800;
#绑定pc2的IP地址
host bindpc2 {
hardware ethernet 00:50:79:66:68:02;
fixed-address 20.20.20.20;
}
}
#下面的配置是服务器接受DHCP请求报文的接口,配置上去就不会报错! Not configured to listen on any interfaces!
subnet 172.16.2.0 netmask 255.255.255.0 {
range 172.16.2.3 172.16.2.254;
option routers 172.16.2.1;
option broadcast-address 172.16.2.255;
option subnet-mask 255.255.255.0;
option domain-name-servers 114.114.114.114;
default-lease-time 86400;
max-lease-time 172800;
}
2.2 配置服务器数据包到 10.10.10.0/24 和 20.20.20.0/24 网段的路由
#route add -net 10.10.10.0 netmask 255.255.255.0 dev ens37
#route add -net 20.20.20.0 netmask 255.255.255.0 dev ens37
三、检查错误
3.1 tail /var/log/messages #查看错误日志信息
3.2 cat /var/lib/dhcpd/dhcpd.leases #查看DHCP服务器地址分配情况
四、实验结果
PC_1获取到的IP地址如下:
PC_2获取的是一个固定的IP地址20.20.20.20/24
实验目的达到了,over~
原文地址:http://blog.51cto.com/jackor/2127992