CARP(4) BSD Programmer's Manual CARP(4)
carp - Common Address Redundancy Protocol
pseudo-device carp [count]
The carp interface is a pseudo-device which implements and controls the CARP protocol. carp allows multiple hosts on the same local network to share a set of IP addresses. Its primary purpose is to ensure that these addresses are always available, but in some configurations carp can also provide load balancing functionality. A carp interface can be created at runtime using the ifconfig carpN create command or by setting up a hostname.if(5) configuration file for netstart(8). To use carp, the administrator needs to configure at minimum a common virtual host ID 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 vir- tual host, and pass which is used to authenticate carp advertisements. These configurations can be done using ifconfig(8), or through the SIOCSVH ioctl. Additionally, there are a number of global parameters which can be set using sysctl(8).
In order to set up an ARP balanced virtual host, it is necessary to con- figure one virtual host for each physical host which would respond to ARP requests and thus handle the traffic. In the following example, 2 hosts are configured to provide balancing and failover for the IP address 192.168.1.10. First the carp interfaces on Host A are configured. The advskew of 100 on the second virtual host means that its advertisements will be sent out slightly less frequently. # ifconfig carp0 create # ifconfig carp0 vhid 1 pass mekmitasdigoat 192.168.1.10 # ifconfig carp1 create # ifconfig carp1 vhid 2 advskew 100 pass mekmitasdigoat 192.168.1.10 The configuration for host B is identical, except the skew is on virtual host 1 rather than virtual host 2. # ifconfig carp0 create # ifconfig carp0 vhid 1 advskew 100 pass mekmitasdigoat 192.168.1.10 # ifconfig carp1 create # ifconfig carp1 vhid 2 pass mekmitasdigoat 192.168.1.10 Finally, the ARP balancing feature must be enabled on both hosts: # sysctl net.inet.carp.arpbalance=1 When the hosts receive an ARP request for 192.168.1.10, they both select one of the virtual hosts based on the source IP address in the request. The host which is master of that virtual host will reply to the request, the other will ignore it. Because the host which advertises most often will tend to be the master, the result of this is that Host A will tend to be the master for the vir- tual host with ID 1, while Host B will tend to be the master for the vir- tual host with ID 2, and therefore arp requests and subsequent IP traffic are balanced across the two hosts. If one of the hosts fails, the other will take over the virtual MAC address, and begin answering ARP requests on its behalf. Note: ARP balancing only works on the local network segment. Connections which cross a router to arrive on the local network segment will all ap- pear to come from that router and be balanced to the same host.
sysctl(3), inet(4), ifconfig(8), sysctl(8)
The carp device first appeared in OpenBSD 3.5. MirOS BSD #10-current October 16, 2003 1
Generated on 2014-02-10 02:47:05 by $MirOS: src/scripts/roff2htm,v 1.79 2014/02/10 00:36:11 tg Exp $
These manual pages and other documentation are copyrighted by their respective writers;
their source is available at our CVSweb,
AnonCVS, and other mirrors. The rest is Copyright © 2002‒2014 The MirOS Project, Germany.
This product includes material provided by Thorsten Glaser.
This manual page’s HTML representation is supposed to be valid XHTML/1.1; if not, please send a bug report – diffs preferred.