Keepalived is a load balancer and high availability (HA) solution for Linux clusters. It can be used to manage both IPv4 and IPv6 addresses.
To use Keepalived to manage both IPv4 and IPv6 addresses, you need to create a separate Keepalived configuration file for each address family. For example, you might have a keepalived.conf
file for IPv4 and a keepalivedv6.conf
file for IPv6.
In each Keepalived configuration file, you need to define a virtual router (VR) for each IP address that you want to manage. For example, if you have an IPv4 address of 192.168.1.1 and an IPv6 address of 2001:db8:85a3:0:8a2e:370:7334:3564, you would define two VRs:
- VR1 with the IPv4 address of 192.168.1.1
- VR2 with the IPv6 address of 2001:db8:85a3:0:8a2e:370:7334:3564
You also need to define a state for each VR. The state can be either MASTER
or BACKUP
. The MASTER VR is the active VR and is responsible for handling traffic. The BACKUP VR is the standby VR and is ready to take over if the MASTER VR fails.
For example, you might configure VR1 to be the MASTER VR for IPv4 and VR2 to be the BACKUP VR for IPv4. You might also configure VR2 to be the MASTER VR for IPv6 and VR1 to be the BACKUP VR for IPv6.
Once you have defined the VRs and their states, you need to define a track interface for each VR. The track interface is the interface that Keepalived will use to monitor the health of the VR.
For example, you might configure Keepalived to track the eth0 interface for both VR1 and VR2.
Finally, you need to start the Keepalived daemon.
Here is an example of a Keepalived configuration file for IPv4 and IPv6:
# Keepalived configuration file for IPv4
global_defs {
router_id VR1
state MASTER
interface eth0
virtual_ipaddress {
192.168.1.1
}
track_interface {
eth0
}
}
# Keepalived configuration file for IPv6
global_defs {
router_id VR2
state BACKUP
interface eth0
virtual_ipaddress {
2001:db8:85a3:0:8a2e:370:7334:3564
}
track_interface {
eth0
}
}
To start the Keepalived daemon, you can run the following command:
sudo service keepalived start
Keepalived will now monitor the health of the VRs and ensure that the active VR is always available. If the active VR fails, Keepalived will automatically switch to the standby VR.