VRRP 虚拟路由冗余协议

VRRP 虚拟路由冗余协议

作用:

VRRP是一种路由器备份机制,防止网关路由器单点故障。保证网络主机的网关路由器故障时,可及时由另一个路由器接替工作,从而保证网络的连续性和可靠性


VRRP概念:

VRRP组:由至少两个接入在同一个网络里的路由器组成 VRID:作为每一个VRRP组的唯一标识


虚拟路由器

由VRRP抽象生成出的逻辑路由器,此路由器上有虚拟IP和虚拟MAC

虚拟IP(VIP)

VRRP虚拟路由器的IP地址,是所有该网络主机的默认网关地址,VRRP组中由MASTER路由器承载虚拟IP 虚拟MAC:VRRP虚拟路由器的MAC地址,格式为 00-00-5E-00-01-{VRID}


MASTER路由器:

承载虚拟IP,实际负责接收该网络主机发送的数据并转发;定期给BACKUP路由器发送VRRP消息告知自己的存活状态

BACKUP路由器:

监听MASTER路由器发送的VRRP消息,当在超时时间范围内没有接收到VRRP报文,则会接替MASTER路由器的工作

MASTER 和 BACKUP 的选举依据:

  • 优先通过比较 VRRP 优先级来选举,值越大,优先级越高
  • 如果优先级一样,则再通过比较接口的IP地址来选举,IP越大,优先级越高

    VRRP配置:

[R1]int vlanif 10

网关接口(三层交换为VLAN接口,路由器为下行接口)

[R1-Vlanif10]ip address 192.168.10.11 24

配置网关地址

[R1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1   

创建VRRP虚拟路由器的标识vrid为1,并配置vrid 1的虚拟IP地址

[R1-Vlanif10]vrrp vrid 1 priority 120

设置设备A的优先级为120(缺省值为100),数值越大越优先

[R1-Vlanif10]vrrp vrid 1 preempt-mode timer delay 6       

配置Master设备的抢占时延为6秒(缺省值为0,立即抢占),以防频繁地进行状态切换

[R1-Vlanif10]vrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 30

跟踪上行接口G0/0/1的状态,如端口故障则Master优先级降低30(缺省值为10) [R1-

Vlanif10]vrrp vrid 1 track interface g0/0/2

跟踪下行接口

实践:

配置主机

配置AR1、AR2、AR3的接口地址

dis ip interface brief                            查看IP配置

un sh                                                    保存

system-view(或 sys)

sys R1

进入系统,方便记忆  sys R1  更改名称为R1、R2、R3  

 

int  g0/0/0                           进入端口,并  ip add ip地址 子网掩码  进行端口配置

R1配置

<Huawei>sys                                            进入系统
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R1                                         更名R1

[R1]int g0/0/0                                         进入g0/0/0

[R1-GigabitEthernet0/0/0]ip add 13.0.0.1               配置IP地址为13.0.0.1

[R1-GigabitEthernet0/0/0]un sh                         保存
Info: Interface GigabitEthernet0/0/0 is not shutdown.

[R1-GigabitEthernet0/0/0]int g0/0/1                    进入g0/0/1

[R1-GigabitEthernet0/0/1]ip add 192.168.10.253 24      配置IP地址为13.0.0.1

[R1-GigabitEthernet0/0/1]q                             退出


[R1]dis ip int	
[R1]dis ip interface b	
[R1]dis ip interface brief                              查看IP配置
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 1

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              13.0.0.1/24          up         up        
GigabitEthernet0/0/1              192.168.10.253/24    up         up        
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)     

R2配置

<Huawei>sys                                                         进入系统
Enter system view, return user view with Ctrl+Z.

[Huawei]sys R2                                                      更名R2

[R2]int g 0/0/0                                                     进入g0/0/0


[R2-GigabitEthernet0/0/0]ip add 20.0.0.2 24                       配置IP地址为20.0.0.2 24
Mar 31 2024 17:19:16-08:00 R2 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 
[R2-GigabitEthernet0/0/0]un sh                                       保存
Info: Interface GigabitEthernet0/0/0 is not shutdown.


[R2-GigabitEthernet0/0/0]int g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.10.252 24                 配置IP地址为20.0.0.2 24
Mar 31 2024 17:20:37-08:00 R2 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 


[R2-GigabitEthernet0/0/1]un sh                                      保存
Info: Interface GigabitEthernet0/0/1 is not shutdown.


[R2-GigabitEthernet0/0/1]q                                          退出
[R2]dis ip int b                                                    查看
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 1

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              20.0.0.2/24          up         up        
GigabitEthernet0/0/1              192.168.10.252/24    up         up        
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)     
[R2]

R3如上

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R3


[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 10.0.0.1 24
[R3-GigabitEthernet0/0/0]
Mar 31 2024 17:27:12-08:00 R3 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP 
on the interface GigabitEthernet0/0/0 has entered the UP state. 


[R3-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.


[R3-GigabitEthernet0/0/0]int g 0/0/1
[R3-GigabitEthernet0/0/1]ip add 13.0.0.3 24
Mar 31 2024 17:27:49-08:00 R3 %%01IFNET/4/LINK_STATE(l)[1]:The line protocol IP 
on the interface GigabitEthernet0/0/1 has entered the UP state. 

[R3-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.

[R3-GigabitEthernet0/0/1]int g0/0/2
[R3-GigabitEthernet0/0/2]ip add 20.0.0.3 24
[R3-GigabitEthernet0/0/2]
Mar 31 2024 17:28:16-08:00 R3 %%01IFNET/4/LINK_STATE(l)[2]:The line protocol IP 
on the interface GigabitEthernet0/0/2 has entered the UP state. 

[R3-GigabitEthernet0/0/2]un sh
Info: Interface GigabitEthernet0/0/2 is not shutdown.

[R3-GigabitEthernet0/0/2]q

[R3]dis ip int b
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 4
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 4
The number of interface that is DOWN in Protocol is 0

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.0.0.1/24          up         up        
GigabitEthernet0/0/1              13.0.0.3/24          up         up        
GigabitEthernet0/0/2              20.0.0.3/24          up         up        
NULL0                             unassigned           up         up(s)     
[R3]

[R1]int vlanif 10网关接口(    三层交换为VLAN接口,路由器为下行接口)

[R1-Vlanif10]ip address 192.168.10.11 24    配置网关地址

[R1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1   创建VRRP虚拟路由器的标识vrid为1,并配置vrid 1的虚拟IP地址

[R1-Vlanif10]vrrp vrid 1 priority 120  设置设备A的优先级为120(缺省值为100),数值越大越优先

[R1-Vlanif10]vrrp vrid 1 preempt-mode timer delay 6       配置Master设备的抢占时延为6秒(缺省值为0,立即抢占),以防频繁地进行状态切换

[R1-Vlanif10]vrrp vrid 1 track interface GigabitEthernet0/0/1 reduced 30  跟踪上行接口G0/0/1的状态,如端口故障则Master优先级降低30(缺省值为10)

[R1-Vlanif10]vrrp vrid 1 track interface g0/0/2  跟踪下行接口

[R1]int g0/0/0                  进入g0/0/0
[R1-GigabitEthernet0/0/0]vrrp vr	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 vir	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 virtual-ip 192.168.10.254  
                 创建VRRP虚拟路由器的标识vrid为10,并配置vrid 1的虚拟IP地址
Error: The virtual IP address already exists.
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]vr	
[R1-GigabitEthernet0/0/0]vrrp vri	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 pr	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 prior	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 priority 120   
        设置设备10的优先级为120(缺省值为100),数值越大越优先
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]
[R1-GigabitEthernet0/0/0]vrr	
[R1-GigabitEthernet0/0/0]vrrp vri	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 pre	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 preempt-mode tim	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 preempt-mode timer  de	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 preempt-mode timer  delay 10
 配置Master设备的抢占时延为10秒(缺省值为0,立即抢占),以防频繁地进行状态切换


[R1-GigabitEthernet0/0/0]vrrp vrid 10 tra	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 track in	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 track int g0/0/1 re	
[R1-GigabitEthernet0/0/0]vrrp vrid 10 track int g0/0/1 reduced 30
          跟踪上行接口G0/0/1的状态,如端口故障则Master优先级降低30(缺省值为10)
Error: The specified interface has been tracked.

 R2

[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]vr	
[R2-GigabitEthernet0/0/0]vrrp vr	
[R2-GigabitEthernet0/0/0]vrrp vrid 10 virt	
[R2-GigabitEthernet0/0/0]vrrp vrid 10 virtua	
[R2-GigabitEthernet0/0/0]vrrp vrid 10 virtual-ip 192.168.10.254
 创建VRRP虚拟路由器的标识vrid为10,并配置vrid 1的虚拟IP地址
Error: The virtual IP address already exists.
[R2-GigabitEthernet0/0/0]
[R2-GigabitEthernet0/0/0]

[R2-GigabitEthernet0/0/0]vrr	
[R2-GigabitEthernet0/0/0]vrrp vr	
[R2-GigabitEthernet0/0/0]vrrp vrid 10	
[R2-GigabitEthernet0/0/0]vrrp vrid 10 pri	
[R2-GigabitEthernet0/0/0]vrrp vrid 10 priority 110
设置设备10的优先级为110(缺省值为100),数值越大越优先

R1

静态路由配置指令:ip route-static 目标网段 子网掩码 下一跳地址

<R1>sys
Enter system view, return user view with Ctrl+Z.
[R1]ip rou	
[R1]ip route-sta	
[R1]ip route-static 10.0.0.0 24 13.0.0.3  
Error: The route already exists.

R2

[R2]ip route-static 10.0.0.0 24 23.0.0.3
Error: The route already exists.

R3

[R3]ip rou	
[R3]ip route-static 192.168.10.253 24 13.0.0.1
Error: The route already exists.
[R3]ip route-static 192.168.10.253 24 13.0.0.1
Error: The route already exists.
[R3]
[R3]
[R3]ip rou	
[R3]ip route
[R3]ip route-static 192.168.10.0 24 13.0.0.1
Error: The route already exists.
[R3]ip route-static 192.168.10.0 24 20.0.0.2
[R3]

PC1pingPC2

  • 23
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值