device carp
The CARP allows multiple hosts on the same local network to share a set of IPv4 and/or IPv6 addresses. Its primary purpose is to ensure that these addresses are always available.
To use carp, the administrator needs to configure at a minimum a common virtual host ID (vhid), and attach at least one IP address to this vhid on each machine which is to take part in the virtual group. Additional parameters can also be set on a per-vhid basis: advbase and advskew, which are used to control how frequently the host sends advertisements when it is the master for a virtual host, and pass which is used to au- thenticate carp advertisements. The advbase parameter stands for "advertisement base". It is measured in seconds and specifies the base of the advertisement interval. The advskew parameter stands for "advertisement skew". It is measured in 1/256 of seconds. It is added to the base advertisement interval to make one host advertise a bit slower that the other does. Both advbase and advskew are put inside CARP advertisements. These values can be configured using ifconfig(8), or through the SIOCSVH ioctl(2). To use carp, the administrator needs to configure at minimum a common virtual host ID (VHID) and virtual host IP address on each machine which is to take part in the virtual group. Additional parameters can also be set on a per-interface basis: advbase and advskew, which are used to control how frequently the host sends advertisements when it is the master for a virtual host, and pass which is used to authenticate carp advertisements. The advbase parameter stands for "advertisement base". It is measured in seconds and specifies the base of the advertisement interval. The advskew parameter stands for "advertisement skew". It is measured in 1/256 of seconds. It is added to the base advertisement interval to make one host advertise a bit slower that the other does. Both advbase and advskew are put inside CARP advertisements. These configurations can be done using ifconfig, or through the SIOCSVH ioctl.
CARP virtual hosts can be configured on multicast-capable interfaces:
Ethernet, layer 2 VLAN, FDDI and Token Ring. An arbitrary number of virtual host IDs can be configured on an interface. An arbitrary number of IPv4 or IPv6 addresses can be attached to a particular vhid. It is important that all hosts participating in a vhid have the same list of prefixes configured on the vhid, since all the prefixes are included in the cryptographic checksum supplied in each advertisement. Multiple vhids running on one interface participate in master/backup elections independently.
Additionally, there are a number of global parameters which can be set using sysctl(8):
net.inet.carp.allow
net.inet.carp.preempt
net.inet.carp.dscp
net.inet.carp.log
netr.inet.carp.demotion
net.inet.carp.ifdown_demotion_factor
net.inet.carp.senderr_demotion_factor
For firewalls and routers with multiple interfaces, it is desirable to failover all of the addresses running carp together, when one of the physical interfaces goes down. This is achieved by the preempt option. Enable it on both host A and B:
sysctl net.inet.carp.preempt=1
Assume that host A is the preferred master and we are running the 192.168.1.0/24 prefix on em0 and 192.168.2.0/24 on em1. This is the setup for host A (advskew is above 0 so it could be overwritten in the emergency situation from the other host):
ifconfig ie1g0 vhid 1 advskew 100 pass mekmitasdigoat 192.168.1.1/24
ifconfig ie1g1 vhid 2 advskew 100 pass mekmitasdigoat 192.168.2.1/24
The setup for host B is identical, but it has a higher advskew:
ifconfig ie1g0 vhid 1 advskew 200 pass mekmitasdigoat 192.168.1.1/24
ifconfig ie1g1 vhid 2 advskew 200 pass mekmitasdigoat 192.168.2.1/24
When one of the physical interfaces of host A fails, advskew is demoted to a configured value on all its carp vhids. Due to the preempt option, host B would start announcing itself, and thus preempt host A on both interfaces instead of just the failed one.
To see carp packets decoded in tcpdump(1) output, one needs to specify the -T carp option, otherwise tcpdump(1) will interpret them as VRRP packets:
tcpdump -npi vlan0 -T carp
Versions |
---|
INtime 7.1 |