天天看點

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.中繼伺服器

#配置192.168.2.0為dhcp中繼網段(若沒有中)

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伺服器配置在同一伺服器上。

本文轉自 fxl風 51CTO部落格,原文連結:http://blog.51cto.com/fengxiaoli/1944864