目录
一、VRRP的作用
出口网关的备份,保证出口网关的高可用性。
二、VRRP的好处
1. 主路由器失效后,备份路由器立即顶替主路由器的工作,保证数据的不丢失。
2.两个不同的路由器成为不同组的主路由器,相互备份。
3.跟踪上行链路接口状态,当上行链路接口失效时,自动将备份路由份提升为主路
由器,保证数据的不丢失。
三、工作原理
通过在冗余网关间共享虚拟MAC和IP地址,保证数据转发时并不是转给某一个具体网关的IP,而是把数据转发给虚拟网关的IP,因此,不论哪一个路由器成为主路由,都不会影响数据通信。通过组播协议对数据端口进行监控,一旦检测数据转发的端口坏掉,主路由器会停发HELLO包,备路由器提升为主路由,实现数据的稳定高效转发。
在VRRP协议中,有两组重要的概念:VRRP路由器和虚拟路由器,主控路由器和备份路由器。VRRP路由器是指运行VRRP的路由器,是物理实体;虚拟路由器是指VRRP协议创建的,是逻辑概念。一组VRRP路由器协同工作,共同构成一台虚拟路由器。该虚拟路由器对外表现为一个具有唯一固定的IP地址和MAC地址的逻辑路由器。处于同一个VRRP组中的路由器具有两种互斥的角色:主控路由器和备份路由器,一个VRRP组中有且只有一台处于主控角色的路由器,可以有一个或者多个处于备份角色的路由器VRRP协议从路由器组中选出一台作为主控路由器,负责ARP解析和转发IP数据包,组中的其他路由器作为备份的角色并处于待命状态,当由于某种原因主控路由器发生故障时,其中的一台备份路由器能在瞬间的时延后升级为主控路由器,由于此切换非常迅速而且不用改变IP地址和MAC地址,故对终端使用者系统是透明的。
四、配置步骤及命令
L2-SW1
[L2-SW1]vlan ba
[L2-SW1]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[L2-SW1]int e0/0/1
[L2-SW1-Ethernet0/0/1]po
[L2-SW1-Ethernet0/0/1]port lin
[L2-SW1-Ethernet0/0/1]port link-t
[L2-SW1-Ethernet0/0/1]port link-type acc
[L2-SW1-Ethernet0/0/1]port link-type access
[L2-SW1-Ethernet0/0/1]po
[L2-SW1-Ethernet0/0/1]port de
[L2-SW1-Ethernet0/0/1]port default v
[L2-SW1-Ethernet0/0/1]port default vlan 10
[L2-SW1-Ethernet0/0/1]int e0/0/2
[L2-SW1-Ethernet0/0/2]po
[L2-SW1-Ethernet0/0/2]port li
[L2-SW1-Ethernet0/0/2]port link-t
[L2-SW1-Ethernet0/0/2]port link-type ac
[L2-SW1-Ethernet0/0/2]port link-type access
[L2-SW1-Ethernet0/0/2]po
[L2-SW1-Ethernet0/0/2]port de
[L2-SW1-Ethernet0/0/2]port default v
[L2-SW1-Ethernet0/0/2]port default vlan 20
[L2-SW1-Ethernet0/0/2]int g0/0/1
[L2-SW1-GigabitEthernet0/0/1]po
[L2-SW1-GigabitEthernet0/0/1]port lin
[L2-SW1-GigabitEthernet0/0/1]port link-t
[L2-SW1-GigabitEthernet0/0/1]port link-type tr
[L2-SW1-GigabitEthernet0/0/1]port link-type trunk
[L2-SW1-GigabitEthernet0/0/1]po
[L2-SW1-GigabitEthernet0/0/1]port tr
[L2-SW1-GigabitEthernet0/0/1]port trunk al
[L2-SW1-GigabitEthernet0/0/1]port trunk allow-pass all
^
Error: Unrecognized command found at '^' position.
[L2-SW1-GigabitEthernet0/0/1]po
[L2-SW1-GigabitEthernet0/0/1]port tr
[L2-SW1-GigabitEthernet0/0/1]port trunk al
[L2-SW1-GigabitEthernet0/0/1]port trunk allow-pass vl
[L2-SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[L2-SW1-GigabitEthernet0/0/1]int g0/0/2
[L2-SW1-GigabitEthernet0/0/2]po
[L2-SW1-GigabitEthernet0/0/2]port li
[L2-SW1-GigabitEthernet0/0/2]port link-t
[L2-SW1-GigabitEthernet0/0/2]port link-type tr
[L2-SW1-GigabitEthernet0/0/2]port link-type trunk
[L2-SW1-GigabitEthernet0/0/2]po
[L2-SW1-GigabitEthernet0/0/2]port tr
[L2-SW1-GigabitEthernet0/0/2]port trunk a
[L2-SW1-GigabitEthernet0/0/2]port trunk allow-pass v
[L2-SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan a
[L2-SW1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[L2-SW1-GigabitEthernet0/0/2]q
[L2-SW1]
L3-SW1
[L3-SW1]int g0/0/1
[L3-SW1-GigabitEthernet0/0/1]po
[L3-SW1-GigabitEthernet0/0/1]port li
[L3-SW1-GigabitEthernet0/0/1]port link-t
[L3-SW1-GigabitEthernet0/0/1]port link-type tr
[L3-SW1-GigabitEthernet0/0/1]port link-type trunk
[L3-SW1-GigabitEthernet0/0/1]po
[L3-SW1-GigabitEthernet0/0/1]port tr
[L3-SW1-GigabitEthernet0/0/1]port trunk a
[L3-SW1-GigabitEthernet0/0/1]port trunk allow-pass v
[L3-SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan a
[L3-SW1-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[L3-SW1-GigabitEthernet0/0/1]q
[L3-SW1]vlan ba
[L3-SW1]vlan batch 10 20 100
Info: This operation may take a few seconds. Please wait for a moment...done.
[L3-SW1]int vlan 10
[L3-SW1-Vlanif10]ip add
[L3-SW1-Vlanif10]ip address 192.168.10.10 24
[L3-SW1-Vlanif10]vrr
[L3-SW1-Vlanif10]vrrp vri
[L3-SW1-Vlanif10]vrrp vrid 1virt
[L3-SW1-Vlanif10]vrrp vrid virt
[L3-SW1-Vlanif10]vrrp vrid virtua
[L3-SW1-Vlanif10]vrrp vrid virtual-i
[L3-SW1-Vlanif10]vrrp vrid virtual-ip 192.168.10.1
^
Error: Wrong parameter found at '^' position.
[L3-SW1-Vlanif10]vrr
[L3-SW1-Vlanif10]vrrp vr
[L3-SW1-Vlanif10]vrrp vrid 1 vi
[L3-SW1-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1
[L3-SW1-Vlanif10]vrr
[L3-SW1-Vlanif10]vrrp vr
[L3-SW1-Vlanif10]vrrp vrid 1 prio
[L3-SW1-Vlanif10]vrrp vrid 1 priority 105
[L3-SW1-Vlanif10]vrr
[L3-SW1-Vlanif10]vrrp vr
[L3-SW1-Vlanif10]vrrp vrid 1tra
[L3-SW1-Vlanif10]vrrp vrid 1 tr
[L3-SW1-Vlanif10]vrrp vrid 1 track in
[L3-SW1-Vlanif10]vrrp vrid 1 track interface g0/0/2
[L3-SW1-Vlanif10]int vlan 20
[L3-SW1-Vlanif20]ip ad
[L3-SW1-Vlanif20]ip address 192.168.20.10 24
[L3-SW1-Vlanif20]vrr
[L3-SW1-Vlanif20]vrrp v
[L3-SW1-Vlanif20]vrrp vrid 2 vi
[L3-SW1-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.1
[L3-SW1-Vlanif20]v
[L3-SW1-Vlanif20]vrrp v
[L3-SW1-Vlanif20]vrrp vrid 2 tr
[L3-SW1-Vlanif20]vrrp vrid 2 track in
[L3-SW1-Vlanif20]vrrp vrid 2 track interface g0/0/2
[L3-SW1-Vlanif20]q
[L3-SW1]int g0/0/2
[L3-SW1-GigabitEthernet0/0/2]po
[L3-SW1-GigabitEthernet0/0/2]port li
[L3-SW1-GigabitEthernet0/0/2]port link-t
[L3-SW1-GigabitEthernet0/0/2]port link-type ac
[L3-SW1-GigabitEthernet0/0/2]port link-type access
[L3-SW1-GigabitEthernet0/0/2]po
[L3-SW1-GigabitEthernet0/0/2]port de
[L3-SW1-GigabitEthernet0/0/2]port default v
[L3-SW1-GigabitEthernet0/0/2]port default vlan 100
[L3-SW1-GigabitEthernet0/0/2]q
[L3-SW1]int vlan 100
[L3-SW1-Vlanif100]ip add
[L3-SW1-Vlanif100]ip address 10.10.10.1 24
[L3-SW1-Vlanif100]q
[L3-SW1]ip rou
[L3-SW1]ip route-st
[L3-SW1]ip route-static 1.1.1.1 32 10.10.10.11
L3-SW2
[L3-SW2]int g0/0/1
[L3-SW2-GigabitEthernet0/0/1]po
[L3-SW2-GigabitEthernet0/0/1]port lin
[L3-SW2-GigabitEthernet0/0/1]port link-t
[L3-SW2-GigabitEthernet0/0/1]port link-type tr
[L3-SW2-GigabitEthernet0/0/1]port link-type trunk
[L3-SW2-GigabitEthernet0/0/1]po
[L3-SW2-GigabitEthernet0/0/1]port tr
[L3-SW2-GigabitEthernet0/0/1]port trunk a
[L3-SW2-GigabitEthernet0/0/1]port trunk allow-pass v
[L3-SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan a
[L3-SW2-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[L3-SW2-GigabitEthernet0/0/1]q
[L3-SW2]vla
[L3-SW2]vlan ba
[L3-SW2]vlan batch 10 20 200
Info: This operation may take a few seconds. Please wait for a moment...done.
[L3-SW2]int vlan 10
[L3-SW2-Vlanif10]ip add
[L3-SW2-Vlanif10]ip address 192.168.10.11 24
[L3-SW2-Vlanif10]v
[L3-SW2-Vlanif10]vrrp v
[L3-SW2-Vlanif10]vrrp vrid 1 v
[L3-SW2-Vlanif10]vrrp vrid 1 virtual-ip 192.168.10.1
[L3-SW2-Vlanif10]v
[L3-SW2-Vlanif10]vrrp v
[L3-SW2-Vlanif10]vrrp vrid 1 tr
[L3-SW2-Vlanif10]vrrp vrid 1 track in
[L3-SW2-Vlanif10]vrrp vrid 1 track interface g0/0/2
[L3-SW2-Vlanif10]int vlan 20
[L3-SW2-Vlanif20]ip add
[L3-SW2-Vlanif20]ip address 192.168.20.11 24
[L3-SW2-Vlanif20]v
[L3-SW2-Vlanif20]vrrp v
[L3-SW2-Vlanif20]vrrp vrid 2 v
[L3-SW2-Vlanif20]vrrp vrid 2 virtual-ip 192.168.20.1
[L3-SW2-Vlanif20]v
[L3-SW2-Vlanif20]vrrp v
[L3-SW2-Vlanif20]vrrp vrid 2 pr
[L3-SW2-Vlanif20]vrrp vrid 2 priority 105
[L3-SW2-Vlanif20]v
[L3-SW2-Vlanif20]vrrp v
[L3-SW2-Vlanif20]vrrp vrid 2 t
[L3-SW2-Vlanif20]vrrp vrid 2 tr
[L3-SW2-Vlanif20]vrrp vrid 2 track in
[L3-SW2-Vlanif20]vrrp vrid 2 track interface g0/0/2
[L3-SW2-Vlanif20]q
[L3-SW2]int g0/0/2
[L3-SW2-GigabitEthernet0/0/2]po
[L3-SW2-GigabitEthernet0/0/2]port li
[L3-SW2-GigabitEthernet0/0/2]port link-t
[L3-SW2-GigabitEthernet0/0/2]port link-type ac
[L3-SW2-GigabitEthernet0/0/2]port link-type access
[L3-SW2-GigabitEthernet0/0/2]po
[L3-SW2-GigabitEthernet0/0/2]port de
[L3-SW2-GigabitEthernet0/0/2]port default v
[L3-SW2-GigabitEthernet0/0/2]port default vlan 200
[L3-SW2-GigabitEthernet0/0/2]q
[L3-SW2]int vlan 200
[L3-SW2-Vlanif200]ip add
[L3-SW2-Vlanif200]ip address 20.20.20.2 24
[L3-SW2-Vlanif200]q
[L3-SW2]ip rou
[L3-SW2]ip route-s
[L3-SW2]ip route-static 1.1.1.1 32 20.20.20.11
[L3-SW2]
R1
[R1]int g0/0/1
[R1-GigabitEthernet0/0/1]undo shu
[R1-GigabitEthernet0/0/1]undo shutdown
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R1-GigabitEthernet0/0/1]ip add
[R1-GigabitEthernet0/0/1]ip address 10.10.10.11 24
[R1-GigabitEthernet0/0/1]int g0/0/2
[R1-GigabitEthernet0/0/2]undo shu
[R1-GigabitEthernet0/0/2]undo shutdown
Info: Interface GigabitEthernet0/0/2 is not shutdown.
[R1-GigabitEthernet0/0/2]ip add
[R1-GigabitEthernet0/0/2]ip address 20.20.20.11 24
[R1-GigabitEthernet0/0/2]q
[R1]int LoopBack 0
[R1-LoopBack0]ip address 1.1.1.1 32
[R1-LoopBack0]q
[R1]ip route-static 192.168.10.0 24 10.10.10.1
[R1]ip route-static 192.168.10.0 24 20.20.20.2 preference 65
[R1]ip route-static 192.168.20.0 24 20.20.20.2
[R1]ip route-static 192.168.20.0 24 10.10.10.1 preference 65
PC1
PC2
检测是否配置成功:
从检测结果来看是按照正确路由去传输的