拓撲圖
要求
- PC1通過DHCP獲取192.168.1.1地址
- PC2和PC3通過DHCP接口地址池方式獲取IP地址
- 配置靜態路由使其ping通
配置
配置主機名及接口IP地址
# AR1
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys AR1
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip add 192.168.1.254 24
May 27 2024 14:32:56-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IPon the interface GigabitEthernet0/0/0 has entered the UP state.
[AR1-GigabitEthernet0/0/0]int g0/0/1
[AR1-GigabitEthernet0/0/1]ip add 10.1.12.1 24
May 27 2024 14:33:06-08:00 AR1 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IPon the interface GigabitEthernet0/0/1 has entered the UP state.
[AR1-GigabitEthernet0/0/1]
# AR2
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys AR2
[AR2]int g0/0/1
[AR2-GigabitEthernet0/0/1]ip add 10.1.12.2 24
May 27 2024 14:33:55-08:00 AR2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IPon the interface GigabitEthernet0/0/1 has entered the UP state.
[AR2-GigabitEthernet0/0/1]int g0/0/0
[AR2-GigabitEthernet0/0/0]ip add 172.16.1.254 24
May 27 2024 14:34:04-08:00 AR2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IPon the interface GigabitEthernet0/0/0 has entered the UP state.
[AR2-GigabitEthernet0/0/0]
配置DHCP
# AR1
[AR1]ip pool 1 //創建ip地址池,后跟地址池名稱
Info: It's successful to create an IP address pool.
[AR1-ip-pool-1]network 192.168.1.0 mask 24 //dhcp分配的網絡及其掩碼
[AR1-ip-pool-1]gateway-list 192.168.1.254 //dhcp分配的網關地址
[AR1-ip-pool-1]static-bind ip-address 192.168.1.1 mac-address 5489-9838-24A8 //配置靜態ip地址分配,后跟PC的MAC地址
[AR1-ip-pool-1]q
[AR1]dhcp enable //開啟dhcp服務
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]dhcp select global //將dhcp應用到全局接口
# AR2
<AR2>sys
Enter system view, return user view with Ctrl+Z.
[AR2]ip pool 1
Info: It's successful to create an IP address pool.
[AR2-ip-pool-1]network 172.16.1.0 mask 24
[AR2-ip-pool-1]gateway-list 172.16.1.254
[AR2-ip-pool-1]q
[AR2]dhcp enable
[AR2]int g0/0/0
[AR2-GigabitEthernet0/0/0]dhcp select global
配置靜態路由
# AR1
[AR1]ip route-static 172.16.1.0 24 10.1.12.2
# AR2
[AR2]ip route-static 192.168.1.0 24 10.1.12.1
測試
獲取PC1的IP地址
PC2
PC3
ping測試