作者:cyrich
rpm包在第4张光盘dhcp-3.0.3-26.i386.rpm
编译安装方法
#tar zxvf dhcp-latest.tar.gz
#cd dhcp-3.0.3
#./configure
#make
#make install
#vi /etc/dhcpd.conf
#touch /var/state/dhcp/dhcpd.leases rpm安装不用touch,文件默认安装在/var/lib/dhcpd/dhcpd.leases
#dhcpd
主要配置选项
1.默认网关
2.IP地址
3.子网掩码
4.DNS服务器地址
5.租用时间
/etc/dhcpd.conf:
ddns-update-style none; 必须有的一句
subnet 192,168.0.0 netmask 255.255.255.0 { 指定服务范围
option routers 192.168.0.22
option subnet-mask 255.255.255.0
option domain-name “chinaitlab.com”;
option domain-name-servers 192.168.0.22;
range 192.168.0.128 192.168.0.254;
default-lease-time 21600; 6小时
max-lease-time 43200; 12小时
host mail { 根据网卡地址分配一个固定的IP
hardware Ethernet 12:34:56:78:ab:cd;
fixed-address 192.168.0.5;
}
}
服务器默认UDP67端口。
Linux客户机的配置
修改/etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
或使用netconfig配置动态地址,然后运行#service network restart
设定1分钟后执行指定操作:
#at now+1minutes
at> service network restart
ctrl+D结束
调试服务器:
#tail /var/log/messages 查看日志信息
#more /var/lib/dhcpd/dhcpd.leases 查看IP分配情况
调试客户机:
Under unix:
#dhclient eth0 DHCP客户端工具,刷新网卡eh0,发送一个广播,重新请求一个IP
Under windows:
C:\>ipconfig /renew
应用案例
要求:
配置一台DHCP服务器,为100台主机分配地址,使用192.168.0.0/24网段,静态主机地址如下:
默认网关:192.168.0.254
DNS服务器:192.168.0.1
邮件服务器:192.168.0.2
DHCP服务器:192.168.0.254
解决方法:
option routers 192.168.0.254;
option domain-name-server 192.168.0.1;
range 192.168.0.3 192.168.0.102;
host ns {
hardware Ethernet 12:24:34:34:as:de;
fixed-address 192.168.0.1;
}
host mail {
hardware Ethernet 12:34:56:78:ab:cd;
fixed-address 192.168.0.2;
}
阅读(1738) | 评论(0) | 转发(0) |