实验环境:
系统:RHEL6.4
一.给DHCP服务器配置固定IP
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=.......
TYPE=Ethernet
UUID=......
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=static
IPADDR=192.168.50.253
NETMASK=255.255.255.0
[[email protected] ~]#service network restart
[[email protected] ~]#chkconfig network on
[[email protected] ~]inconfig eth0
二.安装dhcp软件包
[[email protected] ~]rpm -q dhcp
package dhcp is not installed
放入RHEL6.4.iso
[[email protected] ~]cd /misc/cd/Packages/
[[email protected] Packages]ls dhcp*
dhcp-4.1.1-34.P1.el6.x86_64.rpm
dhcp-common-4.1.1-34.P1.el6.x86_64.rpm
[[email protected] Packages]rpm -ivh dhcp-4.1.1-34.P1.el6.x86_64.rpm
warning: dhcp-4.1.1-34.P1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY
Preparing... ########################################### [100%]
1:dhcp ########################################### [100%]
三.配置DHCP服务器
[[email protected] ~]vim /etc/dhcpd/dhcpd.conf
ddns-update-style none; //动态更新类型
subnet 192.168.50.0 netmask 255.255.255.0 { //网段声明
range 192.168.50.10 192.168.50.20; //IP分配范围
range 192.168.50.50 192.168.50.60;
option domain-name-servers 192.168.50.252,114.114.114.114; //DNS服务器地址
option domain-name "tarena.com"; //默认搜索域
option routers 192.168.50.254; //默认网关
default-lease-time 21600; //默认租期
max-lease-time 43200; //最大租期
}
host hostname { //识别名称
hardware ethernet 00:00:00:00:00:00; //客户机MAC地址
fixed-address 192.168.50.33; //分配给改客户机的固定IP
}
四.启动服务
[[email protected] ~]service dhcpd status
dhcpd已停
[[email protected] ~]service dhcpd start
启动dhcpd : [确定]
[[email protected] ~]chkconfig --list dhcpd
dhcpd 0:关闭 1:关闭 2:关闭 3:关闭 4:关闭 5:关闭 6:关闭
[[email protected] ~]chkconfig dhcpd on
五.客户端验证
Windows平台
网络设置选择自动选取,ipconfig /release
ipconfig /renew
Linux 平台
临时
dhclient -d eth0 获取
dhclient -r eth0 释放
永久
[[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
HWADDR=00:00:00:00:00:00
TYPE=Ethernet
ONBOOT=yes
NM_CONTROLLED=yes
BOOTPROTO=dhcp
[[email protected] ~]#service network restart
[[email protected] ~]#ifconfig eth0
错误检查:
service dhcpd configtest //检查dhcpd.conf语法错误
根据提示一步步排错,如果语法OK,服务启动不了,查看本机IP地址.
搭建一个简单的DHCP服务器