DHCP集群搭建工作安排
安裝配置DHCP集群服務器
安裝配置兩臺Linux7.6操作系統做為dhcp集群服務器,已完成
DHCP服務器配置,主DHCP服務器配置 dhcpd.conf
option domain-name "yuchai.com";
option domain-name-servers 172.16.0.101, 172.16.0.110;
option ntp-servers 172.16.0.101;
#default-lease-time 600;
#max-lease-time 7200;
default-lease-time 43200;## 12個小時
max-lease-time 64800;## 18個小時
failover peer "ycfailover" {
primary; # declare this to be the primary server
address 172.16.0.241;
port 647;
peer address 172.16.0.242;
peer port 647;
max-response-delay 30;
max-unacked-updates 10;
load balance max seconds 3;
mclt 1800;
split 3; ### 驗證時,地址池是5個,則取中間數量做分割
}
subnet 172.19.58.0 netmask 255.255.255.0 { ##使用位置: 玉柴大廈7樓,內部使用
option routers 172.19.58.1; #修改網關
pool {
failover peer "ycfailover";
range 172.19.58.20 172.19.58.24; ## 5 IP自動分配
authoritative; #申明權威子網
}
}
新DHCP服務器IP地址,172.16.0.241、172.16.0.242,不影響現有用戶
驗證新DHCP集群環境效果
在玉柴大廈匯聚三層交換機,修改網段172.19.58(內部使用,不影響業務部門使用)的dhcp配置
interface Vlan58
description TO-7F-ITSYS
no shutdown
ip access-group deny_blj in
no ip redirects
ip address 172.19.58.253/24
no ipv6 redirects
ip router ospf 10 area 0.0.0.0
hsrp 58
preempt
priority 10
ip 172.19.58.1
ip dhcp relay address 172.16.0.241
ip dhcp relay address 172.16.0.242
測試驗證 把主節點關機
Jun 27 13:01:36 yc-itbase-dhcp-0-241 dhcpd: DHCPOFFER on 172.19.58.22 to 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:43 yc-itbase-dhcp-0-241 dhcpd: DHCPDISCOVER from 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:43 yc-itbase-dhcp-0-241 dhcpd: DHCPOFFER on 172.19.58.22 to 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:43 yc-itbase-dhcp-0-241 dhcpd: DHCPREQUEST for 172.19.58.22 (172.16.0.241) from 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:43 yc-itbase-dhcp-0-241 dhcpd: DHCPACK on 172.19.58.22 to 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:43 yc-itbase-dhcp-0-241 dhcpd: Unable to add forward map from ycithp1.yuchai.com to 172.19.58.22: not found
Jun 27 13:02:43 yc-itbase-dhcp-0-241 dhcpd: DHCPREQUEST for 172.16.133.14 from 00:50:56:b1:d3:4f (w2016-tst001) via eth0
Jun 27 13:02:43 yc-itbase-dhcp-0-241 dhcpd: DHCPACK on 172.16.133.14 to 00:50:56:b1:d3:4f (w2016-tst001) via eth0
Jun 27 13:02:43 yc-itbase-dhcp-0-241 dhcpd: Unable to add forward map from w2016-tst001.yuchai.com to 172.16.133.14: not found
Jun 27 13:03:30 yc-itbase-dhcp-0-241 dhcpd: DHCPREQUEST for 172.16.133.15 from 00:50:56:b1:60:0d via eth0
Jun 27 13:03:30 yc-itbase-dhcp-0-241 dhcpd: DHCPACK on 172.16.133.15 to 00:50:56:b1:60:0d via eth0
^C
You have new mail in /var/spool/mail/root
[root@yc-itbase-dhcp-0-241 dhcpd-webui]# init 0
Connection closing...Socket close.
客戶端拔插網線,在dhcp節點2上,可以看到成功分配到IP地址
Jun 27 13:00:01 yc-itbase-dhcp-0-242 systemd: Started Session 75 of user root.
Jun 27 13:01:01 yc-itbase-dhcp-0-242 systemd: Started Session 76 of user root.
Jun 27 13:01:01 yc-itbase-dhcp-0-242 systemd: Started Session 77 of user root.
Jun 27 13:01:29 yc-itbase-dhcp-0-242 dhcpd: DHCPINFORM from 172.19.58.12 via 172.19.58.254: not authoritative for subnet 172.19.58.0
Jun 27 13:01:29 yc-itbase-dhcp-0-242 dhcpd: If this DHCP server is authoritative for that subnet,
Jun 27 13:01:29 yc-itbase-dhcp-0-242 dhcpd: please write an `authoritative;' directive either in the
Jun 27 13:01:29 yc-itbase-dhcp-0-242 dhcpd: subnet declaration or in some scope that encloses the
Jun 27 13:01:29 yc-itbase-dhcp-0-242 dhcpd: subnet declaration - for example, write it at the top
Jun 27 13:01:29 yc-itbase-dhcp-0-242 dhcpd: of the dhcpd.conf file.
Jun 27 13:01:31 yc-itbase-dhcp-0-242 dhcpd: DHCPDISCOVER from 00:0e:c6:c1:eb:88 via 172.19.58.254
Jun 27 13:01:32 yc-itbase-dhcp-0-242 dhcpd: DHCPOFFER on 172.19.58.20 to 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:33 yc-itbase-dhcp-0-242 dhcpd: DHCPINFORM from 172.19.58.12 via 172.19.58.254: not authoritative for subnet 172.19.58.0
Jun 27 13:01:35 yc-itbase-dhcp-0-242 dhcpd: DHCPDISCOVER from 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:35 yc-itbase-dhcp-0-242 dhcpd: DHCPOFFER on 172.19.58.20 to 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:43 yc-itbase-dhcp-0-242 dhcpd: DHCPDISCOVER from 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:43 yc-itbase-dhcp-0-242 dhcpd: DHCPOFFER on 172.19.58.20 to 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
Jun 27 13:01:43 yc-itbase-dhcp-0-242 dhcpd: uid lease 172.19.58.20 for client 00:0e:c6:c1:eb:88 is duplicate on 172.19.58.0/24
Jun 27 13:03:51 yc-itbase-dhcp-0-242 dhcpd: peer ycfailover: disconnected
Jun 27 13:03:51 yc-itbase-dhcp-0-242 dhcpd: failover peer ycfailover: I move from normal to communications-interrupted
Jun 27 13:04:59 yc-itbase-dhcp-0-242 dhcpd: DHCPREQUEST for 172.19.58.22 from 00:0e:c6:c1:eb:88 via 172.19.58.254
Jun 27 13:04:59 yc-itbase-dhcp-0-242 dhcpd: DHCPACK on 172.19.58.22 to 00:0e:c6:c1:eb:88 (ycithp1) via 172.19.58.254
后續工作
梳理終端使用的網段DHCP信息
網段DHCP地址池分配原則
- 網段第一個IP地址為VLAN網關,不可分配
- 網段多少有一些需要固定IP的設備,統一為網段最后20個
- 建議用于DHCP自動分配的地址段為 10 - 230
- 租約時間建議
配置格式如下:
### 終端網段1
subnet 172.19.58.0 netmask 255.255.255.0 { ##使用位置: 玉柴大廈7樓,內部使用
option routers 172.19.58.1; #修改網關
pool {
failover peer "ycfailover";
range 172.19.58.20 172.19.58.24; ## 5 IP自動分配
authoritative; #申明權威子網
}
}
### 終端網段2
subnet 172.16.11.0 netmask 255.255.255.0 { ##使用位置: 玉柴大學2樓201、202、203教室
option routers 172.16.11.1; #修改網關
pool {
failover peer "ycfailover";
range 172.16.11.11 172.16.11.200; ##可分配的IP區域 11-200 ,共190可以自動分配
}
}
### 終端網段3
subnet 172.16.13.0 netmask 255.255.255.0 { ##使用位置: 動力大廈12樓、13樓、14樓
option routers 172.16.13.1; #修改網關
pool {
failover peer "ycfailover";
range 172.16.13.11 172.16.13.200; ##可分配的IP區域 11-200 ,共190可以自動分配
}
}
在新DHCP集群服務器上逐個網段配置DHCP
分次在各個三層交換機上配置DHCP relay信息或者ip dhcp helper,驗證各個網段的終端是否正常獲取IP地址
ip dhcp relay address 172.16.0.241
ip dhcp relay address 172.16.0.242