实验环境:一台RHEL一台xp,在RHEL上搭建DHCP,是xp能通过DHCP自动获得IP
首先在RHEL上配置自己的IP,vi /etc/sysconfig/network-scripts/ifcfg-eth0
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/MYQZI$4TL[LN9AQ$LVE6QG1.jpg)
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/U~D8Y7%7BB~(U)MTER%7BH6E3]V.jpg)
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/8KHRAP0NJ$MZOFB6PB[8F%25S.jpg)
安装完成后,可以通过命令rpm -ql dhcp找到dhcp配置文件dhcpd.conf的样例,
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/4%7DVVYGXD2MDVTVQSGUVG~0C.jpg)
将该文件改名为dhcpd.conf并复制到/etc/dhcp/
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/CJIN6NAN3I2MQXSI%60Q0L9@J.jpg)
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/__AK5]6WKSW69FKHZ(W$%25WF.jpg)
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/FKO68V6]BQCQ$09H0J8WVPP.jpg)
ddns-update-style interim; #定义所支持的DNS动态更新类型(必选)
ignore client-updates; #忽略客户机更新DNS记录
allow bootp;
subnet 192.168.0.0 netmask 255.255.255.0{ #定义作用域(IP子网)
range 192.168.0.11 192.168.0.200; #定义作用域(IP子网)范围
option routers 192.168.0.1; #为客户端指定网关
option subnet-mask 255.255.255.0; #为客户端指定子网掩码
option domain-name “dpgroup.net”; #为客户端指定DNS域名
option domain-name-servers 166.111.8.28,202.106.196.115; #为客户端指定DNS服务器的IP地址
option broadcast-address 192.168.0.255; #为客户端指定广播地址
default-lease-time 86400; #指定默认的租约期限
max-lease-time 172800; #指定最大租约期限
host node4{ #为某台客户机定义保留地址
hardware Ethernet 00:03:FF:25:5d:a3; #客户机的网卡物理地址
fixed-address 192.168.0.27; #分配给客户机的一个固定IP地址
filename "vmlinux";
option root-path "/usr/src/toshiba/target";
}
}
完成配置,重启服务
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/_~9%7B29SRB_1UBBO$203@%7DTD.jpg)
这样,dhcp服务器算是OK了,下面客户端
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/UR86_@Y_%7DYKZ9N%7B[JZ@%25J8S.jpg)
![](file:///C:/Documents%20and%20Settings/Administrator/Application%20Data/Tencent/Users/857468538/QQ/WinTemp/RichOle/YEM9%7D)FFCM8%25R8RO6X%7D%7DPIH.jpg)
完成!!!
在配置DHCP的过程中,DHCP服务有时候老是启动失败,总结为以下原因:
1.本机的IP与声明的子网不在同一网段(保证至少有一个子网与本机IP在同一网段);
2.配置文件出错,如少符号等:
3.配置文件路径出问题,比如在RHEL6以下的版本中,配置文件保存在了/etc/dhcpd.conf,但是在rhel6及以上版本中,却保存在了/etc/dhcp/dhcpd.conf。