It is required to ensure the operability of a specific IP address (gateway, important server, etc.) when communication with the device to which this address originally belongs is lost using backup devices.
The article will use Debian Linux, the CARP protocol, and the ucarp utility for this purpose.
Operating principle
One or more backup (backup) with the same services is added to the main device owner IP (master)
Each device additionally has a unique service IP address and assigned priority,
Backup devices are continuously polled by the wizard
As soon as the master stops responding, the backup device that has the highest priority raises the public IP on its network interface,
Protocols and terms
Hot standby is a generic term for the mechanism (as well as the name of the obsolete proprietary protocol HSRP from Cisco), in which a reserve is created for a resource that operates in idle mode and is ready to immediately switch to operational mode automatically.
VRRP , Virtual Router Redundancy Protocol — Developed by the HSRP-based IETF, but incompatible with it. Available as RFC, but contains Cisco patent bookmarks. Supported by many professional-grade hardware routers and has open implementations for Linux / Unix.
CARP , Common Address Redundancy Protocol - open, developed as part of OpenBSD, ported to FreeBSD. In * BSD, it is supported directly by the kernel and is controlled by the base system.
High availability (HA) is what the Hot-standby for VRRP and CARP is used for IP addresses.
Load balancing (LB) - something that is often referred to in conjunction with HA, but in our case is not provided.
keepalived is another system for organizing a cluster.
carp is a module for the Linux kernel by Evgeny Polyakov. The official kernel is not included, with standard CARP, it is either incompletely compatible, or incompatible at all.
vrrpd , ucarp - User-space daemons implementing VRRP and CARP.
Test system configuration
Two physical routers R1 and R2 , forming one virtual fault tolerant VR .
1.2.3.4 - the external IP address of VR.
10.0.0.1/16 - the internal IP address of VR.
eth0 - LAN interfaces of routers.
eth1 - WAN interfaces of routers.
10.255.0.0/24 - a private subnet for connecting routers via a LAN interface.
10.255.1.0/24 - a private subnet for connecting routers via the WAN interface.
10.255. *. 11, .12, .13, ... - IP addresses of routers R1, R2, ... in private subnets.
10.0.0.2 - test computer with default gateway 10.0.0.1
Installing ucarp on R1 and R2
apt-get install ucarp
Documentation
In Debian, setting up and launching ucarp is not done directly, but with the help of additional parameters in the standard system settings file / etc / network / interfaces , it is recommended that you first read not “man ucarp” (although this is also not superfluous) and /usr/share/doc/ucarp/README.Debian . ')
This approach has both pros and cons. On the one hand, the setting becomes more visual. On the other hand, if on one interface it is required to support several independent virtual IPs, then for all but the first one, ucarp will have to be started manually.