ucarp8
Automatic ip failover
Usage
ucarp [-i,
--interface=INTERFACE]
[-s,
--srcip=IPADDRESS]
[-v,
--vhid=VHID]
[-p,
--pass=PASSWORD]
[-o,
--passfile=PASSFILE]
[-P,
--preempt]
[-n,
--neutral]
[-a,
--addr=IPADDR]
[-h,
--help]
[-b,
--advbase=SECS]
[-k,
--advskew=SKEW]
[-u,
--upscript=SCRIPT]
[-d,
--downscript=SCRIPT]
[-r,
--deadratio=RATIO]
[-z,
--shutdown]
[-B,
--daemonize]
[-f,
--facility=FACILITY]
[-x,
--xparam
PARAM]
[-S,
--ignoreifstate]
[-M,
--nomcast]
Overview
ucarp allows a pair of hosts to share common IP addresses in order to provide automatic failover of an address from one machine to another. It is a portable userland implementation of the secure and patent-free Common Address Redundancy Protocol, (CARP), OpenBSD's alternative to VRRP.
Options
ucarp supports the following command line options:
- -i INTERFACE --interface=INTERFACE
-
The network interface to bind to.
- -s IPADDRESS --srcip=IPADDRESS
-
The persistent source address, (real IP), associated with this interface.
- -v VHID --vhid=VHID
-
The id of the virtual server [1-255].
- -p PASSWORD --pass=PASSWORD
-
The shared password, (this gets encrypted and is not sent in the clear).
- -o PASSFILE --passfile=PASSFILE
-
File to read the shared password from. The file specified should contain the password on the first line of the file.
-
-P --preempt -
Turn on preemptive failover. This causes an instance of ucarp to assume master status right immediately.
-
-n --neutral -
Do not run the downscript on startup when the initial state is backup.
- -a IPADDRESS --addr=IPADDRESS
-
The IP address of the virtual server.
-
-h --help -
Display a brief summary of the command line options.
- -b SECONDS --advbase=SECONDS
-
Interval in seconds that advertisements will occur, (defaults to 1 second).
- -k SKEW --advskew=SKEW
-
Advertisement skew [1-255], (defaults to 0).
- -u COMMAND --upscript=COMMAND
-
Specifies the command to run after ucarp has successfully become master, the interface name gets passed as an argument. Typically a script used to bring up the virtual address, log the result, add routes, clear arp cache entries, etc.
- -d COMMAND --downscript=COMMAND
-
Specifies the command that is run after ucarp has transitioned to the backup state, the interface name is passed as an argument. This is typically a script used to bring down the virtual interface, log the action, remove routes, etc.
- -r RATIO --deadratio=RATIO
-
Ratio used by the backup to determine how long to wait for an unresponsive master before considering it dead.
-
-z --shutdown -
Use of this command causes the command specified by the -d argument to be invoked when ucarp shuts down.
-
-B --daemonize -
Causes ucarp to detach from the terminal and run in the background as a daemon.
-
-f --facility -
Set the syslog facility, defaults to daemon.
- -x PARAMETER --xparam=PARAMETER
-
Specify an extra parameter to be supplied to the up/down scripts.
-
-S --ignoreifstate -
Ignore unplugged network cables. This option is useful when ucarp nodes are connected with a crossover cable. Without this option the master will transition to backup when the other node is powered down, as it no longer has a link (NO-CARRIER).
-
-M --nomcast -
Use broadcast instead of multicast advertisements.
Examples
A host with a real IP of 10.1.1.10 configured to be the master in a preemptive configuration with a virtual IP of 10.1.1.252.
ucarp -i eth0 -s 10.1.1.10 -v 10 -p secret -a 10.1.1.252 \
--upscript=/usr/local/sbin/vip-up.sh --downscript=/usr/local/sbin/vip-down.sh -P
The backup might be configured something like this.
ucarp -i eth0 -s 10.1.1.11 -v 10 -p secret -a 10.1.1.252 \
--upscript=/usr/local/sbin/vip-up.sh --downscript=/usr/local/sbin/vip-down.sh
A machine with a real IP of 192.168.1.19 is the preferred master for a virtual IP of 10.1.12.7, broadcasts are sent every 5 seconds.
ucarp -b 5 -s 192.168.1.19 -v 27 -p badpass -a 10.1.12.7 \
-u /usr/local/sbin/vip-up.sh -d /usr/local/sbin/vip-down.sh -z
The hot standby with an IP of 192.168.1.20 uses the following command, (note the advskew of 50 putting it at a disadvantage and making the first machine preferred).
ucarp -b 5 -k 50 -s 192.168.1.20 -v 27 -p badpass -a 10.1.12.7 \
-u /usr/local/sbin/vip-up.sh -d /usr/local/sbin/vip-down.sh -z
Signals
Sending the ucarp process a SIGUSR1 will have it log a status line to syslog, eg "Sep 13 12:59:56 localhost ucarp[2654]: [INFO] MASTER on eth0 id 1" or "Sep 13 13:00:25 localhost ucarp[2644]: [INFO] BACKUP on eth0 id 1"
Sending the ucarp process a SIGUSR2 will cause it to demote itself from master to backup, pause 3 seconds, then proceed as usual to listen for other masters, and promote itself if necessary. This could be useful if you wish another node to take over master.
History
- Arch Linux 2026-11-01: the text shown here
- Debian 13 (Trixie) to Debian 12 (Bookworm)
- Debian 10 (Buster) to Debian 9 (Stretch)
- Debian 8 (Jessie)
- Debian 7 (Wheezy)
- Debian 6.0 (Squeeze)
- Debian 5.0 (Lenny)
- Debian 4.0 (Etch)
- Debian 3.1 (Sarge)
--ignoreifstate since Debian 5.0 (Lenny);
--neutral since Debian 4.0 (Etch);
--nomcast since Debian 6.0 (Squeeze);
-M since Debian 6.0 (Squeeze);
-S since Debian 5.0 (Lenny);
-n since Debian 4.0 (Etch).
--addr until Debian 13 (Trixie);
--advbase until Debian 13 (Trixie);
--advskew until Debian 13 (Trixie);
--deadratio until Debian 13 (Trixie);
--debug until Debian 13 (Trixie);
--downscript until Debian 13 (Trixie);
--interface until Debian 13 (Trixie);
--mcast until Debian 13 (Trixie);
--pass until Debian 13 (Trixie);
--passfile until Debian 13 (Trixie);
--srcip until Debian 13 (Trixie);
--vhid until Debian 13 (Trixie);
--xparam until Debian 13 (Trixie);
-D until Debian 13 (Trixie);
-a until Debian 13 (Trixie);
-b until Debian 13 (Trixie);
-d until Debian 13 (Trixie);
-i until Debian 13 (Trixie);
-k until Debian 13 (Trixie);
-m until Debian 13 (Trixie);
-o until Debian 13 (Trixie);
-p until Debian 13 (Trixie);
-r until Debian 13 (Trixie);
-s until Debian 13 (Trixie);
-v until Debian 13 (Trixie);
-x until Debian 13 (Trixie).