环境说明:
DHCP服务器系统:CentOS 5.5
网卡接口:eth0
IP地址:192.168.21.136
网关:192.168.21.2
子网掩码:255.255.255.0
DNS:8.8.8.8&">nbsp; 8.8.4.4
一、安装
检查DHCP服务是否安装
rpm -q dhcp
package dhcp is not installed
yum -y install dhcp
二、配置
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf #复制配置文件模板
vi /etc/dhcpd.conf #编辑配置文件
ddns-update-style interim; #设置DHCP服务器模式
ignore client-updates; #禁止客户端更新
subnet 192.168.21.0 netmask 255.255.255.0 {
option routers 192.168.21.2; #设置网关
option subnet-mask 255.255.255.0; #设置子网掩码
option domain-name-servers 8.8.8.8,8.8.4.4; #设置dns服务器地址
range dynamic-bootp 192.168.21.200 192.168.21.210; #设置dhcp服务器IP地址租用的范围
default-lease-time 21600; #默认租约时间
max-lease-time 43200; #最大租约时间
hardware ethernet 00:0C:29:E2:82:5C; #保留主机的MAC地址
fixed-address 192.168.21.201; #保留主机的IP,即绑定IP地址到主机
vi /etc/sysconfig/dhcpd #指定DHCP服务的网络接口
# Command line options here
DHCPDARGS=eth0
三、启动
service dhcpd start #启动dhcp服务
service dhcpd restart #重启dhcp服务
chkconfig dhcpd on #设置开机启动
四、测试
在客户机上设置IP地址为自动获得,重启客户机,查看IP地址为192.168.21.200到192.168.21.210其中的一个,即为成功!
附件:本教程中的dhcpd.conf配置文件
ddns-update-style interim;ignore client-updates;subnet 192.168.21.0 netmask 255.255.255.0 {# --- default gateway option routers 192.168.21.2; option subnet-mask 255.255.255.0;# option nis-domain "domain.org";# option domain-name "domain.org"; option domain-name-servers 8.8.8.8,8.8.4.4; option time-offset -18000; # Eastern Standard Time# option ntp-servers
192.168.1.1;# option netbios-name-servers 192.168.1.1;# --- Selects point-to-point node (default is hybrid). Don't change this unless# -- you understand Netbios very well# option netbios-node-type 2; range dynamic-bootp 192.168.21.200 192.168.21.210; default-lease-time 21600; max-lease-time 43200; # we want the nameserver to appear at a fixed address host ns { next-server marvin.
redhat.com; hardware ethernet 00:0C:29:E2:82:5C; fixed-address 192.168.21.201; }}