DHCP(動態主機設置協議,Dynamic Host Configuration Protocol)服務可以爲大量客戶機自動分配地址,提供集中管理,減輕管理和維護成本、提高網絡配置效率,其基於C/S結構模式。
yum 安裝DHCP服務器
yum -y install dhcp
建立配置文件
[root@mail Server]# cp /usr/share/doc/dhcp-3.0.5/dhcpd.conf.sample /etc/dhcpd.conf
[root@mail ~]# vi /etc/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
option domain-name "benet.com";
option domain-name-servers 202.106.0.20;
default-lease-time 21600;
max-lease-time 43200;
subnet 192.168.20.0 netmask 255.255.255.0 {
option routers 192.168.20.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.20.10 192.168.20.100;
}
subnet 192.168.30.0 netmask 255.255.255.0 {
option routers 192.168.30.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.30.10 192.168.30.100;
}
subnet 192.168.40.0 netmask 255.255.255.0 {
option routers 192.168.40.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.40.10 192.168.40.100;
}
2. 配置中繼服務器,安裝dhcp軟件包
[root@mail ~]#vi /etc/sysctl.conf
Net.ipv4.ip_forward = 1
[root@mail ~]#sysctl -p
[root@mail ~]#vi /etc/sysconfig/dhcrelay
INTERFACES = "eth0 eth1 eth2"
DHCPSERVERS = "192.168.20.1"
[root@mail ~]#serviice dhcrelay start
[root@mail ~]#chkconfig --level 35 dhcrelay on
ddns-update-style interim;
ignore client-updates;
option domain-name "benet.com";
option domain-name-servers 202.106.0.20;
default-lease-time 21600;
max-lease-time 43200;
subnet 192.168.20.0 netmask 255.255.255.0 {
option routers 192.168.20.2;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.20.10 192.168.20.100;
}
subnet 192.168.30.0 netmask 255.255.255.0 {
option routers 192.168.30.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.30.10 192.168.30.100;
}
subnet 192.168.40.0 netmask 255.255.255.0 {
option routers 192.168.40.1;
option subnet-mask 255.255.255.0;
range dynamic-bootp 192.168.40.10 192.168.40.100;
}
2. 配置中繼服務器,安裝dhcp軟件包
[root@mail ~]#vi /etc/sysctl.conf
Net.ipv4.ip_forward = 1
[root@mail ~]#sysctl -p
[root@mail ~]#vi /etc/sysconfig/dhcrelay
INTERFACES = "eth0 eth1 eth2"
DHCPSERVERS = "192.168.20.1"
[root@mail ~]#serviice dhcrelay start
[root@mail ~]#chkconfig --level 35 dhcrelay on