配置DHCP服务器

一、安装DHCP软件包
rpm -ivh /misc/cd/Server/dhcp-3.0.5-23.e15.i386.rpm

二、建立主配置文件dhcp.conf
[root@localhost~]# cp /usr/share/doc/dhcpd-3.0.5/dhcpd.conf.samole /etc/dhcpd.conf
[root@localhost ~]# vim /etc/dhcpd.conf
ddns-update-style none; //禁用DNS动态更新

option domain-name bene.com; //指定默认搜索域

option domain-name-servers 192.168.1.1,202.96.128.68; //DNS地址

default-lease-time 21600; //默认租约6小时

max-lease-time 43200; //最大租约为12小时


subnet 192.168.0.0 netmask 255.255.255.0 {

option routers 192.168.0.1; //指定默认网关

option subnet-mask 255.255.255.0; //子网

range 192.168.0.128192.168.0.254; //地址范围


host ns {

next-server marvin.redhat.com;

hardware ethernet 12:34:56:78:AB:CD; //保留选项,为客户机保留地址

fixed-address 192.168.0.129;

}

三、启动dhcpd服务 ( service dhcpd configtest 可以检查配置脚本)

[root@localhost~]# service dhcpd start
[root@localhost~]# chkconfig dhcpd on //添加运行级别

[root@localhost~]# netstat -naup | grep “:67” //查看dhcpd服务端口


四、配置DHCP客户端

[root@localhost~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0

DEVICE=eth0

ONBOOT=yes //开机自启

BOOTPROTO=dhcp

[root@localhost~]# dhclient -d eth0 //自动获取新的Ip地址

[root@localhost~]# dhclient -r eth0 //释放,重新获取ip地址

[root@localhost~]# less /var/lib/dhcpd/dhcpd.leases //查看已分配的ip地址