实验拓扑
基础配置
- 配置SW1
# 创建vlan,配置链路聚合
[SW1]vlan batch 10 20
[SW1]int Eth-Trunk 1
[SW1-Eth-Trunk1]trunkport GigabitEthernet 0/0/10 0/0/11
[SW1-Eth-Trunk1]port link-type trunk
[SW1-Eth-Trunk1]port trunk allow-pass vlan all
[SW1-Eth-Trunk1]q
# 配置接口类型
[SW1]int g0/0/1
[SW1-GigabitEthernet0/0/1]port link-type trunk
[SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW1-GigabitEthernet0/0/1]int g0/0/2
[SW1-GigabitEthernet0/0/2] port link-type trunk
[SW1-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 4094
[SW1-GigabitEthernet0/0/2]q
- 配置SW2
# SW2创建vlan,配置链路聚合
[SW2]vlan batch 10 20
[SW2]int Eth-Trunk 1
[SW2-Eth-Trunk1]trunkport GigabitEthernet 0/0/10 0/0/11
[SW2-Eth-Trunk1]port link-type trunk
[SW2-Eth-Trunk1]port trunk allow-pass vlan all
[SW2-Eth-Trunk1]q
# SW2配置接口类型
[SW2]int g0/0/1
[SW2-GigabitEthernet0/0/1]port link-type trunk
[SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[SW2-GigabitEthernet0/0/1]int g0/0/2
[SW2-GigabitEthernet0/0/2] port link-type trunk
[SW2-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 4094
[SW2-GigabitEthernet0/0/2]q
- 配置SW3、SW4
# SW3配置
[SW3]vlan ba 10 20
[SW3]int g0/0/2
[SW3-GigabitEthernet0/0/2]port link-type trunk
[SW3-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 4094
[SW3-GigabitEthernet0/0/2]int g0/0/
[SW3-GigabitEthernet0/0/3]port link-type trunk
[SW3-GigabitEthernet0/0/3] port trunk allow-pass vlan 2 to 4094
[SW3-GigabitEthernet0/0/3]q
[SW3]int g0/0/1
[SW3-GigabitEthernet0/0/1]port link-type access
[SW3-GigabitEthernet0/0/1]port default vlan 10
# SW4配置
[SW4]vlan ba 10 20
[SW4]int g0/0/2
[SW4-GigabitEthernet0/0/2]port link-type trunk
[SW4-GigabitEthernet0/0/2] port trunk allow-pass vlan 2 to 4094
[SW4-GigabitEthernet0/0/2]int g0/0/3
[SW4-GigabitEthernet0/0/3]port link-type trunk
[SW4-GigabitEthernet0/0/3] port trunk allow-pass vlan 2 to 409
[SW4]int g0/0/1
[SW4-GigabitEthernet0/0/1]port link-type access
[SW4-GigabitEthernet0/0/1]port default vlan 20
- AR1配置
[AR1]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip ad 10.1.1.1 24
[AR1-GigabitEthernet0/0/0]q
[AR1]ip route-static 0.0.0.0 0 10.1.1.254 //配置静态路由,否则无法互通
配置VRRP
- SW1配置
# 配置vlanif的IP地址,配置VRRP
[SW1]int Vlanif 10
[SW1-Vlanif10]ip ad 10.1.1.2 24
[SW1-Vlanif10]vrrp vrid 1 virtual-ip 10.1.1.254 //配置VRID 1的虚拟网关为10.1.1.254
[SW1-Vlanif10]vrrp vrid 1 priority 120 //配置VRID 1的优先级
[SW1-Vlanif10]q
[SW1]int Vlanif 20
[SW1-Vlanif20]ip ad 20.1.1.2 24
[SW1-Vlanif20]vrrp vrid 2 virtual-ip 20.1.1.254 //配置VRID 2的虚拟网关为20.1.1.254
- SW2配置
[SW2]int Vlanif 10
[SW2-Vlanif10]ip ad 10.1.1.3 24
[SW2-Vlanif10]vrrp vrid 1 virtual-ip 10.1.1.254
[SW2-Vlanif10]q
[SW2]int Vlanif 20
[SW2-Vlanif20]ip ad 20.1.1.3 24
[SW2-Vlanif20]vrrp vrid 2 virtual-ip 20.1.1.254
[SW2-Vlanif20]vrrp vrid 2 priority 120 //配置VRID 2的优先级为120
实验结果
- 当SW2down掉之后(down之前记得save),VRRP可以迅速切换备用网关,进行数据转发,当SW2恢复时,可以迅速切换会主交换机
拓展
vrrp vrid 1 preempt-mode timer delay 20
修改抢占时延vrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 20
配置上行接口down后,自身优先级降20
以上内容均属原创,如有不详或错误,敬请指出。
本文链接: https://blog.csdn.net/qq_45668124/article/details/106016943
版权声明: 本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明出处!