拓扑图
要求
- 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测试