redhat7.3-dhcp和dhcp中继服务器配置

1.设置host、firewald、selinux 

hostnamectl set-hostname fengxiaoli41.com

systemctl stop firewalld.service

systemctl disable firewalld.service 

setenforce 0

2.配置基本dhcp服务

yum install -y dhcp

vim /etc/dhcp/dhcpd.conf

#全局参数

option domain-name "fengxiaoli41.com";

option domain-name-servers dns.fengxiaoli41.com;

default-lease-time 600;

max-lease-time 7200;

authoritative;

log-facility local7;

#配置192.168.1.0网段动态获取

subnet 192.168.1.0 netmask 255.255.255.0 {

range dynamic-bootp 192.168.1.20 192.168.1.254;

option broadcast-address 192.168.1.255;

option routers 192.168.1.1;

}

#配置192.168.1.0网络给该mac分配固定ip

host feng {

#hardware ethernet MAC

fixed-address 192.168.1.5;

}

systemctl restart dhcpd

systemctl status dhcpd

-------------至此客户端可以获取动态和固定ip

3.中继服务器

vim /etc/dhcp/dhcpd.conf

#配置192.168.2.0dhcp中继网段(若没有中)

subnet 192.168.2.0 netmask 255.255.255.0 {

range dynamic-bootp 192.168.2.20 192.168.2.254;

option broadcast-address 192.168.2.255;

option routers 192.168.2.254;

}

cp /lib/systemd/system/dhcrelay.service /etc/systemd/system/

cd /etc/systemd/system/

vim dhcrelay.service

[Service]

ExecStart=/usr/sbin/dhcrelay -d --no-pid 192.168.1.10

4.重启服务

systemctl --system daemon-reload

systemctl restart dhcrelay.service

 注:配置之前先要保证dhcp服务器和中继服务器网络互通,dhcp服务器为192.168.1.0网段,中继服务器192.168.2.0网段。另外也可在dhcp服务器上添加两块网卡,将中继服务器与dhcp服务器配置在同一服务器上。