33、VRRP(虚拟路由冗余协议)

发布时间 2023-08-23 15:12:02作者: 五杀摇滚小拉夫

虚拟路由冗余协议主要解决中网络网关的单点故障,在vrrp默认配置情况下,所有数据包都是交给主设备来处理的,只有当主设备出现故障时备用设备才会处理数据,这样导致备用设备长时间闲置,数据全部由主设备处理负荷大,导致数据处理不及时,出现延时现象。

vrrp是企业中提供网络高可靠性的主要协议,主要解决网关单点故障引起的网络中断事故,通过热备份路由器的方式,当网络中路由设备故障时,能自动在线切换,保障通信的连续与稳定。

1、vrrp虚拟路由网关基本配置

2、配置如下:

 ①、配置PC1的ip、网关、子网掩码

 ②、SW3配置

[sw3]inter Ethernet 0/0/1
[sw3-Ethernet0/0/1]port link-type trunk
[sw3-Ethernet0/0/1]port trunk allow-pass vlan all
[sw3-Ethernet0/0/1]quit
[sw3]inter Ethernet 0/0/2
[sw3-Ethernet0/0/2]port link-type trunk
[sw3-Ethernet0/0/2]port trunk allow-pass vlan all
[sw3-Ethernet0/0/2]quit
[sw3]inter Ethernet 0/0/3
[sw3-Ethernet0/0/3]port link-type access
[sw3-Ethernet0/0/3]port default vlan 10
[sw3-Ethernet0/0/3]quit

 ③、sw1 配置

[sw1]un info en
Info: Information center is disabled.
[sw1]vlan 10
[sw1-vlan10]quit
[sw1]inter Gigabit    
[sw1]inter GigabitEthernet 0/0/2
[sw1-GigabitEthernet0/0/2]port link-type trunk
[sw1-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[sw1-GigabitEthernet0/0/2]quit
[sw1]inter Vlanif 10
[sw1-Vlanif10]ip address 10.1.10.251 24
[sw1-Vlanif10]quit
[sw1]quit
<sw1>save
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 配置

[sw2]
Aug 23 2023 09:56:01-08:00 sw2 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 c
hange loop count is 0, and the maximum number of records is 4095.
[sw2]un info en
Info: Information center is disabled.
[sw2]vlan 10
[sw2-vlan10]quit
[sw2]inter G    
[sw2]inter GigabitEthernet 0/0/2
[sw2-GigabitEthernet0/0/2]port link-type trunk
[sw2-GigabitEthernet0/0/2]port trunk allow-pass vlan all
[sw2-GigabitEthernet0/0/2]quit
[sw2]inter Vlanif 10
[sw2-Vlanif10]ip add 10.1.10.252 24
[sw2-Vlanif10]quit
[sw2]quit
<sw2>save
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>

 ⑤、vrrp虚拟网关配置

#创建 vrrp 工作组为10,虚拟ip地址为 10.1.10.254
#配置优先为120.目的是让sw1成为Master

#创建 vrrp 工作组为10,虚拟ip地址为 10.1.10.254,优先级默认配置是100.                                                                                                                                                              

 ⑥、查看vrrp配置

<sw1>dis vrrp
  Vlanif10 | Virtual Router 10
    State : Master  #sw1为Master角色
    Virtual IP : 10.1.10.254  #虚拟网关地址
    Master IP : 10.1.10.251  #物理网关地址
    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-010a  #虚拟MAC
    Check TTL : YES
    Config type : normal-vrrp
    Create time : 2023-08-23 10:33:40 UTC-08:00
    Last change time : 2023-08-23 10:33:43 UTC-08:00

<sw1>

<sw1>dis vrrp brief
VRID State Interface Type Virtual IP
----------------------------------------------------------------
10 Master Vlanif10 Normal 10.1.10.254
----------------------------------------------------------------
Total:1 Master:1 Backup:0 Non-active:0
<sw1>

<sw2>dis vrrp
  Vlanif10 | Virtual Router 10
    State : Backup
    Virtual IP : 10.1.10.254
    Master IP : 10.1.10.251
    PriorityRun : 100  #运行优先级100
    PriorityConfig : 100  #配置优先级100
    MasterPriority : 120  #主备优先级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 : 2023-08-23 10:35:11 UTC-08:00
    Last change time : 2023-08-23 10:35:11 UTC-08:00

<sw2>

<sw2>dis vrrp brief
VRID State Interface Type Virtual IP
----------------------------------------------------------------
10 Backup Vlanif10 Normal 10.1.10.254
----------------------------------------------------------------
Total:1 Master:0 Backup:1 Non-active:0
<sw2>

⑦、通信测试

PC1 ping 网关 10.1.10.254 

 将sw1 交换机关机,再次测试通信状态

 将sw1 关闭后刚开始不通,一会就连通了。

 查看sw3的mac-address,可以看到数据是从sw3的Eth0/0/2出去

 

以上便说明了,在vrrp默认配置下,所有数据是交给主设备Master处理的,当主设备出现故障时,备用设备处理数据。

SW1正常情况下,SW1优先级120,是Master。SW2是Backup。