一、什么是HSRP
HSRP(Hot Standby Router Protocol)是Cisco的专有协议,用于实现网络中路由器的冗余和故障转移。通过HSRP,可以将多台路由器组成一个“热备份组”,形成一个虚拟路由器。在这个组内,只有一个路由器是Active(活动)的,负责转发数据包。
二、什么是VRRP
VRRP(Virtual Router Redundancy Protocol)是一种网络协议,用于实现路由器的冗余和故障转移,以增加网络的可用性和可靠性。VRRP允许将多台物理路由器加入到一个虚拟路由器组中。在这个组中,一台路由器被选为Master路由器,负责转发数据包,而其他路由器则作为备份路由器。如果Master路由器出现故障,备份路由器将自动接管数据包转发任务,从而实现无缝切换,确保网络的连续运行。
三、HSRP配置
1、配置为HSRP的成员
Switch(config-if)#standby group-number ip virtual-ip-address
2、配置HSRP的优先级
Switch(config-if)#standby group-number priority priority-value
3、HSRP占先权
Switch(config-if)#standby group-number preempt
4、HSRP计时器配置
Switch(config-if)#standby group-number times hellotime holdtime
5、配置HSRP端口跟踪
Switch(config-if)#standby group-number track type mod/num interface-priority
6、查看HSRP的状态
#查看HSRP摘要信息
Switch#show standby brief
#查看HSRP详细信息
Switch#show standby
四、VRRP配置
1.配置虚拟IP地址:
vrrp vrid <VID> virtual-ip <IP地址>
[Huawei-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.254
2.配置优先级
[Huawei-Vlanif10]vrrp vrid 1 priority 120
3.配置抢占模式
vrrp vrid <VID> preemptive-mode
4.配置端口跟踪
[Huawei-Vlanif10]vrrp vrid 1 track interface Vlanif 10
五、实验
实验要求:
1.配置多层交换机 0为 vlan 10 根网桥,配置多层交换 1 为 vlan 20 根网桥2.配置多层交换机 0 为 vlan 10 的活跃路由器,为 van 20 的备份路由器
3.配置多层交换机 1为 vlan 20 的活跃路由器,为 vlan 10 的备份路由器
4.配置端口跟踪
二层交换机SW5
<Huawei>system-view
[Huawei]vlan 10
[Huawei-vlan10]vlan 20[Huawei-vlan20]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 20[Huawei-GigabitEthernet0/0/1]int g0/0/3
[Huawei-GigabitEthernet0/0/3]port link-type trunk
[Huawei-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[Huawei-GigabitEthernet0/0/1]int g0/0/4
[Huawei-GigabitEthernet0/0/3]port link-type trunk
[Huawei-GigabitEthernet0/0/3]port trunk allow-pass vlan all
[Huawei]stp region-configuration
[Huawei-mst-region]region-name 1
[Huawei-mst-region]instance 1 vlan 10
[Huawei-mst-region]instance 2 vlan 20[Huawei-mst-region]active region-configuration
层交换机SW6
<Huawei>system-view
[Huawei]vlan 10
[Huawei-vlan10]vlan 20[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[Huawei]int g0/0/3
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[Huawei]stp region-configuration
[Huawei-mst-region]region-name 1[Huawei-mst-region]instance 1 vlan 10
[Huawei-mst-region]instance 2 vlan 20[Huawei]stp instance 1 root primary
[Huawei]stp instance 2 root secondary
[Huawei-vlan10]int vlan 10
[Huawei-Vlanif10]ip add 192.168.10.252 255.255.255.0
[Huawei-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.254
[Huawei-vlan20]int vlan 20
[Huawei-Vlani210]ip add 192.168.20.252 255.255.255.0
[Huawei-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.254
层交换机SW7
<Huawei>system-view
[Huawei]vlan 10
[Huawei-vlan10]vlan 20[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[Huawei]int g0/0/3
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[Huawei]stp region-configuration
[Huawei-mst-region]region-name 1[Huawei-mst-region]instance 1 vlan 10
[Huawei-mst-region]instance 2 vlan 20[Huawei]stp instance 2 root primary
[Huawei]stp instance 1 root secondary
[Huawei-vlan10]int vlan 10
[Huawei-Vlanif10]ip add 192.168.10.253 255.255.255.0
[Huawei-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.254
[Huawei-vlan20]int vlan 20
[Huawei-Vlani210]ip add 192.168.20.253 255.255.255.0
[Huawei-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.254