ucarp(8)
π ucarp(8) β automatic IP failover π
okay bestie, sit down, hydrate, because we're about to talk about ucarp, and it's genuinely one of the most iconic little tools in the failover game. no cap. it lives in section 8 of the manual, it's the Automatic IP failover girlie, and she's about to eat. π
β¨ NAME β¨
ucarp β automatic IP failover π
π SYNOPSIS π
ucarp [-i, --interface=INTERFACE] [-s, --srcip=IPADDRESS]
[-m, --mcast=<ip>] [-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] [-D, --debug] [-z, --shutdown] [-B, --daemonize]
[-f, --facility=FACILITY] [-x, --xparam PARAM] [-S, --ignoreifstate]
[-M, --nomcast]
π¦ DESCRIPTION π¦
so basically, ucarp lets a pair of hosts share common IP addresses, which means an address can automatically fail over from one machine to the other. it's giving "if one of us goes down, the other one steps up" energy, and honestly? iconic. π
it's a portable userland implementation of the secure and patent-free Common Address Redundancy Protocol, aka CARP β which is OpenBSD's alternative to VRRP. no patents, no drama, just vibes. β¨
β οΈ Warning: Maximum length of the password used must be 20 characters. that's the limit, bestie, do not test her. π
π OPTIONS π
-i INTERFACE,--interface=INTERFACEβ the network interface you're binding to. that's your home base. π-s IPADDRESS,--srcip=IPADDRESSβ the persistent source address (the real IP) that goes with this interface. the genuine article. π-m IPADDRESS,--mcast=IPADDRESSβ the multicast group IP address. defaults to224.0.0.18. π«Ά-v VHID,--vhid=VHIDβ the id of the virtual server, and it's gotta be in the range [1-255]. β¨-p PASSWORD,--pass=PASSWORDβ the shared password. it gets encrypted, so it is not sent in the clear. we love a secure queen. π-o PASSFILE,--passfile=PASSFILEβ file to read the shared password from. the file should have the password on its first line, periodt.-P,--preemptβ turn on preemptive failover. this makes an instance ofucarpassume master status right immediately. main character energy, immediately. π-n,--neutralβ do not run the downscript on startup when the initial state is backup. she's staying neutral, she's minding her business. π§-a IPADDRESS,--addr=IPADDRESSβ the IP address of the virtual server. the shared one. the moment. β-h,--helpβ display a brief summary of the command line options. for when you're lost bestie, no shame. π-b SECONDS,--advbase=SECONDSβ interval in seconds that advertisements will occur. defaults to 1 second. ticking like a clock. β°-k SKEW,--advskew=SKEWβ advertisement skew, range [1-255], defaults to 0. yes, skew. she's a little off and that's the point. π-u COMMAND,--upscript=COMMANDβ specifies the command to run afterucarphas successfully become master. the interface name gets passed as an argument. typically it's a script used to bring up the virtual address, log the result, add routes, clear arp cache entries, etc. the glow-up script. πΈ-d COMMAND,--downscript=COMMANDβ specifies the command that is run afterucarphas 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. the graceful exit. π-r RATIO,--deadratio=RATIOβ the ratio the backup uses to figure out how long to wait for an unresponsive master before considering it dead. not me judging from afar. π-D,--debugβ enable debug output. turn the lights on. π₯-z,--shutdownβ using this command causes the command specified by the-dargument to be invoked whenucarpshuts down. clean exits only. β¨-B,--daemonizeβ causesucarpto detach from the terminal and run in the background as a daemon. she's independent, she doesn't need you watching. π¦-f,--facility=FACILITYβ set the syslog facility. defaults todaemon. π-x,--xparam=PARAMETERβ specify an extra parameter to be supplied to the up/down scripts. a lil something extra. π-S,--ignoreifstateβ ignore unplugged network cables. this option is useful whenucarpnodes 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. old school, still valid. π
π§ 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=/etc/vip-up.sh --downscript=/etc/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=/etc/vip-up.sh --downscript=/etc/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 /etc/vip-up.sh -d /etc/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 /etc/vip-up.sh -d /etc/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. like handing over the aux cord, respectfully. π§
π AUTHOR π
Written by Frank Denis <j@pureftpd.org>. π
This manual page was written by Guilherme de Paula Xavier Segundo <guilherme.lnx@gmail.com> and Eric Evans <eevans@debian.org> for the Debian project (but may be used by others). π«Ά
and that's the whole page, bestie!! this was ucarp-1.5.2+git20192404.1a9aaf7, dated 08 Jan 2023, and she ate. no crumbs. mwah. π
β¨π
π¦ where this page comes from
- debian bookworm: ucarp 1.5.2+git20192404.1a9aaf7-1 Β· MIT
- debian trixie: ucarp 1.5.2+git20192404.1a9aaf7-1+b1 Β· MIT
- ubuntu noble: ucarp 1.5.2+git20192404.1a9aaf7-1build2 Β· MIT
- ubuntu questing: ucarp 1.5.2+git20192404.1a9aaf7-1build2
- ubuntu resolute: ucarp 1.5.2+git20192404.1a9aaf7-1build3 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms