One article to understand: VRRP

Learn VRRP today.

Before learning, let's take a look at the birth background of VRRP:

- When the gateway router RouterA fails, the hosts using this device as the gateway in this network segment cannot communicate with the Internet

- There may be some problems with multiple gateways: IP address conflicts between gateways; hosts will frequently switch network exits

 Problem with single gateway Problem with multiple gateways

The basic concept of VRRP:

-Virtual Router (Virtual Router): It consists of a Master device and multiple Backup devices, and is used as a default gateway for hosts in a shared LAN. For example, Router A and Router B together form a virtual router.

-Master router (Virtual Router Master): VRRP device responsible for forwarding packets, such as Router A. -Backup router (Virtual Router Backup): A group of VRRP devices that do not undertake the forwarding task. When the Master device fails, they will become the new Master device through election, such as Router B.

-Priority: The priority of the device in the backup group, the value range is 0~255. 0 means that the device stops participating in the VRRP backup group, which is used to make the backup device become the Master device as soon as possible without waiting for the timer to expire; 255 is reserved for The owner of the IP address cannot be manually configured; the default priority value of the device is 100.

- vrid: the identifier of the virtual router. In the figure, the vrid of the virtual router composed of Router A and Router B is 1, manually specified, and the range is 1-255.

-Virtual IP address (Virtual IP Address): the IP address of the virtual router, a virtual router can have one or more IP addresses, configured by the user. For example, the virtual IP address of the virtual router composed of Router A and Router B is 10.1.1.254/24.

-IP Address Owner: If a VRRP device configures the real interface IP address as the virtual router IP address, the device is called the IP address owner. If the IP address owner is available, it will always be the Master.

-Virtual MAC Address (Virtual MAC Address): The MAC address generated by the virtual router based on the vrid. -A virtual router has a virtual MAC address, the format is: 00-00-5E-00-01-{vrid}. When a virtual router responds to an ARP request, it uses the virtual MAC address instead of the real MAC address of the interface. For example, the vrid of the virtual router composed of RouterA and RouterB is 1, so the MAC address of this VRRP backup group is 00-00-5E-00-01-01.

-VRRP protocol state machine has three states: Initialize (initial state), Master (active state), Backup (standby state).

How VRRP works:

-VRRP can virtualize multiple routers into a virtual router without changing the networking, and realize gateway backup by configuring the IP address of the virtual router as the default gateway.

- Protocol version: VRRPv2 (commonly used) and VRRPv3 VRRPv2 is only applicable to IPv4 networks, and VRRPv3 is applicable to both IPv4 and IPv6 networks.

-VRRP protocol message: There is only one kind of message: the destination IP address of the Advertisement message is 224.0.0.18, the destination MAC address is 00-00-5e-00-01-XX, the protocol number is 112, and VRRP is a network layer protocol .

Step 1: Elect the Master

  1.  The devices in the VRRP backup group elect the master according to the priority. The master device notifies the device or host connected to it of the virtual MAC address by sending a gratuitous ARP message, so as to undertake the task of message forwarding.
  2.  Election rules: compare the size of the priority, and the one with the higher priority is elected as the master device. When two devices have the same priority, if there is already a master, they will maintain the status of the master, and there is no need to continue the election; if there is no master, continue to compare the size of the interface IP address, and the device with the larger interface IP address will be elected as the master device.

Step 2: Notification of the status of the Master device (VRRP backup group status maintenance)

  1. The master device periodically sends VRRP notification packets to announce its configuration information (priority, etc.) and working status in the VRRP backup group. The Backup device judges whether the Master device is working normally through the received VRRP packets.
  2. When the Master device voluntarily gives up the Master status (for example, the Master device exits the backup group), it will send a notification message with a priority of 0 to make the Backup device quickly switch to the Master device without waiting for the Master_Down_Interval (default is 3s) timer time out. The switching time is called Skew_Time (almost 0s), and the calculation method is: (256-Backup device priority)/256, and the unit is second.
  3. When the Master device fails to send notification messages due to a network failure, the Backup device cannot immediately know its working status. After the Master_Down_Interval timer expires, it will consider that the Master device cannot work normally, and thus switch the state to Master. Wherein, the value of the Master_Down_Interval timer is: 3×Advertisement_Interval+Skew_Time, and the unit is second. Where Advertisement_Interval is 1s by default.

VRRP master/standby switchover process

If the Master fails, the process of master-standby switchover

  1. When the backup device in the group does not receive a message from the master device within a period of time (Master_Down_Interval timer value: 3×Advertisement_Interval+Skew_Time, unit is second), it will turn itself into a master device.
  2. When there are multiple backup devices in a VRRP group, multiple master devices may be generated in a short period of time. At this time, the device will compare the priority in the received VRRP message with the local priority, so as to select the one with the highest priority. The device becomes the Master. q After the status of the device becomes Master, it will immediately send a gratuitous ARP to refresh the MAC table entries on the switch, thereby directing the user's traffic to this device, and the whole process is completely transparent to the user.

Working Process of VRRP Load Balancing

  1. Load balancing means that multiple VRRP backup groups undertake service forwarding at the same time. The basic principle and packet negotiation process of VRRP load balancing and VRRP active/standby backup are the same. Each VRRP backup group includes a Master device and several Backup devices.
  2. The difference from the master-standby backup method is that: the load sharing method needs to establish multiple VRRP backup groups, and the Master device of each backup group is shared on different devices; a single device can join multiple backup groups and play the role of VRRP in different backup groups. different roles.

Thank you for your attention!

Guess you like

Origin blog.csdn.net/yuyeconglong/article/details/132685972