拓扑图如下:
SW-1配置命令如下:
<Huawei>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 //配置静态路由
SW-2:
<Huawei>system-view //进系统视图
Enter