DHCP服務器和DHCP中繼的配置
全局的DHCP
SW1
[Huawei]port-group group-member Ethernet 0/0/1 e0/0/2 e0/0/3 //把e0/0/1 e0/0/2 e0/0/3 加入組
[Huawei-port-group]port link-type access //把這個組加入access
[Huawei-port-group]port default vlan 10 //把這個組加入VLAN 10
AR1
[AR1]dhcp enable //全局開啟DHCP服務
[AR1]ip pool p1 //創建地址池並命名
[AR1-ip-pool-p1]network 192.168.1.0 mask 255.255.255.0 //分配終端要獲取的網段信息
[AR1-ip-pool-p1]dns-list 8.8.8.8 //配置下發的DNS地址
[AR1-ip-pool-p1]lease day 3 //配置分配的租期時間
[AR1]interface GigabitEthernet0/0/0 //進入g0/0/0接口
[AR1-GigabitEthernet0/0/0]ip address 192.168.1.254 24 //接口的地址就是網關地址
[AR1-GigabitEthernet0/0/0]dhcp select global //在接口開啟DHCP功能
基於接口的DHCP
AR1
[Huawei]dhcp enable //全局開啟DHCP服務
[AR1]interface GigabitEthernet0/0/0 //進入g0/0/0接口
[Huawei-GigabitEthernet0/0/0]ip address 192.168.2.254 24 //配置網關地址(相當於非配了網段)
[Huawei-GigabitEthernet0/0/0]dhcp select interface //接口下開啟DHCP功能
[Huawei-GigabitEthernet0/0/0]dhcp server dns-list 4.4.4.4 //配置DNS地址
[Huawei-GigabitEthernet0/0/0]dhcp server lease day 6 //配置租期時間
中繼配置
SW1
[SW1]vlan 10 //創建vlan 10
[Huawei]port-group group-member Ethernet 0/0/1 e0/0/2 //把e0/0/1 e0/0/2 加入組
[Huawei-port-group]port link-type access //把這個組加入access
[Huawei-port-group]port default vlan 10 //把這個組加入VLAN 10
AR1 DHCP服務器
[Huawei]dhcp enable //全局開啟DHCP服務
[AR1]ip pool 1314 //創建地址池
[AR1-ip-pool-1314]network 192.168.10.0 mask 255.255.255.0 //分配終端要獲取的網段信息
[AR1-ip-pool-1314]gateway-list 192.168.10.254 //配置下發的網關地址
[AR1-ip-pool-1314]dns-list 1.3.1.4 //配置下發的DNS地址
[AR1-ip-pool-1314]excluded-ip-address 192.168.10.100 192.168.10.100 設置保留地址
[AR1-ip-pool-1314]lease day 3 //配置分配的租期時間
[AR1]interface GigabitEthernet 0/0/0 //進入g0/0/0接口
[AR1]ip address 192.168.20.1 255.255.255.0 //配置IP地址
[AR1] dhcp select global //在接口開啟DHCP功能
[AR1]ip route-static 192.168.10.0 24 192.168.20.2 嚇一跳
AR2 DHCP中繼
[AR2]dhcp enable //全局開啟DHCP服務
[AR2]interface GigabitEthernet 0/0/1 //進入接口g0/0/1
[AR2-GigabitEthernet0/0/1]ip address 192.168.20.2 24 配置IP地址
[AR2]interface GigabitEthernet0/0/0 //進入接口g0/0/0
[AR2-GigabitEthernet0/0/0]ip address 192.168.10.254 24 //配置IP地址的網關
[AR2-GigabitEthernet0/0/0]dhcp select relay //進入接口上應用DHCP中繼功能
[AR2-GigabitEthernet0/0/0]dhcp relay server-ip 192.168.20.1 //指向DHCP服務器的IP地址
DHCP服務器和DHCP中繼的配置