dhcp中继的搭建流程
拓扑:
server(/etc/dhcp/dhcpd.conf) dhcp源服务器
trunk(/etc/sysconfig/dhcrelay) dhcp中继服务器
server trunk client
eth0 ———— eth0 eth1 ———— eth0
18.251 18.252 19.1 19.0
vmnet4 vmnet4 vmnet5 vmnet5
配置步骤:
一、server(18)
1)配置网卡(GETEWAY =18.252)
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
IPADDR=192.168.18.251
GATEWAY=192.168.18.252
2)重启网卡
#service network restart
3)安装服务
#yum -y install dhcp
4)复制模板文件
#cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcp/dhcpd.conf
5)编辑配置文件
#vim /etc/dhcp/dhcpd.conf
subnet 192.168.18.0 netmask 255.255.255.0 {}
注意:dhcp服务器配置文件中的subnet至少要有一个跟服务器网卡相同网段的子网,所以此处有一个空白子网。
subnet 192.168.19.0 netmask 255.255.255.0 {
range 192.168.19.2 192.168.19.222;
option domain-name-servers 8.8.8.8;
option routers 192.168.19.1; //注意网关的设置,也可直接在client中设置
default-lease-time 600;
max-lease-time 7200;
}
6)重启服务
#service dhcpd restart
二、trunk(18,19)
1)配置网卡
#vim /etc/sysconfig/network-scripts/ifcfg-eth1
IPADDR=192.168.18.252
#vim /etc/sysconfig/network-scripts/ifcfg-eth2
IPADDR=192.168.19.1
2)重启网卡
#service network restart
3)配置端口转发
#echo 1 > /proc/sys/net/ipv4/ip_forward
4)安装服务
#yum -y install dhcp
5)编辑配置文件
#vim /etc/sysconfig/dhcrelay
INTERFACES="eth0 eth1" (interfaces)
DHCPSERVERS="192.168.18.251" (dhcpservices)
6)重启服务
#service dhcrelay restart
三、client(19)
1)配置网卡
#vim /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=dhcp
2)重启网卡
#service network restart