VRRP概述及其简单配置

vrrp概述:

1.Virtual Router Redundancy Protocol,也即虚拟路由器冗余协议。

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

3.VRRP决定哪个路由器是Master , Master路由器负责接收发送至用户网关的数据包并进       行转发,以及响应PC对于其网关IP地址的ARP请求。

4.Backup路由器侦听Master路由器的状态,并在Master路由器发生故障时,接替其工         作,从而保证业务流量的平滑切换。


VRRP术语

VRRP路由器:

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

VRRP组:

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

虚拟路由器:

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


虚拟IP地址、MAC地址:

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

2.虚拟MAC地址是虚拟路由器根据VRID生成的MAC地址。一个虚拟路由器拥有一个虚拟       MAC地址,格式为:00-00-5E-0O-O1-fVRID}。

Master&Backup路由器:

Master路由器:在VRRP组中实际转发数据包的路由器,在每一个VRRP组中,仅有Master响应对虚拟IP地址的ARP请求。Master路由器同时以一定的时间间隔发送VRRP消息,以便通知Backup路由器自己的存活情况。

1.以虚拟MAC地址响应其他设备对虚拟IP地址的ARP请求。

2.转发目的MAC地址为虚拟MAC地址的IP报文。

3.如果它是这个虚拟IP地址的拥有者(接口实际P地址为虚拟IP地址),则接收目的IP地址为这个虚拟IP地址的IP报文。否则,丢弃这个IP报文。

4.如果收到比自己优先级大的报文,立即成为Backup。

5.如果收到与自己优先级相等的VRRP报文且本地接口IP地址小于对端接口IP,立即成为Backup。


Backup路由器:处于监听状态的路由器,一旦Master路由器出现故障,Backup路由器就开始接替工作。

1.对虚拟IP地址的ARP请求,不做响应。

2.丢弃目的IP地址为虚拟IP地址的IP报文。

3.如果收到优先级和自己相同或者比自己大的报文,则重置Master_Down_Interval定时器,不进一步比较IP地址。

4.如果收到比自己优先级小的报文且该报文优先级是0时,定时器时间设置为Skew_time(偏移时间),如果该报文优先级不是0,丢弃报文,立刻成为Master。


选举依据:先比较接口VRRP优先级(比大),如果相等,则比较接口IP地址(比大)。


VRRP状态机

VRRP协议的状态共有三种,分别是Initialize,Master ,Backup,初始状态都是lnitialize,通过比较优先级产生Master和Backup,在规定时间内,Backup若没有收到Master发来的心跳报文,将切换为Master。

VRRP概述及其简单配置_mac地址

VRRP的工作过程

1. VRRP组中的设备选举出Master. Master设备通过发送免费ARP报文,将虚拟MAC地址通      知给与它连接的设备或者主机,从而承担报文转发任务。

2. Master设备周期性向备份组内所有Backup设备发送VRRP通告报文。

3.如果Master设备出现故障 , VRRP备份组中的Backup设备重新选举新的Master.

4. VRRP组状态切换时, Master设备由一台设备切换为另外-台设备,新的Master设备会立即      发送携带虚拟路由器的虚拟MAC地址和虚拟IP地址信息的免费ARP报文,刷新与它连接        的主机或设备中的MAC表项,从而把用户流量引到新的Master设备上来,整个过程对用户      完全透明。

5.原Master设备故障恢复时 ,若该设备为IP地址拥有者(则其优先级为255) , 将直接切换至       Master状态。若该设备优先级小于255 ,将首先切换至Backup状态,且其优先级恢复为     故障前配置的优先级。

6. Backup设备的优先级高于Master设备时,

    由Backup设备的工作方式(抢占方式和非抢占方式)决定是否重新选举Master。



配置:


VRRP概述及其简单配置_优先级_02



R1配置:

<Huawei>sys

Enter system view, return user view with Ctrl+Z.

[Huawei]un in en

Info: Information center is disabled.

[Huawei]us  

[Huawei]user-in  

[Huawei]user-interface con  

[Huawei]user-interface console 0

[Huawei-ui-console0]i  

[Huawei-ui-console0]idle-timeout 0 0

[Huawei-ui-console0]q

[Huawei]sys R1

[R1]int g0/0/0

[R1-GigabitEthernet0/0/0]ip add 13.0.0.2 24

[R1-GigabitEthernet0/0/0]un shu

Info: Interface GigabitEthernet0/0/0 is not shutdown.

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

[R1-GigabitEthernet0/0/1]ip add 23.0.0.2 24

[R1-GigabitEthernet0/0/1]un shu

Info: Interface GigabitEthernet0/0/1 is not shutdown.

[R1-GigabitEthernet0/0/1]q

[R1]int l  

[R1]int LoopBack 1

[R1-LoopBack1]ip add 30.0.0.1 24

[R1-LoopBack1]q

[R1]dis ip br

          ^

Error: Unrecognized command found at '^' position.

[R1]dis ip int b  

[R1]dis ip int brief  

*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 1

The number of interface that is UP in Protocol is 4

The number of interface that is DOWN in Protocol is 1


Interface                         IP Address/Mask      Physical   Protocol  

GigabitEthernet0/0/0              13.0.0.2/24          up         up        

GigabitEthernet0/0/1              23.0.0.2/24          up         up        

GigabitEthernet0/0/2              unassigned           down       down      

LoopBack1                         30.0.0.1/24          up         up(s)      

NULL0                             unassigned           up         up(s)      

[R1]q

<R1>sa

 The current configuration will be written to the device.  

 Are you sure to continue? (y/n)[n]:y

 It will take several minutes to save configuration file, please wait.......

 Configuration file had been saved successfully

 Note: The configuration file will take effect after being activated

<R1>



SW1配置:

<Huawei>sys

Enter system view, return user view with Ctrl+Z.

[Huawei]un in en

Info: Information center is disabled.

[Huawei]us  

[Huawei]user-in  

[Huawei]user-interface con  

[Huawei]user-interface console 0

[Huawei-ui-console0]i  

[Huawei-ui-console0]idle-timeout 0 0

[Huawei-ui-console0]q

[Huawei]sys SW1

[SW1]v b 10 20

Info: This operation may take a few seconds. Please wait for a moment...done.

[SW1]int e0/0/1

[SW1-Ethernet0/0/1]p l a

[SW1-Ethernet0/0/1]p d v 10

[SW1-Ethernet0/0/1]un shu

Info: Interface Ethernet0/0/1 is not shutdown.

[SW1-Ethernet0/0/1]int e0/0/2

[SW1-Ethernet0/0/2]p l a

[SW1-Ethernet0/0/2]p d v 20

[SW1-Ethernet0/0/2]un shu

Info: Interface Ethernet0/0/2 is not shutdown.

[SW1-Ethernet0/0/2]int e0/0/3

[SW1-Ethernet0/0/3]p l t

[SW1-Ethernet0/0/3]p t a v a

[SW1-Ethernet0/0/3]

[SW1-Ethernet0/0/3]int e0/0/4

[SW1-Ethernet0/0/4]p l t

[SW1-Ethernet0/0/4]p t a v a

[SW1-Ethernet0/0/4]un shu

Info: Interface Ethernet0/0/4 is not shutdown.

[SW1-Ethernet0/0/4]int e0/0/3

[SW1-Ethernet0/0/3]un shu

Info: Interface Ethernet0/0/3 is not shutdown.

[SW1-Ethernet0/0/3]q

[SW1]q

<SW1>sa

The current configuration will be written to the device.

Are you sure to continue?[Y/N]y

Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:

Now saving the current configuration to the slot 0.

Save the configuration successfully.

<SW1>


SW2配置:

<Huawei>sys

Enter system view, return user view with Ctrl+Z.

[Huawei]un in en

Info: Information center is disabled.

[Huawei]us  

[Huawei]user-in  

[Huawei]user-interface con  

[Huawei]user-interface console 0

[Huawei-ui-console0]i  

[Huawei-ui-console0]idle-timeout 0 0

[Huawei-ui-console0]q

[Huawei]sys SW2

[SW2]v b 10 20 100

Info: This operation may take a few seconds. Please wait for a moment...done.

[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 shu

Info: Interface GigabitEthernet0/0/1 is not shutdown.

[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 100

[SW2-GigabitEthernet0/0/2]un shu

Info: Interface GigabitEthernet0/0/2 is not shutdown.

[SW2-GigabitEthernet0/0/2]dis th

#

interface GigabitEthernet0/0/2

port link-type access

port default vlan 100

#

return

[SW2-GigabitEthernet0/0/2]q

[SW2]int v  

[SW2]int Vlanif 10

[SW2-Vlanif10]ip add 192.168.10.100 24

[SW2-Vlanif10]un shu

Info: Interface Vlanif10 is not shutdown.

[SW2-Vlanif10]int Vlanif 20

[SW2-Vlanif20]ip add 192.168.20.100 24

[SW2-Vlanif20]un shu

Info: Interface Vlanif20 is not shutdown.

[SW2-Vlanif20]int v  

[SW2-Vlanif20]int vl  

[SW2-Vlanif20]int vl  

[SW2-Vlanif20]int vlanif 100

[SW2-Vlanif100]ip add 13.0.0.1 24

[SW2-Vlanif100]un shu

Info: Interface Vlanif100 is not shutdown.

[SW2-Vlanif100]q

[SW2]int v  

[SW2]int Vlanif 10

[SW2-Vlanif10]vrr  

[SW2-Vlanif10]vrrp v  

[SW2-Vlanif10]vrrp vrid 10 vi  

[SW2-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.1

[SW2-Vlanif10]vrr  

[SW2-Vlanif10]vrrp v  

[SW2-Vlanif10]vrrp vrid 10  

[SW2-Vlanif10]vrrp vrid 10 p  

[SW2-Vlanif10]vrrp vrid 10 pri  

[SW2-Vlanif10]vrrp vrid 10 priority 120

[SW2-Vlanif10]vrrp  

[SW2-Vlanif10]vrrp v  

[SW2-Vlanif10]vrrp vrid 10 pr  

[SW2-Vlanif10]vrrp vrid 10 pree  

[SW2-Vlanif10]vrrp vrid 10 preempt-mode ti  

[SW2-Vlanif10]vrrp vrid 10 preempt-mode timer de  

[SW2-Vlanif10]vrrp vrid 10 preempt-mode timer delay 3

[SW2-Vlanif10]vr  

[SW2-Vlanif10]vrrpv  

[SW2-Vlanif10]vrrp v  

[SW2-Vlanif10]vrrp vrid 10 t  

[SW2-Vlanif10]vrrp vrid 10 tr  

[SW2-Vlanif10]vrrp vrid 10 track int  

[SW2-Vlanif10]vrrp vrid 10 track interface g0/0/2 re  

[SW2-Vlanif10]vrrp vrid 10 track interface g0/0/2 reduced 30

[SW2-Vlanif10]q

[SW2]int vl  

[SW2]int Vlanif 20

[SW2-Vlanif20]vrr  

[SW2-Vlanif20]vrrp v  

[SW2-Vlanif20]vrrp vrid 20 vi  

[SW2-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.1

[SW2-Vlanif20]q

[SW2]q

<SW2>sa

The current configuration will be written to the device.

Are you sure to continue?[Y/N]y

Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:

Now saving the current configuration to the slot 0.

Save the configuration successfully.

<SW2>


SW3配置:

<Huawei>sys

Enter system view, return user view with Ctrl+Z.

[Huawei]un in en

Info: Information center is disabled.

[Huawei]us  

[Huawei]user-in  

[Huawei]user-interface con  

[Huawei]user-interface console 0

[Huawei-ui-console0]i  

[Huawei-ui-console0]idle-timeout 0 0

[Huawei-ui-console0]q

[Huawei]sys SW3

[SW3]int g0/0/1

[SW3-GigabitEthernet0/0/1]q

[SW3]v b 10 20 100

Info: This operation may take a few seconds. Please wait for a moment...done.

[SW3]int g0/0/1

[SW3-GigabitEthernet0/0/1]p l a

[SW3-GigabitEthernet0/0/1]p t a v a

                         ^

Error:Ambiguous command found at '^' position.

[SW3-GigabitEthernet0/0/1]p l t

[SW3-GigabitEthernet0/0/1]p t a v a

[SW3-GigabitEthernet0/0/1]int g0/0/2

[SW3-GigabitEthernet0/0/2]p l a

[SW3-GigabitEthernet0/0/2]p d v 100

[SW3-GigabitEthernet0/0/2]un shu

Info: Interface GigabitEthernet0/0/2 is not shutdown.

[SW3-GigabitEthernet0/0/2]q

[SW3]int v  

[SW3]int Vlanif 10

[SW3-Vlanif10]ip add 192.168.10.200 24

[SW3-Vlanif10]un shu

Info: Interface Vlanif10 is not shutdown.

[SW3-Vlanif10]int Vlanif 20

[SW3-Vlanif20]ip add 192.168.20.200 24

[SW3-Vlanif20]un shu

Info: Interface Vlanif20 is not shutdown.

[SW3-Vlanif20]int vlan  

[SW3-Vlanif20]int vlanif 100

[SW3-Vlanif100]ip add 23.0.0.1 24

[SW3-Vlanif100]un shu

Info: Interface Vlanif100 is not shutdown.

[SW3-Vlanif100]di in  br

PHY: Physical

*down: administratively down

(l): loopback

(s): spoofing

(b): BFD down

(e): ETHOAM down

(dl): DLDP down

(d): Dampening Suppressed

InUti/OutUti: input utility/output utility

Interface                   PHY   Protocol InUti OutUti   inErrors  outErrors

GigabitEthernet0/0/1        up    up          0%     0%          0          0

GigabitEthernet0/0/2        up    up          0%     0%          0          0

GigabitEthernet0/0/3        down  down        0%     0%          0          0

GigabitEthernet0/0/4        down  down        0%     0%          0          0

GigabitEthernet0/0/5        down  down        0%     0%          0          0

GigabitEthernet0/0/6        down  down        0%     0%          0          0

GigabitEthernet0/0/7        down  down        0%     0%          0          0

GigabitEthernet0/0/8        down  down        0%     0%          0          0

GigabitEthernet0/0/9        down  down        0%     0%          0          0

GigabitEthernet0/0/10       down  down        0%     0%          0          0

GigabitEthernet0/0/11       down  down        0%     0%          0          0

GigabitEthernet0/0/12       down  down        0%     0%          0          0

GigabitEthernet0/0/13       down  down        0%     0%          0          0

GigabitEthernet0/0/14       down  down        0%     0%          0          0

GigabitEthernet0/0/15       down  down        0%     0%          0          0

GigabitEthernet0/0/16       down  down        0%     0%          0          0

GigabitEthernet0/0/17       down  down        0%     0%          0          0

GigabitEthernet0/0/18       down  down        0%     0%          0          0

GigabitEthernet0/0/19       down  down        0%     0%          0          0

GigabitEthernet0/0/20       down  down        0%     0%          0          0

GigabitEthernet0/0/21       down  down        0%     0%          0          0

GigabitEthernet0/0/22       down  down        0%     0%          0          0

GigabitEthernet0/0/23       down  down        0%     0%          0          0

GigabitEthernet0/0/24       down  down        0%     0%          0          0

MEth0/0/1                   down  down        0%     0%          0          0

NULL0                       up    up(s)       0%     0%          0          0

Vlanif1                     up    down        --     --          0          0

Vlanif10                    up    up          --     --          0          0

Vlanif20                    up    up          --     --          0          0

Vlanif100                   up    up          --     --          0          0

[SW3-Vlanif100]q

[SW3]int v  

[SW3]int Vlanif 10

[SW3-Vlanif10]vrr  

[SW3-Vlanif10]vrrp v  

[SW3-Vlanif10]vrrp vrid 10 v  

[SW3-Vlanif10]vrrp vrid 10 virtual-ip 192.168.10.1

[SW3-Vlanif10]vr  

[SW3-Vlanif10]vrrp v  

[SW3-Vlanif10]vrrp vrid 10 p  

[SW3-Vlanif10]vrrp vrid 10 pri  

[SW3-Vlanif10]vrrp vrid 10 priority 115

[SW3-Vlanif10]q

[SW3]in  

[SW3]int  

[SW3]int vl  

[SW3]int Vlanif 20

[SW3-Vlanif20]vrr  

[SW3-Vlanif20]vrrp v  

[SW3-Vlanif20]vrrp vrid 20 v  

[SW3-Vlanif20]vrrp vrid 20 virtual-ip 192.168.20.1

[SW3-Vlanif20]v  

[SW3-Vlanif20]vrrp v  

[SW3-Vlanif20]vrrp vrid 20 pri  

[SW3-Vlanif20]vrrp vrid 20 priority 120

[SW3-Vlanif20]v  

[SW3-Vlanif20]vrrp v  

[SW3-Vlanif20]vrrp vrid 20 tr  

[SW3-Vlanif20]vrrp vrid 20 track in  

[SW3-Vlanif20]vrrp vrid 20 track interface g0/0/2 re  

[SW3-Vlanif20]vrrp vrid 20 track interface g0/0/2 reduced 30

[SW3-Vlanif20]q

[SW3]dis vr  

[SW3]dis vrrp

 Vlanif10 | Virtual Router 10

   State : Backup

   Virtual IP : 192.168.10.1

   Master IP : 192.168.10.100

   PriorityRun : 115

   PriorityConfig : 115

   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:32:11 UTC-08:00

   Last change time : 2021-10-19 15:32:11 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 : 0 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 : 30

   IF state : UP

   Create time : 2021-10-19 15:32:51 UTC-08:00

   Last change time : 2021-10-19 15:33:03 UTC-08:00


[SW3]q

<SW3>sa

The current configuration will be written to the device.

Are you sure to continue?[Y/N]y

Info: Please input the file name ( *.cfg, *.zip ) [vrpcfg.zip]:

Now saving the current configuration to the slot 0.

Save the configuration successfully.

<SW3>




------以上就vrrp与简单配置,谢谢!