VRRP:虚拟路由器冗余协议

网友投稿 255 2022-11-06

VRRP:虚拟路由器冗余协议

VRRP:虚拟路由器冗余协议

虚拟路由器冗余协议工作在网络层,通过组播地址:224.0.0.18发送,TTL为255,协议号:112

工作原理:一组路由器(同一个lan中的接口)协同工作,但只有一个处于Master状态,处于该状态的路由器(的接口)承担实际的数据流量转发任务,在一个VRRP组内的多个路由器接口共用一个虚拟IP地址,该地址被作为局域网内所有主机的缺省网管地址。

VRRP术语:

1. VRRP路由器:

VRRP路由器,运行VRRP的路由器,一台VRRP路由器(的接口)可以同时参与到多个VRRP组中,在不同的组中,一台VRRP路由器可以充当不通的角色。

2. VRRP组:

一个VRRP组由多个VRRP路由器组成,使用相同的VRID(Vritual Router ID虚拟路由器ID)进行标识,属于同一个VRRP组的VRRP路由器互相交换信息,每一个VRRP组中只能有一个Master。

3. 虚拟路由器:

对于每一个VRRP组,抽象出来的一个逻辑路由器,该路由器充当网络用户的网关,该路由器并非真实存在的,事实上对用户而言,只需要知道虚拟路由器的IP,至于具体的虚拟路由器由谁来承担,数据转发任务由谁来承担,Masterg故障后谁来接替,这是VRRP的工作。

4. 虚拟IP地址:

就是虚拟路由器的IP地址,该地址实际上就是用户的网关地址。

5. 虚拟MAC地址:

虚拟路由器根据VRID生成的MAC地址,一个虚拟路由器拥有一个虚拟MAC地址,有固定格式,为:00-00-5E-00-01-{VRID}。

6. Master路由器:

Master路由器:在VRRP组中,实际转发数据包的路由器,在每一个VRRP组中,仅有Master响应对虚拟IP地址的ARP请求。(1)Master路由器同时以一定的时间间隔发送VRRP消息,以便通知Backup路由器自己的存活状态。(2)以虚拟MAC地址响应其他设备对虚拟IP地址的ARP请求。(3)转发目的MAC地址为虚拟MAC地址的IP报文。(4)如果它是这个虚拟IP地址的拥有者(接口实际IP地址为虚拟IP地址),则接收目的IP地址为这个虚拟IP地址的IP报文,否则,丢弃这个IP报文。(5)如果收到比自己优先级大的报文,立即成为Backup.(6)如果收到与自己优先级相等的VRRP报文且本地接口IP地址小于对端接口IP,立即成为Backup。

7. Backup路由器:

Backup路由器是处于监听状态的路由器,一点Master路由器出现故障,Backup路由器就开始接替工作。(1)接受Master设备发送的VRRP通告报文,判断Master设备的状态是否正常。(2)对虚拟IP地址的ARP请求,不做响应。(3)丢弃目标IP地址为虚拟IP的IP报文(4)如果收到优先级和自己相同或者比自己大的报文,则重置Master_Down_Interval定时器,不进一步比较IP地址。(5)如果收到比自己优先级小的报文,且该报文优先级是0时,定时器时间设置为Skew_time(偏移时间)如果该报文优先级不是0,丢弃报文,立刻成为Master。

VRRP协议的配置

交换机SW3的配置:

sys Enter system view, return user view with Ctrl+Z. [Huawei]sys SW3 [SW3]un in en [SW3]user-interface console 0 [SW3-ui-console0]idle-timeout 0 0 [SW3-ui-console0]q [SW3]vlan batch 10 20 [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 [SW3-Ethernet0/0/1]dis th #interface Ethernet0/0/1 port link-type access port default vlan 10 # return [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 [SW3-Ethernet0/0/2]dis th # interface Ethernet0/0/2 port link-type access port default vlan 20 # return [SW3-Ethernet0/0/2]int e0/0/3 [SW3-Ethernet0/0/3]p l t [SW3-Ethernet0/0/3]p t a v a [SW3-Ethernet0/0/3]un sh [SW3-Ethernet0/0/3]dis th # interface Ethernet0/0/3 port link-type trunk port trunk allow-pass vlan 2 to 4094 # return [SW3-Ethernet0/0/3]int e0/0/4 [SW3-Ethernet0/0/4]p l t [SW3-Ethernet0/0/4]p t a v a [SW3-Ethernet0/0/4]un sh [SW3-Ethernet0/0/4]dis th # interface Ethernet0/0/4 port link-type trunk port trunk allow-pass vlan 2 to 4094 # return [SW3-Ethernet0/0/4]q [SW3]

交换机SW1的配置:

sys [Huawei]sys SW1 [SW1]un in en [SW1]user-interface console 0 [SW1-ui-console0]idle-timeout 0 0 [SW1-ui-console0]q [SW1]vlan batch 10 20 [SW1]interface Vlanif 10 [SW1-Vlanif10]ip add 192.168.10.1 24 [SW1-Vlanif10]interface Vlanif 20 [SW1-Vlanif20]ip add 192.168.20.200 24 [SW1-Vlanif20]interface Vlanif 10 [SW1-Vlanif10]ip add 192.168.10.100 24 [SW1-Vlanif10]dis th # interface Vlanif10 ip address 192.168.10.100 255.255.255.0 # return [SW1-Vlanif10]q [SW1]vlan 30 [SW1-vlan30]q [SW1]interface Vlanif 30 [SW1-Vlanif30]ip add 13.0.0.1 24 [SW1-Vlanif30]dis th # interface Vlanif30 ip address 13.0.0.1 255.255.255.0 # return [SW1-Vlanif30]q [SW1]int g0/0/2 [SW1-GigabitEthernet0/0/2]p l a [SW1-GigabitEthernet0/0/2]p d v 30 [SW1-GigabitEthernet0/0/2]un sh [SW1-GigabitEthernet0/0/2]dis th # interface GigabitEthernet0/0/2 port link-type access port default vlan 30 # return [SW1-GigabitEthernet0/0/2]q [SW1]int g0/0/1 [SW1-GigabitEthernet0/0/1]p l t [SW1-GigabitEthernet0/0/1]p t a v a [SW1-GigabitEthernet0/0/1]un sh [SW1-GigabitEthernet0/0/1]dis th # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094 # return [SW1-GigabitEthernet0/0/1]q [SW1]ip route-static 0.0.0.0 0.0.0.0 13.0.0.2 [SW1]int vl [SW1]int Vlanif 10 ###网关接口(三层交换为VLAN接口,路由为下行接口) [SW1-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.1 ==//创建VRRP虚拟路由器的标识VRID为1,并配置VRID 1的虚拟IP地址== [SW1-Vlanif10]vrrp vrid 10 priority 120 ==//设置设备A的优先级为120(缺省值为100),数值越大越优先== [SW1-Vlanif10]vrrp vrid 10 preempt-mode timer delay 5 ==//配置Master设备的抢占时延为5秒(缺省值为0,立即抢占),以防频繁地进行状态切换 == [SW1-Vlanif10]vrrp vrid 10 track interface GigabitEthernet 0/0/2 reduced 30 ==//跟踪上行接口G0/0/1的状态,如端口故障则Master优先级降低30(缺省值为10)== [SW1-Vlanif10]q [SW1]dis vrrp == //显示VRRP状态== Vlanif10 | Virtual Router 10 State : Master Virtual IP : 192.168.10.1 Master IP : 192.168.10.100 PriorityRun : 120 PriorityConfig : 120 MasterPriority : 120 Preempt : YES Delay Time : 5 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-010a Check TTL : YES Config type : normal-vrrp Track IF : GigabitEthernet0/0/2 Priority reduced : 30 IF state : UP Create time : 2021-10-19 15:39:39 UTC-08:00 Last change time : 2021-10-19 15:39:43 UTC-08:00 [SW1]int Vlanif 20 [SW1-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.1 [SW1-Vlanif20]q [SW1]

交换机SW2的配置:

sys [Huawei]sys SW2 [SW2]un in en [SW2]user-interface console 0 [SW2-ui-console0]idle-timeout 0 0 [SW2-ui-console0]q [SW2]vlan b 10 20 30 [SW2]int Vlanif 10 [SW2-Vlanif10]ip add 192.168.10.200 24 [SW2-Vlanif10]int Vlanif 20 [SW2-Vlanif20]ip add 192.168.20.200 24 [SW2-Vlanif20]int Vlanif 30 [SW2-Vlanif30]ip add 23.0.0.1 24 [SW2-Vlanif30]dis th # interface Vlanif30 ip address 23.0.0.1 255.255.255.0 # return [SW2-Vlanif30]q [SW2]int g0/0/1 [SW2-GigabitEthernet0/0/1]p l t [SW2-GigabitEthernet0/0/1]p t a v a [SW2-GigabitEthernet0/0/1]un sh [SW2-GigabitEthernet0/0/1]dis th # interface GigabitEthernet0/0/1 port link-type trunk port trunk allow-pass vlan 2 to 4094 # return [SW2-GigabitEthernet0/0/1]int g0/0/2 [SW2-GigabitEthernet0/0/2]p l a [SW2-GigabitEthernet0/0/2]p d v 30 [SW2-GigabitEthernet0/0/2]un sh [SW2-GigabitEthernet0/0/2]dis th # interface GigabitEthernet0/0/2 port link-type access port default vlan 30 # return [SW2-GigabitEthernet0/0/2]q [SW2]ip route-static 0.0.0.0 0.0.0.0 23.0.0.2 [SW2]int Vlanif 20 [SW2-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.1 [SW2-Vlanif20]vrrp vrid 20 priority 120 [SW2-Vlanif20]vrrp vrid 20 preempt-mode timer delay 5 [SW2-Vlanif20]vrrp vrid 20 track interface GigabitEthernet 0/0/2 ==//追踪上行接口的状态,以便最早发现借口是否断掉== [SW2-Vlanif20]dis th # interface Vlanif20 ip address 192.168.20.200 255.255.255.0 vrrp vrid 20 virtual-ip 192.168.20.1 vrrp vrid 20 priority 120 vrrp vrid 20 preempt-mode timer delay 5 vrrp vrid 20 track interface GigabitEthernet0/0/2 # return [SW2-Vlanif20]q [SW2]dis vrrp Vlanif20 | Virtual Router 20 State : Master Virtual IP : 192.168.20.1 Master IP : 192.168.20.200 PriorityRun : 120 PriorityConfig : 120 MasterPriority : 120 Preempt : YES Delay Time : 5 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0114 Check TTL : YES Config type : normal-vrrp Track IF : GigabitEthernet0/0/2 Priority reduced : 10 IF state : UP Create time : 2021-10-19 15:32:02 UTC-08:00 Last change time : 2021-10-19 15:32:05 UTC-08:00 [SW2]int Vlanif 10 [SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.1 [SW2-Vlanif10]q [SW2]dis vrrp Vlanif10 | Virtual Router 10 State : Backup Virtual IP : 192.168.10.1 Master IP : 192.168.10.100 PriorityRun : 100 PriorityConfig : 100 MasterPriority : 120 Preempt : YES Delay Time : 0 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-010a Check TTL : YES Config type : normal-vrrp Create time : 2021-10-19 15:42:16 UTC-08:00 Last change time : 2021-10-19 15:42:16 UTC-08:00 Vlanif20 | Virtual Router 20 State : Master Virtual IP : 192.168.20.1 Master IP : 192.168.20.200 PriorityRun : 120 PriorityConfig : 120 MasterPriority : 120 Preempt : YES Delay Time : 5 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0114 Check TTL : YES Config type : normal-vrrp Track IF : GigabitEthernet0/0/2 Priority reduced : 10 IF state : UP Create time : 2021-10-19 15:32:02 UTC-08:00 Last change time : 2021-10-19 15:32:05 UTC-08:00 [SW2]

路由器R1的配置:

sys [Huawei]sys R1 [R1]un in en [R1]user-interface console 0 [R1-ui-console0]idle-timeout 0 0 [R1-ui-console0]q [R1]int g0/0/2 [R1-GigabitEthernet0/0/2]ip add 13.0.0.2 24 [R1-GigabitEthernet0/0/2]un sh [R1-GigabitEthernet0/0/2]int g0/0/1 [R1-GigabitEthernet0/0/1]ip add 23.0.0.2 24 [R1-GigabitEthernet0/0/1]un sh [R1-GigabitEthernet0/0/1]q [R1]int LoopBack 0 [R1-LoopBack0]ip add 30.0.0.1 24 [R1-LoopBack0]q [R1]ip route-static 192.168.10.0 24 13.0.0.1 [R1]ip route-static 192.168.20.0 24 13.0.0.1 [R1]ip route-static 192.168.10.0 24 23.0.0.1 preference 70 ==//设置备用路由,默认优先级为60,只要比默认数值大就变成备用了== [R1]ip route-static 192.168.20.0 24 23.0.0.1 preference 70 [R1]

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:亚马逊深入汽车领域
下一篇:详解Java接口签名(Signature)实现方案
相关文章

 发表评论

暂时没有评论,来抢沙发吧~