拓扑图如下:
AR-1配置命令如下:
<Huawei>system-view //进系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR-1 //修改主机名为AR-1
[AR-1]int g0/0/2 //进接口
[AR-1-GigabitEthernet0/0/2]ip address 192.168.1.254 255.255.255.0 //配置IP地址和子网掩码
[AR-1-GigabitEthernet0/0/2]int g0/0/0 //切换接口
[AR-1-GigabitEthernet0/0/0]ip address 192.168.2.1 24 //配置IP地址和子网掩码
[AR-1-GigabitEthernet0/0/0]int g0/0/1 //切换接口
[AR-1-GigabitEthernet0/0/1]ip address 192.168.3.1 24 //配置IP地址和子网掩码
[AR-1]ip route-static 192.168.4.0 255.255.255.0 192.168.2.2 //配置静态路由
[AR-1]ip route-static 192.168.4.0 255.255.255.0 192.168.3.2 preference 100 //配置优先级为100
AR-2配置命令如下:
<Huawei>system-view //进系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR-2 //修改主机名为AR-2
[AR-2]int g0/0/0 //进接口
[AR-2-GigabitEthernet0/0/0]ip address 192.168.2.2 24 //配置IP地址和子网掩码
[AR-2-GigabitEthernet0/0/0]int g0/0/1 //切换接口
[AR-2-GigabitEthernet0/0/1]ip address 192.168.3.2 24 //配置IP地址和子网掩码
[AR-2-GigabitEthernet0/0/1]int g0/0/2 //切换接口
[AR-2-GigabitEthernet0/0/2]ip address 192.168.4.254 24 //配置IP地址和子网掩码
[AR-2]ip route-static 192.168.1.0 255.255.255.0 192.168.2.1 //配置静态路由
[AR-2]ip route-static 192.168.1.0 255.255.255.0 192.168.3.1 preference 100 //配置优先级为100
测试pc机
pc1 ping pc2的IP地址发现可以ping通的