目录
一、什么是VRRP
1、VRRP含义
VRRP:Virtual Router Redundancy Protocol,虚拟路由器备份协议。
VRRP能够在不改变组网的情况下,将多台路由器虚拟成一个虚拟路由器,通过配置虚拟路由器的IP地址
为默认网关,实现网关的备份。
协议版本:VRRPv2(常用)和VRRPv3:
VRRPv2仅适用于IPv4网络,VRRPv3适用于IPv4和IPv6两种网络。
VRRP描述了一个动态选举协议,该协议从一组VRRP路由器中选举一个主路由器(Master),并将Master
关联到一个虚拟路由器,作为所连接网段的网关。
VRRP组成员:Master路由器,Backup路由器,虚拟路由器,其他路由器
二、VRRP配置案例(华为)
配置命令:
1、LSW3配置
sys
undo info enable #关闭系统信息提示
vlan batch 10 20
interface e0/0/1
port link-type access #更改接口属性
port default vlan 10
interface e0/0/2
port link-type access #更改接口属性
port default vlan 20
quit
interface e0/0/15
port link-type trunk #更改接口属性
port trunk allow-pass vlan 10 20 #在接口绑定VLAN
interface e0/0/16
port link-type trunk
port trunk allow-pass vlan 10 20
quit
ospf 1
area 0
network 192.168.100.0 0.0.0.3
network 192.168.20.0 0.0.0.255
network 192.168.10.0 0.0.0.255
2、配置三层交换机LSW1
sys
undo info enable #关闭系统信息提示
vlan batch 10 20 100
interface g0/0/2
port link-type trunk #更改接口属性
port trunk allow-pass vlan 10 20 #在接口绑定VLAN
interface g0/0/24
port link-type trunk
port trunk allow-pass vlan 10 20
quit
interface g0/0/1
port link-type access #更改接口属性
port default vlan 100 #在接口绑定VLAN
interface vlanif 100
ip addr 192.168.100.1 255.255.255.252
quit
ospf 1
area 0
network 192.168.100.0 0.0.0.3
network 192.168.20.0 0.0.0.255
network 192.168.10.0 0.0.0.255
3、配置三层交换机LSW2
sys
undo info enable #关闭系统信息提示
vlan batch 10 20 100
interface g0/0/2
port link-type trunk #更改接口属性
port trunk allow-pass vlan 10 20 #在接口绑定VLAN
interface g0/0/24
port link-type trunk
port trunk allow-pass vlan 10 20
quit
interface g0/0/1
port link-type access #更改接口属性
port default vlan 100 #在接口绑定VLAN
interface vlanif 100
ip addr 192.168.100.5 255.255.255.252
quit
ospf 1
area 0
network 192.168.100.0 0.0.0.3
network 192.168.20.0 0.0.0.255
network 192.168.10.0 0.0.0.255
4、路由器R1
sys
undo info enable
interface g0/0/0
ip addr 192.168.100.2 255.255.255.252
interface g0/0/1
ip addr 192.168.100.6 255.255.255.252
interface loopback 0
ip addr 192.168.200.1 255.255.255.0
quit
ospf 1
area 0
network 192.168.100.0 0.0.0.3
network 192.168.20.0 0.0.0.255
network 192.168.10.0 0.0.0.255
1、LSW3配置
sys
undo info enable #关闭系统信息提示
vlan batch 10 20
interface e0/0/1
port link-type access #更改接口属性
port default vlan 10
interface e0/0/2
port link-type access #更改接口属性
port default vlan 20
quit
interface e0/0/15
port link-type trunk #更改接口属性
port trunk allow-pass vlan 10 20 #在接口绑定VLAN
interface e0/0/16
port link-type trunk
port trunk allow-pass vlan 10 20
quit
ospf 1
area 0
network 192.168.100.0 0.0.0.3
network 192.168.20.0 0.0.0.255
network 192.168.10.0 0.0.0.255
2、配置三层交换机LSW1
sys
undo info enable #关闭系统信息提示
vlan batch 10 20 100
interface g0/0/2
port link-type trunk #更改接口属性
port trunk allow-pass vlan 10 20 #在接口绑定VLAN
interface g0/0/24
port link-type trunk
port trunk allow-pass vlan 10 20
quit
interface g0/0/1
port link-type access #更改接口属性
port default vlan 100 #在接口绑定VLAN
interface vlanif 100
ip addr 192.168.100.1 255.255.255.252
quit
ospf 1
area 0
network 192.168.100.0 0.0.0.3
network 192.168.20.0 0.0.0.255
network 192.168.10.0 0.0.0.255
3、配置三层交换机LSW2
sys
undo info enable #关闭系统信息提示
vlan batch 10 20 100
interface g0/0/2
port link-type trunk #更改接口属性
port trunk allow-pass vlan 10 20 #在接口绑定VLAN
interface g0/0/24
port link-type trunk
port trunk allow-pass vlan 10 20
quit
interface g0/0/1
port link-type access #更改接口属性
port default vlan 100 #在接口绑定VLAN
interface vlanif 100
ip addr 192.168.100.5 255.255.255.252
quit
ospf 1
area 0
network 192.168.100.0 0.0.0.3
network 192.168.20.0 0.0.0.255
network 192.168.10.0 0.0.0.255
4、路由器R1
sys
undo info enable
interface g0/0/0
ip addr 192.168.100.2 255.255.255.252
interface g0/0/1
ip addr 192.168.100.6 255.255.255.252
interface loopback 0
ip addr 192.168.200.1 255.255.255.0
quit
ospf 1
area 0
network 192.168.100.0 0.0.0.3
network 192.168.20.0 0.0.0.255
network 192.168.10.0 0.0.0.255
配置图解
LSW3
LSW2
LSW1
R1
三、配置VRRP实现网关备份冗余
配置命令如下
1、三层交换机LSW1(是VLAN10的Master路由器,VLAN20的Backup路由器)
interface Vlanif 10
ip address 192.168.10.1 24
vrrp vrid 10 virtual-ip 192.168.10.254 #虚拟路由器
vrrp vrid 10 priority 200 #优先级(VLAN10优先选择路线)
vrrp vrid 10 preempt-mode timer delay 1 #占先权
vrrp vrid 10 timer advertise 3
vrrp vrid 10 track interface GigabitEthernet0/0/1 reduced 100 #跟踪
interface Vlanif 20
ip address 192.168.20.1 24
vrrp vrid 20 virtual-ip 192.168.20.254
vrrp vrid 20 priority 150
vrrp vrid 20 preempt-mode timer delay 1
vrrp vrid 20 timer advertise 3 #时钟:(Hello间隔)
2、
interface Vlanif 10
ip address 192.168.10.2 24
vrrp vrid 10 virtual-ip 192.168.10.254
vrrp vrid 10 priority 150
vrrp vrid 10 preempt-mode timer delay 1
vrrp vrid 10 timer advertise 3
interface Vlanif 20
ip address 192.168.20.2 24
vrrp vrid 20 virtual-ip 192.168.20.254 #虚拟路由器
vrrp vrid 20 priority 200 #优先级(VLAN20优先选择路线)
vrrp vrid 20 preempt-mode timer delay 1 # #占先权
vrrp vrid 20 timer advertise 3
vrrp vrid 20 track interface GigabitEthernet0/0/1 reduced 100 #跟踪
1、三层交换机LSW1(是VLAN10的Master路由器,VLAN20的Backup路由器)
interface Vlanif 10
ip address 192.168.10.1 24
vrrp vrid 10 virtual-ip 192.168.10.254 #虚拟路由器
vrrp vrid 10 priority 200 #优先级(VLAN10优先选择路线)
vrrp vrid 10 preempt-mode timer delay 1 #占先权
vrrp vrid 10 timer advertise 3
vrrp vrid 10 track interface GigabitEthernet0/0/1 reduced 100 #跟踪
interface Vlanif 20
ip address 192.168.20.1 24
vrrp vrid 20 virtual-ip 192.168.20.254
vrrp vrid 20 priority 150
vrrp vrid 20 preempt-mode timer delay 1
vrrp vrid 20 timer advertise 3 #时钟:(Hello间隔)
2、
interface Vlanif 10
ip address 192.168.10.2 24
vrrp vrid 10 virtual-ip 192.168.10.254
vrrp vrid 10 priority 150
vrrp vrid 10 preempt-mode timer delay 1
vrrp vrid 10 timer advertise 3
interface Vlanif 20
ip address 192.168.20.2 24
vrrp vrid 20 virtual-ip 192.168.20.254 #虚拟路由器
vrrp vrid 20 priority 200 #优先级(VLAN20优先选择路线)
vrrp vrid 20 preempt-mode timer delay 1 # #占先权
vrrp vrid 20 timer advertise 3
vrrp vrid 20 track interface GigabitEthernet0/0/1 reduced 100 #跟踪
配置图解
LSW1
LSW2
四、验证:
1、正常情况
查看VRRP dis vrrp bri
LSW1
LSW2
2、出现故障(如,LSW1的上行链路G0/0/1断开)
3、测试PC能否接通到虚拟端口
PC1配置如下
测试:
4、PC2配置如下
测试
总结:
VRRP(虚拟路由器冗余协议)是一种通过将多台设备组成逻辑上的一台设备来提高网络可用性和可靠性的协议。通过配置VRRP,可以将多个设备组成虚拟路由器,使得在一个设备故障或拓扑结构变化的情况下,网络可以继续正常工作,从而避免中断服务和系统故障所带来的影响。VRRP协议的主要作用是提高网络的可用性和可靠性,保证网络的连通性,降低设备故障对业务产生的影响。同时,VRRP还能够提高网络的容错能力,提升网络配置的灵活性和协议的可修改性,使网络管理更加简便。因此,VRRP的应用可以有效地提高网络的运行效率和可靠性,对于企业级网络的稳健性和可靠性至关重要。
————————————————
版权声明:本文为CSDN博主「lzzy计算机网络2班林仪」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/2301_77892098/article/details/131275519