dhcp动态配置
配置dhcp服务器:(rhel5)
1, 安装dhcp 服务器软件
#rpm –q dhcp 查看dhcp是否存在/
#mount /dev/cdrom /media 挂载rhel5系统光盘
#rpm –vih /media/Server/dhcp-3.0.5-23.el5.i386.rpm
2,建立主配置文件/etc/dhcpd.conf
#cat/etc/dhcpd.conf
注: #see /usr/share/doc/dhcp*/dhcpd.conf.sample#模板文件
#vim/etc/dhcpd.conf
ddns-update-style none; //禁用DNS动态更新
....
subnet 192.168.1.0 netmask 255.255.255.0 { //网段声明
range 192.168.1.20 192.168.1.50 ;
optionsubnet-mask 255.255.255.0;
optionrouters 192.168.1.254;
optiondomain-name “hzq.com”;
optiondomain-name-servers 202.106.0.20, 202.106.148.1;
default-lease-time 21600;
max-lease-time 43200;
}
host pc1 {
hardware Ethernet00:co:c3:22:46:81;
fixed-adderss192.168.1.30;
}
#dhcpd //检查dhcp配置是否的错!
#sevice dhcpd start
#netstat –anpu | grep “:67” //dhcp是udp的67号端口
注:
日志文件:/var/log/message
租约文件:/var/lib/dhcpd/dhcpd.lease
dhcp客户端
#vim/etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=dhcp
#ifdown eth0 ; ifup eth0
注;
Linux客户机可使用dhclient工具测试dhcp服务器;由软件包 dhclient-3.0.5-23.el5.i386.rpm提供;直接执行dhclient命令;
#dhclient –d eth0 //网卡eth0自动获取新的ip地址
#dhclient –r eth0 //释放之前为eth0获取ip租约