1. VRRP technology
Virtual Router Redundancy Protocol (VRRP) is an IP protocol suite. We know that there are ICMP and OSPF in the IP protocol suite. VRRP is also a member of the IP protocol suite, and the protocol number is 112. In VRRP, the device has two roles (Master and Backup), where the Master is responsible for running business traffic, and the Backup is responsible for backup. When the Master hangs up, Backup automatically preempts it as the Master, and then all data goes from the Master. VRRP is mainly used for redundant backup of egress links. Multiple gateway devices can join a backup group, but there can only be one master device. When the master device hangs up, other backup devices automatically preempt as the master device To ensure the reliability of the network.
2. VRRP configuration examples
Requirements:
SW1 is the main gateway of vlan10, the backup gateway
of vlan20 SW2 is the main gateway of vlan20, and the backup gateway of vlan10
Configuration parameter
VLAN10
SW1配置
interface Vlan10
ip address 10.10.10.3 255.255.255.0
vrrp 1 ip 10.10.10.1
vrrp 1 preempt delay minimum 5
vrrp 1 priority 120
vrrp 1 track 1 decrement 20
!
SW2配置
interface Vlan10
ip address 10.10.10.4 255.255.255.0
vrrp 1 ip 10.10.10.1
vrrp 1 preempt delay minimum 5
vrrp 1 priority 150
!
VLAN20
SW1配置
interface Vlan20
ip address 10.10.20.3 255.255.255.0
vrrp 2 ip 10.10.20.1
vrrp 2 preempt delay minimum 5
!
SW2配置
track 2 interface Ethernet0/2 line-protocol //追踪上联端口
interface Vlan20
ip address 10.10.20.4 255.255.255.0
vrrp 2 ip 10.10.20.1
vrrp 2 preempt delay minimum 5
vrrp 2 priority 120
vrrp 2 track 2 decrement 40
!
Result test:
在SW1上查看
Switch#show vrrp
Vlan10 - Group 1
State is Backup
Virtual IP address is 10.10.10.1
Virtual MAC address is 0000.5e00.0101
Advertisement interval is 1.000 sec
Preemption enabled, delay min 5 secs
Priority is 120
Track object 1 state Up decrement 20
Master Router is 10.10.10.4, priority is 150
Master Advertisement interval is 1.000 sec
Master Down interval is 3.531 sec (expires in 3.431 sec)
Vlan20 - Group 2
State is Backup
Virtual IP address is 10.10.20.1
Virtual MAC address is 0000.5e00.0102
Advertisement interval is 1.000 sec
Preemption enabled, delay min 5 secs
Priority is 100
Master Router is 10.10.20.4, priority is 120
Master Advertisement interval is 1.000 sec
Master Down interval is 3.609 sec (expires in 2.994 sec)
在SW2上查看
Switch#show vrrp
Vlan10 - Group 1
State is Master
Virtual IP address is 10.10.10.1
Virtual MAC address is 0000.5e00.0101
Advertisement interval is 1.000 sec
Preemption enabled, delay min 5 secs
Priority is 150
Master Router is 10.10.10.4 (local), priority is 150
Master Advertisement interval is 1.000 sec
Master Down interval is 3.414 sec
Vlan20 - Group 2
State is Master
Virtual IP address is 10.10.20.1
Virtual MAC address is 0000.5e00.0102
Advertisement interval is 1.000 sec
Preemption enabled, delay min 5 secs
Priority is 120
Track object 2 state Up decrement 40
Master Router is 10.10.20.4 (local), priority is 120
Master Advertisement interval is 1.000 sec
Master Down interval is 3.531 sec
Tracking test:
关闭SW2的上联端口e0/2
SW1切换为VLAN20的主网关
Switch(config)#int e 0/2
Switch(config-if)#sh
Switch(config-if)#
*Nov 11 06:13:48.928: %TRACK-6-STATE: 2 interface Et0/2 line-protocol Up -> Down
Switch(config-if)#
*Nov 11 06:13:50.933: %LINK-5-CHANGED: Interface Ethernet0/2, changed state to administratively down
*Nov 11 06:13:51.935: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/2, changed state to down
Switch(config-if)#
*Nov 11 06:13:54.461: %VRRP-6-STATECHANGE: Vl20 Grp 2 state Master -> Backup
SW2开启上联端口e0/2
SW2恢复为VLAN20的主网关
Switch(config-if)#no sh
Switch(config-if)#
*Nov 11 06:14:05.361: %LINK-3-UPDOWN: Interface Ethernet0/2, changed state to up
Switch(config-if)#
*Nov 11 06:14:06.699: %TRACK-6-STATE: 2 interface Et0/2 line-protocol Down -> Up
Switch(config-if)#
*Nov 11 06:14:07.373: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0/2, changed state to up
Switch(config-if)#
*Nov 11 06:14:12.035: %VRRP-6-STATECHANGE: Vl20 Grp 2 state Backup -> Master