Dhcp的安装配置及高级应用
① 安装dhcp
DHCP服务器软件 dhcp-3.0.5-3.el5.i386.rpm
cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
② 修改主配置文件
/etc/dhcpd.conf
subnet 申明所分配的ip网络范围
range 地址池
host 绑定主机
default-lease-time (默认租约期)
max-lease-time (最大租约期)
fixed-address (为主机分配固定IP,只能用在host声明)
hardware ethernet (指定主机物理地址,只能用在host声明)
option routers (指定网关地址)
option domain-name-servers (指定DNS服务器地址)
③启动
#service dhcpd configtest 测试dhcp服务器
#/etc/init.d/dhcpd start/stop/restart/status/reload
#service dhcpd start/stop/restart/status/reload
#chkconfig --level 35 dhcpd on
#ntsysv --level 35
下面通过一个实例来操作一下
完成上图的客户端能自动非配到ip
(1)、在dhcp中继代理,dhcp服务器上安装dhcp服务
(2)、在中继代理,服务器上开启路由转发
Echo “1” > /proc/sys/net/ipv4/ip_froward
(3)、在dhcp服务器上修改/etc/sysconfig/dhcrelay
DHCPDARGS=eth0
(4)、dhcp服务器上修改配置文件
ddns-update-style interim;
ignore client-updates;
option domain-name-server 202.106.0.20;
option time-offset -18000;
default-lease-time 21600;
max-lease-time 43200;
subnet 192.168.0.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.0.10 192.168.0.200;
option routers 192.168.0.1;
option subnet-mask 255.255.255.0;
host prtsvr {
hardware ethernet 00:c0:c3:22:46:81;
fixed-address 192.168.0.11;
}
}
subnet 192.168.1.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.1.10 192.168.1.200;
option routers 192.168.1.1;
option subnet-mask 255.255.255.0;
host prtsvr {
hardware ethernet 00:c0:c3:22:46:81;
fixed-address 192.168.1.11;
}
}
(5)、开启dhcp服务,并下次自动加载
(6)、在中继服务器上设置允许dhcp中继数据的接口及dhcp服务器的ip地址
INTERFACES="eth0 eth1" #指定接收dhcp客户端dhcpdiscover包得网络接口
DHCPSERVERS="192.168.1.2" #dhcp服务器的ip
(7)、在中继服务器上开启dhcp中继代理,并设置下次启动自动加载
Service dhcrelay restart
Chkconfig dhcrelay on
(8)、配置结束