第十二集 VRRP

熟悉VRRP的工作原理

掌握VRRP的基本配置

VRRP术语## 实验

《 熟悉VRRP的工作原理》:
【1】路由器开启 VRRP功能后,会根据优先级确定自己在备份组中的角色。优先级高的路由器成为主用路由器,优先级低的成为备用路由器。主用路由器定期发送 VRRP通告报文,通知备份组内的其他路由器自己工作正常;备用路由器则启动定时器等待通告报文的到来。
【2】VRRP在不同的主用抢占方式下,主用角色的替换方式不同:
在抢占方式下,当主用路由器收到 VRRP通告报文后,会将自己的优先级与通告报文中的优先级进行比较。如果大于通告报文中的优先级, 则成为主用路由器; 否则将保持备用状态。
在非抢占方式下,只要主用路由器没有出现故障,备份组中的路由器始终保持主用或备用状态,备份组中的路由器即使随后被配置了更高的优先级也不会成为主用路由器。

2.概念:VRRP是一种路由容错协议,也可以叫做备份路由协议,可以把一个虚拟路由器的责任动态分配到局域网上的 VRRP 路由器中的一台。
控制虚拟路由器 IP 地址的 VRRP 路由器称为主路由器, 它负责转发数据包到这些虚拟 IP地址。
当缺省路由器down掉(即端口关闭)之后,内部主机将无法与外部通信,如果路由器设置了VRRP时,那么这时,虚拟路由将启用备份路由器,从而实现全网通信。

《掌握VRRP的基本配置》:
必须在网关接口上运行,两边的配置命令必须完全相同,除了优先级的配置。

《VRRP术语》:
【1】 虚拟路由器:由一个Master路由器和多个Backup路由器组成。主机将虚拟路由器当作默认网关。
【2】 VRID:虚拟路由器的标识。有相同VRID的一组路由器构成一个虚拟路由器。
【3】Master路由器:虚拟路由器中承担报文转发任务的路由器。
【4】 Backup路由器:Master路由器出现故障时,能够代替Master路由器工作的路由器。
【5】虚拟IP地址:虚拟路由器的IP地址。一个虚拟路由器可以拥有一个或多个IP地址。
【6】IP地址拥有者:接口IP地址与虚拟IP地址相同的路由器被称为IP地址拥有者。
【7】虚拟MAC地址:一个虚拟路由器拥有一个虚拟MAC地址。虚拟MAC地址的格式为00-00-5E-00-01-{VRID}。通常情况下,虚拟路由器回应ARP请求使用的是虚拟【8】MAC地址,只有虚拟路由器做特殊配置的时候,才回应接口的真实MAC地址。
【9】优先级:VRRP根据优先级来确定虚拟路由器中每台路由器的地位。
(默认值:100) 可配置的范围(0-255)
实际范围(1-254)
【10】非抢占方式:如果Backup路由器工作在非抢占方式下,则只要Master路由器没有出现故障,Backup路由器即使随后被配置了更高的优先级也不会成为Master路由器。
【11】抢占方式:如果Backup路由器工作在抢占方式下,当它收到VRRP报文后,会将自己的优先级与通告报文中的优先级进行比较。如果自己的优先级比当前的Master路由器的优先级高,就会主动抢占成为Master路由器;否则,将保持Backup状态。(默认抢占0秒)

《实验一》:
实验要求:交换机配置mstp+vrrp,sw1作为vlan10的主,vlan20的备,sw2相反,使得pc1和pc2可以互通

<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys RSW3
[RSW3]undo info-center en
Info: Information center is disabled.
[RSW3]vlan b 10 20
[RSW3]in g0/0/1
[RSW3-GigabitEthernet0/0/1]p l a 
[RSW3-GigabitEthernet0/0/1]p d v 10
[RSW3-GigabitEthernet0/0/1]in g0/0/2
[RSW3-GigabitEthernet0/0/2]p l a
[RSW3-GigabitEthernet0/0/2]p d v 20
[RSW3-GigabitEthernet0/0/2]in g0/0/3
[RSW3-GigabitEthernet0/0/3]p l t
[RSW3-GigabitEthernet0/0/3]p t a v a
[RSW3-GigabitEthernet0/0/3]in g0/0/4
[RSW3-GigabitEthernet0/0/4]p l t
[RSW3-GigabitEthernet0/0/4]p t a v a
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys RSW2
[RSW2]undo info-center en 
Info: Information center is disabled.
[RSW2]vlan b 10 20
[RSW2]in vlanif 10
[RSW2-Vlanif10]ip add 192.168.1.253 24
[RSW2-Vlanif10]vrrp vrid 1 vir 
[RSW2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.1.254
[RSW2-Vlanif10]in vlan 20
[RSW2-Vlanif20]ip add 192.168.2.252 24
[RSW2-Vlanif20]vrrp vrid 2 vr 
[RSW2-Vlanif20]vrrp vrid 2 vi 
[RSW2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.2.254
[RSW2-Vlanif20]vrrp vrid 2 pri 
[RSW2-Vlanif20]vrrp vrid 2 priority 110
[RSW2]stp region-configuration 
[RSW2-mst-region]re 
[RSW2-mst-region]region-name max
[RSW2-mst-region]ins 
[RSW2-mst-region]instance 1 vlan 10
[RSW2-mst-region]instance 2 vlan 20
[RSW2-mst-region]ac 
[RSW2-mst-region]active re 
[RSW2-mst-region]active region-configuration 
[RSW2]stp in 
[RSW2]stp instance 1 roo 
[RSW2]stp instance 1 root se
[RSW2]stp in 
[RSW2]stp instance 2 r 
[RSW2]stp instance 2 root p
[RSW2]in g0/0/2
[RSW2-GigabitEthernet0/0/2]p l t
[RSW2-GigabitEthernet0/0/2]p t a v a
[RSW2-GigabitEthernet0/0/2]in g0/0/1
[RSW2-GigabitEthernet0/0/1]p l t
[RSW2-GigabitEthernet0/0/1]p t a v a
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys RSW1
[RSW1]undo info-center en
[RSW1]vlan b 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[RSW1]in vlanif 10
[RSW1-Vlanif10]ip add 192.168.1.252 24
[RSW1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.1.254
[RSW1-Vlanif10]vrrp vrid 1 priority 110
[RSW1-Vlanif10]in vlanif 20
[RSW1-Vlanif20]ip add 192.168.2.253 24 
[RSW1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.2.254
[RSW1]stp region-configuration 
[RSW1-mst-region]region-name max
[RSW1-mst-region]ins 
[RSW1-mst-region]instance 1 vlan 10 
[RSW1-mst-region]instance 2 vlan 20
[RSW1-mst-region]active region-configuration 
Info: This operation may take a few seconds. Please wait for a moment...done.
[[RSW1-mst-region]q
RSW1]stp instance 1 root primary 
RSW1]stp instance 2 root secondary 
[RSW1]in g0/0/1
[RSW1-GigabitEthernet0/0/1]p l t 
[RSW1-GigabitEthernet0/0/1]p t a v a
[RSW1-GigabitEthernet0/0/1]in g0/0/2
[RSW1-GigabitEthernet0/0/2]p l t
[RSW1-GigabitEthernet0/0/2]p t a v a


注意:交换机g0/0/3和g0/0/4的端口需要truck

《实验二》:

实验要求:sw1和sw2配置vrrp,sw1作为vlan10的主,vlan20的备,sw2相反,使得pc1和pc2都可以ping通各自的网关,测试断掉一条线路不影响结果

<Huawei>
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]undo in 
[Huawei]undo info-center en 
Info: Information center is disabled.
[Huawei]sysname RSW1
[RSW1]vlan b 10 20
[RSW1]in g0/0/1
[RSW1-GigabitEthernet0/0/1]p l t
[RSW1-GigabitEthernet0/0/1]p t a v a
[RSW1-GigabitEthernet0/0/1]in vlanif 10
[RSW1-Vlanif10]ip add 192.168.1.252 24
[RSW1-Vlanif10]vrrp vrid 1 vir 
[RSW1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.1.254
[RSW1-Vlanif10]vrrp vrid 1 p 
[RSW1-Vlanif10]vrrp vrid 1 pr 
[RSW1-Vlanif10]vrrp vrid 1 priority 110
[RSW1-Vlanif10]in vlanif 20
[RSW1-Vlanif20]ip add 192.168.2.253
                                    ^
Error:Incomplete command found at '^' position.
[RSW1-Vlanif20]ip add 192.168.2.253 24
[RSW1-Vlanif20]vrrp vrid 2 v 
[RSW1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.2.254
[RSW1]dis vrrp b
VRID  State        Interface                Type     Virtual IP     
----------------------------------------------------------------
1     Master       Vlanif10                 Normal   192.168.1.254  
2     Master       Vlanif20                 Normal   192.168.2.254  
----------------------------------------------------------------
Total:2     Master:2     Backup:0     Non-active:0     
<Huawei>sys 
Enter system view, return user view with Ctrl+Z.
[Huawei]sys RSW2
[RSW2]undo in 
[RSW2]undo info-center 
[W2]vlan b 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[RSW2]in g0/0/1
[RSW2-GigabitEthernet0/0/1]p l t
[RSW2-GigabitEthernet0/0/1]p t a v a
[RSW2-GigabitEthernet0/0/1]q
[RSW2]in vlanif 10
[RSW2-Vlanif10]ip add 192.168.1.253 24
[RSW2-Vlanif10]vrrp vrid 1 v 
[RSW2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.1.254
[RSW2-Vlanif10]in vlanif 20
[RSW2-Vlanif20]ip add 192.168.2.252 24
[RSW2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.2.254
[RSW2-Vlanif20]vrrp vrid 2 priority 110
[RSW2-Vlanif20]dis vrrp b
VRID  State        Interface                Type     Virtual IP     
----------------------------------------------------------------
1     Master       Vlanif10                 Normal   192.168.1.254  
2     Master       Vlanif20                 Normal   192.168.2.254  
----------------------------------------------------------------
Total:2     Master:2     Backup:0     Non-active:0     
<Huawei>sys
[Huawei]sys RSW3
[RSW3]vlan b 10 20
[RSW3]in g0/0/1
[RSW3-GigabitEthernet0/0/1]p l t
[RSW3-GigabitEthernet0/0/1]p t a v a
[RSW3-GigabitEthernet0/0/1]in g0/0/2
[RSW3-GigabitEthernet0/0/2]p l t
[RSW3-GigabitEthernet0/0/2]p t a v a
[RSW3-GigabitEthernet0/0/2]in g0/0/3
[RSW3-GigabitEthernet0/0/3]p l a
[RSW3-GigabitEthernet0/0/3]p d v 10
[RSW3-GigabitEthernet0/0/3]in g0/0/4
[RSW3-GigabitEthernet0/0/4]p l a
[RSW3-GigabitEthernet0/0/4]p d v 20

当RSW3配置完成后我们看State的变化

[RSW1]dis vrrp b
VRID  State        Interface                Type     Virtual IP     
----------------------------------------------------------------
1     Master       Vlanif10                 Normal   192.168.1.254  
2     Backup       Vlanif20                 Normal   192.168.2.254  
----------------------------------------------------------------
Total:2     Master:1     Backup:1     Non-active:0     
[RSW2-Vlanif20]dis vrrp b
VRID  State        Interface                Type     Virtual IP     
----------------------------------------------------------------
1     Backup       Vlanif10                 Normal   192.168.1.254  
2     Master       Vlanif20                 Normal   192.168.2.254  
----------------------------------------------------------------
Total:2     Master:1     Backup:1     Non-active:0     



《实验三》


实验要求:R1和R2上的g0/0/0配置子接口使得pc1和pc2能ping通3.3.3.3

sys R1
[R1]vlan b 10 20
[R1]undo info-center en 
[R1]in g0/0/0.1
[R1-GigabitEthernet0/0/0.1]ip add 192.168.1.252 24
[R1-GigabitEthernet0/0/0.1]do 
[R1-GigabitEthernet0/0/0.1]dot1q ter 
[R1-GigabitEthernet0/0/0.1]dot1q termination v 
[R1-GigabitEthernet0/0/0.1]dot1q termination vid 10
[R1-GigabitEthernet0/0/0.1]vrrp vrid 1 virtual-ip 192.168.1.254
[R1-GigabitEthernet0/0/0.1]vrrp vrid 1 priority 110
[R1-GigabitEthernet0/0/0.1]in g0/0/0.2
[R1-GigabitEthernet0/0/0.2]ip add 192.168.2.253 24
[R1-GigabitEthernet0/0/0.2]d t v 20
[R1-GigabitEthernet0/0/0.2]a b e
[R1-GigabitEthernet0/0/0.2]vrrp vrid 2 virtual-ip 192.168.2.254
[R1-GigabitEthernet0/0/0.2]in g0/0/1
[R1-GigabitEthernet0/0/1]ip add 192.168.10.2 24
[R1]ip route-static 3.3.3.3 24 192.168.10.1
 view, return user view with Ctrl+Z.
[Huawei]sys R2
[R2]in g0/0/0
[R2-GigabitEthernet0/0/0]in g0/0/0.1
[R2-GigabitEthernet0/0/0.1]ip add 192.168.1.253 24
[R2-GigabitEthernet0/0/0.1]d t v 10
[R2-GigabitEthernet0/0/0.1]a b e
[R2-GigabitEthernet0/0/0.1]vrrp vrid 1 vir 
[R2-GigabitEthernet0/0/0.1]vrrp vrid 1 virtual-ip 192.168.1.254
[R2-GigabitEthernet0/0/0.1]in g0/0/0.2
[R2-GigabitEthernet0/0/0.2]ip add 192.168.2.252 24
[R2-GigabitEthernet0/0/0.2]d t v 20
[R2-GigabitEthernet0/0/0.2]a b e
[R2-GigabitEthernet0/0/0.2]vrrp vrid 2 vir 
[R2-GigabitEthernet0/0/0.2]vrrp vrid 2 virtual-ip 192.168.2.254
[R2-GigabitEthernet0/0/0.2]vrrp vrid 2 pri 
[R2-GigabitEthernet0/0/0.2]vrrp vrid 2 priority 110
[R2-GigabitEthernet0/0/0.2]in g0/0/1
[R2-GigabitEthernet0/0/1]ip add 192.168.20.2 24
[R2]ip route-static 3.3.3.3 24 192.168.20.1
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R3
[R3]in g0/0/1
[R3-GigabitEthernet0/0/1]ip add 192.168.20.1 24
[R3-GigabitEthernet0/0/1]in g0/0/0
[R3-GigabitEthernet0/0/0]ip add 192.168.10.1 24
[R3]in loopb 0
[R3-LoopBack0]ip add 3.3.3.3 32
[R3]ip route-s 192.168.1.0 24 192.168.10.2
[R3]ip route-s 192.168.1.0 24 192.168.20.2
[R3]ip route-s 192.168.2.0 24 192.168.20.2
[R3]ip route-s 192.168.2.0 24 192.168.10.2



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值