VRRP:(公有协议)
在多个路由器之间运行,
可以虚拟出一个或者多个网关IP地址(虚拟路由器);
从而实现内网不同网段之间的互通
VRRP的工作过程:
1、运行VRRP的“多个”路由器之间通过VRRP报文的交互,从而选择出一个最牛的路由器,作为Master路由器,以后就用来这个设备来转发数据包;
2、Master路由器,仅仅只有一个,其他的路由器称之为backup路由器;/3、同时,Master和Backup路由器,会产生一个虚拟的路由器,也就是一个虚拟的IP地址
实验步骤
SW1
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname SW3
[SW3]v b 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[SW3]int e0/0/1
[SW3-Ethernet0/0/1]p l a
[SW3-Ethernet0/0/1]p d v 10
[SW3-Ethernet0/0/1]un sh
Info: Interface Ethernet0/0/1 is not shutdown.
[SW3-Ethernet0/0/1]int e0/0/2
[SW3-Ethernet0/0/2]p l a
[SW3-Ethernet0/0/2]p d v 20
[SW3-Ethernet0/0/2]un sh
Info: Interface Ethernet0/0/2 is not shutdown.
[SW3-Ethernet0/0/2]int g0/0/1
[SW3-GigabitEthernet0/0/1]p l t
[SW3-GigabitEthernet0/0/1]p t a v 10 20
[SW3-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[SW3-GigabitEthernet0/0/1]int g0/0/2
[SW3-GigabitEthernet0/0/2]p l t
[SW3-GigabitEthernet0/0/2]p t a v 10 20
[SW3-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[SW3-GigabitEthernet0/0/2]
RSW1
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname RSW1
[RSW1]v b 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[RSW1]int g0/0/2
[RSW1-GigabitEthernet0/0/2]p l t
[RSW1-GigabitEthernet0/0/2]p t a v 10 20
[RSW1-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[RSW1-GigabitEthernet0/0/2]int g0/0/1
[RSW1-GigabitEthernet0/0/1]p l a
[RSW1-GigabitEthernet0/0/1]p d v 100
[RSW1-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[RSW1-GigabitEthernet0/0/1]q
[RSW1]int Vlanif 10
[RSW1-Vlanif10]ip add 192.168.10.10 24
[RSW1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1
[RSW1-Vlanif10]vrrp vrid 1 priority 120
[RSW1-Vlanif10]vrrp vrid 1 track interface GigabitEthernet 0/0/1
[RSW1-Vlanif10]vrrp vrid 1 track interface GigabitEthernet 0/0/2
[RSW1-Vlanif10]q
[RSW1]int Vlanif 20
[RSW1-Vlanif20]ip add 192.168.20.10 24
[RSW1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.1
[RSW1-Vlanif20]vrrp vrid 2 priority 115
[RSW1-Vlanif20]q
[RSW1]int Vlanif 100
[RSW1-Vlanif100]ip add 11.0.0.2 30
[RSW1-Vlanif100]q
[RSW1]ip route-static 0.0.0.0 0.0.0.0 11.0.0.1
[RSW1]int g0/0/1
[RSW1-GigabitEthernet0/0/1]shutdown
[RSW1-GigabitEthernet0/0/1]un sh
RSW2
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname RSW2
[RSW2]v b 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[RSW2]int g0/0/2
[RSW2-GigabitEthernet0/0/2]p l t
[RSW2-GigabitEthernet0/0/2]p t a v 10 20
[RSW2-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[RSW2-GigabitEthernet0/0/2]int g0/0/1
[RSW2-GigabitEthernet0/0/1]p l a
[RSW2-GigabitEthernet0/0/1]p d v 100
[RSW2-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[RSW2-GigabitEthernet0/0/1]q
[RSW2]int Vlanif 10
[RSW2-Vlanif10]ip add 192.168.10.20 24
[RSW2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1
[RSW2-Vlanif10]vrrp vrid 1 priority 115
[RSW2-Vlanif10]q
[RSW2]int Vlanif 20
[RSW2-Vlanif20]ip add 192.168.20.20 24
[RSW2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.1
[RSW2-Vlanif20]vrrp vrid 2 priority 120
[RSW2-Vlanif20]vrrp vrid 2 track interface GigabitEthernet 0/0/1
[RSW2-Vlanif20]vrrp vrid 2 track interface GigabitEthernet 0/0/2
[RSW2-Vlanif20]q
[RSW2]int Vlanif 100
[RSW2-Vlanif100]ip add 12.0.0.2 30
[RSW2-Vlanif100]q
[RSW2]ip route-static 0.0.0.0 0.0.0.0 12.0.0.1
R1
<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 11.0.0.1 30
[R1-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R1-GigabitEthernet0/0/0]int g0/0/1
[R1-GigabitEthernet0/0/1]ip add 12.0.0.1 30
[R1-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R1-GigabitEthernet0/0/1]int loo 0
[R1-LoopBack0]ip add 1.1.1.1 24
[R1-LoopBack0]q
[R1]ip route-static 192.168.10.0 24 11.0.0.2
[R1]ip route-static 192.168.10.0 24 12.0.0.2 preference 70
[R1]ip route-static 192.168.20.0 24 12.0.0.2
[R1]ip route-static 192.168.20.0 24 11.0.0.2 preference 70
总结:PC1和PC2 是互通的,当其中三层交换机(RSW1)关闭一个接口时同样会有备用线路联通。
关闭接口后,![](https://i-blog.csdnimg.cn/blog_migrate/ae31d205084816c0017ef7fef98f7fda.png)
首先抓包查看,如下图:![](https://i-blog.csdnimg.cn/blog_migrate/1c06fb33593ca6fe3825f6dbe8aa6243.png)
当RSW1上的g0/0/1接口关闭(接口由绿变红)时,优先级会减10,如下图: