VRRP概述和VRRP的实验配置
一.关于VRRP
VRRP概述
VRRP术语
Master / Backup路由器
VRRP报文
VRRP工作过程
抢占
二.VRRP配置实验
VRRP概述
. Virtual Router Redundancy Protocol,也即虚拟路由器冗余协议。
·利用VRRP,一组路由器(同一个LAN中的接口)协同工作,但只有一个处于Master状态,处于该状态的路由器(的接口)承担实际的数据流量转发任务。在一个VRRP组内的多个路由器接口共用一个虚拟IP地址,该地址被作为局域网内所有主机的缺省网关地址。
.VRRP决定哪个路由器是Master,Master路由器负责接收发送至用户网关的数据包并进行转发,以及响应PC对于其网关lP地址的ARP请求。
Backup路由器侦听Master路由器的状态,并在Master路由器发生故障时,接替其工作,从而保证业务流量的平滑切换。
VRRP术语
. VRRP路由器:
·运行VRRP的路由器。一台VRRP路由器(的接口)可以同时参与到多个VRRP组中,在不同的组中,一台VRRP路由器可以充当不同的角色。
. VRRP组:
·一个VRRP组由多个VRRP路由器组成,使用相同的VRID ( Virtual Router ID ,虚拟路由器ID)进行标识,属于同一VRRP组的VRRP路由器互相交换信息,每一个VRRP组中只能有一个Master。
·虚拟路由器∶
·对于每一个VRRP组,抽象出来的一个逻辑路由器,该路由器充当网络用户的网关,该路由器并非真实存在,事实上对于用户而言,只需知道虚拟路由器的IP,至于具体的虚拟路由器的角色由谁来承担、数据转发任务由谁来承担、Master故障后谁来接替,这是VRRP的工作。
·虚拟IP地址、MAC地址:
·虚拟IP地址就是虚拟路由器的IP地址,该地址实际上就是用户的网关地t·虚拟MAC地址是虚拟路由器根据VRID生成的MAC地址。一个虚拟路由器拥有一个虚拟MAC地址,格式为:0O-00-5E-OO-O1-[VRID}。
· Master、Backup路由器:
. Master路由器︰在VRRP组中实际转发数据包的路由器,在每一个VRRP组中,仅有Master响应对虚拟IP地址的ARP请求。Master路由器同时以一定的时间间隔发送VRRP消息,以便通知Backup路由器自己的存活情况。
. Backup路由器:处于监听状态的路由器,一旦Master路由器出现故障,Backup路由器就开始接替工作。
·选举依据︰先比较接口VRRP优先级(比大),如果相等,则比较接口IP地址(比大)。
Master / Backup路由器
. Backup路由器︰
。接收Master设备发送的VRRP通告报文,判断Master设备的状态是否正常。十·对虚拟IP地址的ARP请求,不做响应。
·丢弃目的IP地址为虚拟IP地址的IP报文。
·如果收到优先级和自己相同或者比自己大的报文,则重置Master_Down_Interval定时器,不进一步比较IP地址。
·如果收到比自己优先级小的报文且该报文优先级是0时,定时器时间设置为Skew_time(偏移时间)),如果该报文优先级不是0,丢弃报文,立刻成为Master。
Master_Down_Interval定时器:Backup设备在该定时器超时后仍未收到通告报文,则会转换为Master状态。计算公式如下:Master_Down_Interval=(3*
VRRP报文
VRRP工作过程
抢占
二.实验题
实验一:
实验思路:再SW1和SW2配置VLAN10和VLAN20的虚接口,再配置VRRP,接口使用trunk模式,LSW3跟PC相连的接口用access模式
对SW1的配置
[w1]undo info-center enable
Info: Information center is disabled.
[w1]int vlan10
Error: The VLAN does not exist.
[w1]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[w1]int vlan 10
[w1-Vlanif10]ip address 192.168.1.10 24
[w1-Vlanif10]int vlan 20
[w1-Vlanif20]ip address 192.168.2.10 24
[w1-Vlanif20]vrrp vrid virtual-ip 192.168.2.254
^
Error: Wrong parameter found at '^' position.
[w1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.2.254
[w1-Vlanif20]int vlan 10
[w1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.1.254
[w1-Vlanif10]vrrp vrid 1 priority 110
[w1-Vlanif10]int g0/0/1
[w1-GigabitEthernet0/0/1]port link-type trunk
[w1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[w1-GigabitEthernet0/0/1]
SW2的配置
[W2]UNDO INFO-CENTER ENABLE
Info: Information center is disabled.
[W2]VLAN BATCH 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[W2]
[W2]int vlan 10
[W2-Vlanif10]ip address 192.168.1.11 24
[W2-Vlanif10]int vlan 20
[W2-Vlanif20]ip address 192.168.2.11 24
[W2-Vlanif20]vrrp vrid virtual-ip 192.168.2.254
^
Error: Wrong parameter found at '^' position.
[W2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.2.254
[W2-Vlanif20]vrrp vrid 2 pri
[W2-Vlanif20]vrrp vrid 2 priority 110
[W2-Vlanif20]int vlan 10
[W2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.
^
Error: Wrong parameter found at '^' position.
[W2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.1.254
[W2-Vlanif10]int g0/0/1
[W2-GigabitEthernet0/0/1]port link-type trunk
[W2-GigabitEthernet0/0/1]port trunk allow-pass all
SW3的配置
[W3]undo info-center enable
Info: Information center is disabled.
[W3]int g0/0/1
[W3-GigabitEthernet0/0/1]p l t
[W3-GigabitEthernet0/0/1]p t a v a
[W3-GigabitEthernet0/0/1]int g0/0/2
[W3-GigabitEthernet0/0/2] p l a
[W3-GigabitEthernet0/0/2]p t a v a
^
Error:Ambiguous command found at '^' position.
[W3-GigabitEthernet0/0/2]p t a v t
^
Error:Ambiguous command found at '^' position.
[W3-GigabitEthernet0/0/2]undo p l a
^
Error:Ambiguous command found at '^' position.
[W3-GigabitEthernet0/0/2]undo port link-type access
^
Error:Too many parameters found at '^' position.
[W3-GigabitEthernet0/0/2]undo port link-type
[W3-GigabitEthernet0/0/2]p l t
[W3-GigabitEthernet0/0/2]p t a v a
[W3-GigabitEthernet0/0/2]int g0/0/3
[W3-GigabitEthernet0/0/3]p l a
[W3-GigabitEthernet0/0/3]p d a v 10
^
Error:Ambiguous command found at '^' position.
[W3-GigabitEthernet0/0/3]p d v 10
Error: The VLAN does not exist.
[W3-GigabitEthernet0/0/3]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[W3]int g0/0/3
[W3-GigabitEthernet0/0/3]p l a
[W3-GigabitEthernet0/0/3]p d v 10
[W3-GigabitEthernet0/0/3]int g0/0/4
[W3-GigabitEthernet0/0/4]p l a
[W3-GigabitEthernet0/0/4]p d v 20
连接
断掉SW1的g0/0/1接口
[w1]int g0/0/1
[w1-GigabitEthernet0/0/1]shutdown
[w1-GigabitEthernet0/0/1]DIS VRRP BRIEF
依然可以实现连接,如下图所示:
实验二:
实验分析:此题是不同网段之间的通信,再配置子接口的时候需要再R1和R2对应接口配置vid,使用vrrp协议再虚拟路由器对应接口设置优先级设置主从关系,再其他链路段的时候依然可以通信
R1配置如下:
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]vlan batch 10 20
[Huawei]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]ip address 192.168.1.10 24
[Huawei-GigabitEthernet0/0/0.1]int g0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]ip address 192.168.1.10
[Huawei-GigabitEthernet0/0/1]ip address 192.168.10.1 24
[Huawei-GigabitEthernet0/0/0.2]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]vrrp vrid 1 virtual-ip 192.168.1.254
[Huawei-GigabitEthernet0/0/0.1]vrrp vrid 1 pri
[Huawei-GigabitEthernet0/0/0.1]vrrp vrid 1 priority 110
[Huawei-GigabitEthernet0/0/0.1]a
[Huawei-GigabitEthernet0/0/0.1]dot1q ter
[Huawei-GigabitEthernet0/0/0.1]dot1q termination vid 10
[Huawei-GigabitEthernet0/0/0.1]arp ba
[Huawei-GigabitEthernet0/0/0.1]arp b
[Huawei-GigabitEthernet0/0/0.1]arp broadcast enable
[Huawei]ip route-static 3.3.3.3 32 192.168.10.2
R2配置如下:
<Huawei>sys
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]UNDO Info-center enable
Info: Information center is disabled.
[Huawei]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]ip address 192.168.1.11 24
[Huawei-GigabitEthernet0/0/0.1]int g0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]ip address 192.168.2.11 24
[Huawei]int g0/0/0.1
[Huawei-GigabitEthernet0/0/0.1]vrrp vrid viratual-ip 192.168.1.254
[Huawei-GigabitEthernet0/0/0.1]vrrp vrid 1 viratual-ip 192.168.1.254
[Huawei-GigabitEthernet0/0/0.1]vrrp vrid 1 virtual-ip 192.168.1.254
[Huawei-GigabitEthernet0/0/0.1]dot1q termination vid 10
[Huawei-GigabitEthernet0/0/0.1]arp broadcast enable
[Huawei-GigabitEthernet0/0/0.1]int g0/0/0.2
[Huawei-GigabitEthernet0/0/0.2]vrrp vrid 2 virtual-ip 192.168.2.254
[Huawei-GigabitEthernet0/0/0.2]vrrp vrid 2 priority 110
[Huawei-GigabitEthernet0/0/0.2]dot1q termination vid 20
[Huawei-GigabitEthernet0/0/0.2]arp broadcast enable
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.20.1 24
[Huawei]ip route-static 3.3.3.3 32 192.168.20.2
SW1配置如下:
Huawei>
sys
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]vlan batch 10 20
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]port link-type access
[Huawei-Ethernet0/0/1]port default vlan 10
[Huawei-Ethernet0/0/1]int e0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 20
[Huawei-Ethernet0/0/2]int e0/0/3
[Huawei-Ethernet0/0/3]p l t
[Huawei-Ethernet0/0/3]p t a v a
[Huawei-Ethernet0/0/3]int e0/0/4
[Huawei-Ethernet0/0/4]p l t
[Huawei-Ethernet0/0/4]p l a v a
R3配置如下
he device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center e
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.10.2 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 192.168.20.2 24
[Huawei-GigabitEthernet0/0/1]int loopback 0
[Huawei-LoopBack0]ip address 3.3.3.3 32
[Huawei-LoopBack0]Q
[Huawei]ip route-static 192.168.1.0 24 192.168.10.1
[Huawei]ip route-static 192.168.2.0 24 192.168.20.1
连接
将R1的接口shutdown 此时在R3再配置一条路由即可通信
R1
[Huawei-GigabitEthernet0/0/0]undo shutdown
R3
[Huawei]ip route-static 192.168.1.0 24 192.168.20.1
连接
实验三.
W1的配置
<Huawei>
<Huawei>sys
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname W1
[W1]
Apr 12 2021 22:24:20-08:00 W1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.
191.3.1 configurations have been changed. The current change number is 4, the ch
ange loop count is 0, and the maximum number of records is 4095..
[W1]undo info-center enable
Info: Information center is disabled.
[W1]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[W1]stp region-configuration
[W1-mst-region]region-name WW
[W1-mst-region]instance 1 vlan 10
[W1-mst-region]instance 2 vlan 20
[W1-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[W1-mst-region]q
[W1]stp instance 1 root primary
[W1]stp instance 2 root secondary
[W1]int g0/0/1
[W1-GigabitEthernet0/0/1]p l t
[W1-GigabitEthernet0/0/1]p t a v a
[W1-GigabitEthernet0/0/2]p l t
[W1-GigabitEthernet0/0/2]p t a v a
[W1-GigabitEthernet0/0/2]int vlan10
[W1-Vlanif10]ip address 192.168.1.10 24
[W1-Vlanif10]int vlan 20
[W1-Vlanif20]ip add
[W1-Vlanif20]ip address 192.168.2.10
[W1-Vlanif20]INT VLAN 10
[W1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.1.254
[W1-Vlanif10]vrrp vri 1 priority 110
[W1-Vlanif10]int vlan 20
[W1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.2.254
SW2的配置
he device is running!
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname W2
[W2]undo info-center enable
Info: Information center is disabled.
[W2]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[W2]stp region-configuration
[W2-mst-region]region-name WW
[W2-mst-region]instance 1 vlan 10
[W2-mst-region]instance 2 vlan 20
[W2-mst-region]active region-configuration
Info: This operation may take a few seconds. Please wait for a moment...done.
[W2-mst-region]q
[W2]stp instance 2 root primary
[W2]stp instance 1 root secondary
[W2]int g0/0/1
[W2-GigabitEthernet0/0/1]p l t
[W2-GigabitEthernet0/0/1]p l a v a
[W2-GigabitEthernet0/0/1]int g0/0/2
[W2-GigabitEthernet0/0/2]p l t
[W2-GigabitEthernet0/0/2]p t a v a
[W2-GigabitEthernet0/0/2]int vlan 10
[W2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.1.254
[W2-Vlanif10]int vlan 20
[W2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.2.254
[W2-Vlanif20]vrrp vrid 2 priority 110
[W2-Vlanif20]int vlan 10 ^
[W2-Vlanif10]ip address 192.168.1.11 24
[W2-Vlanif10]int vlan 20
[W2-Vlanif20]ip address 192.168.2.11 24
SW3的配置
awei>sys
Enter system view, return user view with Ctrl+Z.
[ww]sysname w3
[w3]undo info-center enable
Info: Information center is disabled.
[w3]VLAN BATCH 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[w3]STP region-configuration
[w3-mst-region]region-name WW
[w3-mst-region]INSTANCE 1 VLAN 10
[w3-mst-region]INSTANCE 2 VLAN 20
[w3-mst-region]ACTIVE REGION-CONFIGURATION
Info: This operation may take a few seconds. Please wait for a moment...done.
[w3-mst-region]Q
[w3]INT G0/0/1
[w3-GigabitEthernet0/0/1]P L T
[w3-GigabitEthernet0/0/1]P T A V A
[w3-GigabitEthernet0/0/1]int g0/0/2
[w3-GigabitEthernet0/0/2]p l t
[w3-GigabitEthernet0/0/2]p t a v a
[w3-GigabitEthernet0/0/2]int g0/0/3
[w3-GigabitEthernet0/0/3]p l a
[w3-GigabitEthernet0/0/3]p d v 10
[w3-GigabitEthernet0/0/3]int g0/0/4
[w3-GigabitEthernet0/0/4]p l a
[w3-GigabitEthernet0/0/4]p d v 20
连接: