system-view //进系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW-1 //修改主机名为SW-1
[SW-1]vlan 2 //创建vlan 2
[SW-1]vlan 10 //创建vlan 10
[SW-1]interface g0/0/1 //进接口
[SW-1-GigabitEthernet0/0/1]port link-type access //配置access工作模式
[SW-1-GigabitEthernet0/0/1]port default vlan 10 //将g0/0/1接口加入到vlan10里面去
[SW-1-GigabitEthernet0/0/1]int g0/0/2 //切换接口
[SW-1-GigabitEthernet0/0/2]port link-type trunk //配置Trunk工作模式
[SW-1-GigabitEthernet0/0/2]port trunk allow-pass vlan all //让所有vlan通过此接口
[SW-1-GigabitEthernet0/0/2]int vlanif 2 //切换接口
[SW-1-Vlanif2]ip address 192.168.1.1 24 //配置IP地址和子网掩码
[SW-1-Vlanif2]vrrp vrid 1 virtual-ip 192.168.1.254 //配置虚拟网关地址为192.168.1.254
[SW-1-Vlanif2]vrrp vrid 1 priority 200 //配置vrrp优先级200
[SW-1-Vlanif2]vrrp vrid 1 preempt-mode timer delay 20 //开启抢占延迟时间为20s
[SW-1-Vlanif2]vrrp vrid 1 track interface GigabitEthernet 0/0/1 reduced 100 //配置链路跟踪
[SW-1-Vlanif2]int vlanif 10 //切换接口
[SW-1-Vlanif10]ip address 192.168.10.1 30 //配置IP地址和子网掩码为30位的
[SW-1]ip route-static 0.0.0.0 0.0.0.0 192.168.10.2 //配置静态路由
system-view //进系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW-2 //修改主机名为SW-2
[SW-2]vlan 2 //创建vlan2
[SW-2]vlan 20 //创建vlan20
[SW-2]int g0/0/1 //进g0/0/1接口
[SW-2-GigabitEthernet0/0/1]port link-type access //配置access工作模式
[SW-2-GigabitEthernet0/0/1]port default vlan 20 //将g0/0/2接口加入到vlan20里面去
[SW-2-GigabitEthernet0/0/1]int g0/0/2 //切换接口
[SW-2-GigabitEthernet0/0/2]port link-type trunk //配置Trunk工作模式
[SW-2-GigabitEthernet0/0/2]port trunk allow-pass vlan all //让所有vlan通过此接口
[SW-2-GigabitEthernet0/0/2]int vlanif 2 //切换接口
[SW-2-Vlanif2]ip address 192.168.1.2 24 //配置IP地址和子网掩码
[SW-2-Vlanif2]vrrp vrid 1 virtual-ip 192.168.1.254 //配置虚拟网关IP地址为192.168.1.254
[SW-2-Vlanif2]vrrp vrid 1 priority 150 //配置VRRP优先级为150
[SW-2-Vlanif2]int vlanif 20 //切换接口
[SW-2-Vlanif20]ip address 192.168.20.1 30 //配置IP地址和子网掩码为30位的
[SW-2]ip route-static 0.0.0.0 0.0.0.0 192.168.20.2 //配置静态路由
system-view //进系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW-3 //修改主机名为SW-3
[SW-3]vlan 2 //创建vlan 2
[SW-3]int e0/0/1 //进e0/0/1接口
[SW-3-Ethernet0/0/1]port link-type access //配置access工作模式
[SW-3-Ethernet0/0/1]port default vlan 2 //将e0/0/1接口加入到vlan 2 里面去
[SW-3-Ethernet0/0/1]int g0/0/1 //切换接口
[SW-3-GigabitEthernet0/0/1]port link-type access //配置Trunk工作模式
[SW-3-GigabitEthernet0/0/1]port trunk allow-pass vlan all //让所有vlan通过此接口
[SW-3-GigabitEthernet0/0/1]int g0/0/2 //切换接口
[SW-3-GigabitEthernet0/0/2]port link-type trunk //配置Trunk工作模式
[SW-3-GigabitEthernet0/0/2]port trunk allow-pass vlan all //让所有vlan通过此接口
system-view //进系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR-1 //修改主机名为AR-1
[AR-1]int g0/0/1 //进接口
[AR-1-GigabitEthernet0/0/1]ip address 192.168.10.2 30 //配置IP地址和子网掩码为30位
[AR-1-GigabitEthernet0/0/1]int g0/0/2 //切换接口
[AR-1-GigabitEthernet0/0/2]ip address 192.168.20.2 30 //配置IP地址和子网掩码为30位
[AR-1-GigabitEthernet0/0/2]int g0/0/0 //切换接口
[AR-1-GigabitEthernet0/0/0]ip address 1.1.1.254 24 //配置IP地址和子网掩码
[AR-1]ip route-static 192.168.1.0 24 192.168.10.1 //配置动态路由
[AR-1]ip route-static 192.168.1.0 24 192.168.20.1 preference 100 //下一跳地址的优先级为100
SW-1:
[SW-1]dis vrrp //查看vrrp
Vlanif2 | Virtual Router 1
State : Master
Virtual IP : 192.168.1.254
Master IP : 192.168.1.1
PriorityRun : 200
PriorityConfig : 200
MasterPriority : 200
Preempt : YES Delay Time : 20 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Track IF : GigabitEthernet0/0/1 Priority reduced : 100
IF state : UP
Create time : 2020-04-07 21:25:23 UTC-08:00
Last change time : 2020-04-07 21:25:26 UTC-08:00
[SW-1]dis vrrp brief //查看VRRP详细信息
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Master Vlanif2 Normal 192.168.1.254
----------------------------------------------------------------
Total:1 Master:1 Backup:0 Non-active:0
SW-2验证:
[SW-2]dis vrrp
Vlanif2 | Virtual Router 1
State : Backup
Virtual IP : 192.168.1.254
Master IP : 192.168.1.1
PriorityRun : 150
PriorityConfig : 150
MasterPriority : 200
Preempt : YES Delay Time : 0 s
TimerRun : 1 s
TimerConfig : 1 s
Auth type : NONE
Virtual MAC : 0000-5e00-0101
Check TTL : YES
Config type : normal-vrrp
Create time : 2020-04-07 21:49:05 UTC-08:00
Last change time : 2020-04-07 22:06:40 UTC-08:00
[SW-2]dis vrrp brief //查看VRRP详细信息
VRID State Interface Type Virtual IP
----------------------------------------------------------------
1 Backup Vlanif2 Normal 192.168.1.254
----------------------------------------------------------------
Total:1 Master:0 Backup:1 Non-active:0
[SW-2]
dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.0/24 Direct 0 0 D 1.1.1.254 GigabitEthernet
0/0/0
1.1.1.254/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
1.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 Static 60 0 RD 192.168.10.1 GigabitEthernet
0/0/1
192.168.10.0/30 Direct 0 0 D 192.168.10.2 GigabitEthernet
0/0/1
192.168.10.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
192.168.10.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0