Nine, VRRP related knowledge

VRRP

VRRP is a virtual routing redundancy protocol

VRRP is used to determine the main router and real-time conversion

Function: Provide a device backup mechanism on the local area network. VRRP is a fault-tolerant protocol. It ensures that when the next-hop router of a host fails, it can be replaced by another router in time, thus ensuring the continuity and reliability of communication.

Principle: When VRRP works, a virtual router containing a virtual IP and a virtual Mac address is added to the network. The router acts as a gateway for network users, so that the host on the network communicates with the virtual router without knowing any information about the physical router on the network.

VRRP packets are encapsulated in IP packets and sent through the multicast address 224.0.0.18, with a TTL of 225 and a protocol number of 112

VRRP protocol
VRRP protocol has three states: Initialize (initial), Master and Backup (comparing the priority to determine the master and backup)

VRRP terminology

VRRP router A router that
runs VRRP. A VRRP router (the interface) can participate in multiple VRRP groups at the same time. In different groups, a VRRP router can play different roles.

VRRP group
A VRRP group consists of multiple VRRP routers, which are identified by the same VRID (Virtual Router ID). VRRP routers belonging to the same VRRP group exchange information with each other. Each VRRP group can only have one Master.

A virtual router
is an abstract logical router for each VRRP group. The router acts as a gateway for network users. The router does not really exist. In fact, for users, they only need to know the P of the virtual router. As for the specific virtual router, Who will assume the role, who will assume the task of data forwarding, and who will take over after the Master fails? This is the job of VRRP.

Virtual IP address, MAC address The
virtual IP address is the IP address of the virtual router, which is actually the user's gateway address. The virtual MAC address is the MAC address generated by the virtual router based on the VRID. A virtual router has a virtual MAC address in the format: 00-00-5E-O0-O1-{VRID}.

Master, Backup router
Master router: The router that actually forwards data packets in the VRRP group. In each VRRP group, only the Master responds to the ARP request for the virtual IP address. The Master router sends VRRP messages at a certain time interval at the same time to inform the Backup router of its own survival status.
Backup router: A router in the monitoring state. Once the Master router fails, the Backup router will begin to take over.
Election basis: first compare the interface VRRP priority (higher ratio), if they are equal, compare the interface IP address
(higher ratio).

The working principle of Master and Backup routers

The Master router
periodically (Advertisement Interval) sends VRRP advertisement messages to inform the Backup router of its survival status.
Respond to the ARP request of other devices for the virtual IP address with the virtual MAC address. Forward IP packets with the virtual MAC address as the destination MAC address.
If it is the owner of this virtual IP address (the actual IP address of the interface is a virtual IP address), it will receive an IP packet whose destination IP address is this virtual IP address. Otherwise, discard the IP packet.
If it receives a packet with a higher priority than its own, it immediately becomes a backup.
If it receives a VRRP packet with the same priority as its own and the local interface IP address is less than the peer interface IP, it immediately becomes a backup.

The backup router
receives the VRRP advertisement message sent by the master device to determine whether the status of the master device is normal. No response is made to the ARP request of the virtual IP address.
IP packets whose destination IP addresses are virtual IP addresses are discarded.
If it receives a packet with the same priority as itself or greater than itself, it resets the Master_Down_Interval timer without further comparing IP addresses.
If a packet with a lower priority than its own is received and the priority of the packet is 0, the timer time is set to Skew_time (offset time). If the priority of the packet is not 0, the packet is discarded and the packet becomes the master immediately.

Master_Down_Interval timer
Backup device does not receive the notification message after the timer expires, it will change to the Master state. The calculation formula is as follows: Master_Down_Interval=(3*Advertisement_Interval) + Skew_time. Among them, Skew_Time=(256-Priority)/256

Configuration

Insert picture description here

LSW1 LSW2
vlan batch 10 20 30 100 vlan batch 10 20 100
int g0/0/2 interface g0/0/2
port link-type trunk port link-type trunk
port trunk allow-pass vlan 10 20 100 port trunk allow-pass vlan 10 20 100
int g0/0/1 int g0/0/1
port link-type access port link-type access
port default vlan 100 port default vlan 100
int Vlanif 10 (gateway interface, Layer 3 switching as VLAN interface, router as downstream interface) int Vlanif 10
ip address 192.168.10.10 24 vrrp vrid 10 virtual-ip 192.168.10.1
undo shutdown ip address 192.168.10.20 24
int Vlanif 20 undo shutdown
ip address 192.168.20.10 24 int Vlanif 20
undo shutdown ip address 192.168.20.20 24
int Vlanif 100 undo shutdown
ip address 11.0.0.2 30 int Vlanif 100
undo shutdown ip address 12.0.0.2 30
int Vlanif 10 undo shutdown
vrrp vrid 10 virtual-ip 192.168.10.1 (create the VRRP virtual router with the identifier vrid of 10, and configure the virtual IP address of vrid 10) int Vlanif 20
vrrp vrid 10 priority 120 (set the priority of the device to 120 (default is 100), the larger the value, the more priority) vrrp vrid 20 virtual-ip 192.168.20.1
vrrp vrid 10 preempt-mode timer delay 5 (The preemption delay of the Master device is 5 seconds (default is o, preempt immediately) to prevent frequent state switching) vrrp vrid 20 priority 115
vrrp vrid 10 track interface GigabitEthernet 0/0/1 reduced 30 (track the status of the uplink interface GO/0/1, if the port fails, the master priority will be reduced by 30, the default is 10) vrrp vrid 20 preempt-mode timer delay 5
int Vlanif 20 vrrp vrid 20 track interface GigabitEthernet 0/0/1 reduced 35
vrrp vrid 20 virtual-ip 192.168.20.1
undo shutdown
int Vlanif 100
ip address 10.0.0.1 30
dis vrrp (display VRRP status)
Set up Master first, then set up LSW2 Backup

Guess you like

Origin blog.csdn.net/TaKe___Easy/article/details/112195059