KEEPALIVED(8)
π NAME π
keepalived β the load-balancing and high-availability service, bestie. This is the System Manager's Manual page, section 8, and she is THAT girl. π
β¨ SYNOPSIS β¨
keepalived [-f|--use-file=FILE] [-P|--vrrp] [-C|--check] [-B|--no_bfd]
[--all] [-l|--log-console] [-D|--log-detail]
[-S|--log-facility={0-7|local{0-7}|user|daemon}] [-g|--log-file=FILE]
[--flush-log-file] [-G|--no-syslog] [-X|--release-vips]
[-V|--dont-release-vrrp] [-I|--dont-release-ipvs] [-R|--dont-respawn]
[-n|--dont-fork] [-d|--dump-conf] [-p|--pid=FILE] [-r|--vrrp_pid=FILE]
[-T|--genhash] [-c|--checkers_pid=FILE] [-a|--address-monitoring]
[-b|--bfd_pid=FILE] [-s|--namespace=NAME] [-e|--all-config]
[-i|--config-id id] [-x|--snmp] [-A|--snmp-agent-socket=FILE]
[-u|--umask=NUMBER] [-m|--core-dump] [-M|--core-dump-pattern[=PATTERN]]
[--signum=SIGFUNC] [-t|--config-test[=FILE]] [--perf[={all|run|end}]]
[--debug[=debug-options]] [--no-mem-check] [--ignore-sigint]
[-v|--version] [-h|--help]
Like, yes, that's a lot of flags. She's high-maintenance and we love that for her. π«Ά
πΈ DESCRIPTION πΈ
So, keepalived hands you simple and robust facilities for load-balancing and high-availability. No cap.
The load-balancing framework? It rides on the well-known and widely used Linux Virtual Server (IPVS) kernel module, which is out here doing Layer4 load-balancing. Queen behavior.
Then keepalived implements a whole set of checkers to dynamically and adaptively maintain and manage a load-balanced server pool according to their health. Vibe check, but for servers. π
And on top of that, keepalived implements the VRRPv2 and VRRPv3 protocols to achieve high-availability with director failover. Periodt.
π OPTIONS π
Okay so here's the whole menu, bestie. Every single one. Buckle up. π
-f,--use-file=FILEβ use the configuration file you specify. The default configuration file is/etc/keepalived/keepalived.conf.-P,--vrrpβ only run the VRRP subsystem. Obsessed with this one if your configs don't use the IPVS load balancer.-C,--checkβ only run the healthcheck subsystem. Perfect when you're using the IPVS load balancer with a single director and there's no failover happening.-B,--no_bfdβ don't run the BFD subsystem. Not today. π--allβ run all the subsystems, even if they have no configuration. All of them. Every one.-l,--log-consoleβ log messages to the local console. The default behavior is to log messages to syslog.-D,--log-detailβ detailed log messages. Give me the lore.-S,--log-facility={0-7|local{0-7}|user|daemon}β set the syslog facility toLOG_LOCAL[0-7],LOG_USERorLOG_DAEMON. The default syslog facility isLOG_DAEMON.-g,--log-file=FILEβ write log entries toFILE. Here's the cute detail:FILEwill have_vrrp,_healthcheckers, and_bfdinserted before the last.inFILEfor the log output for those processes. It's giving organized. β¨--flush-log-fileβ if you're using the-goption, the log file stream will be flushed after each write. Every. Single. Write.-G,--no-syslogβ do not write log entries to syslog. This can be useful if the rate of writing log entries is sufficiently high that syslog will rate limit them, and the-goption is used instead. Basically: syslog said "too much", so you go direct. π-X,--release-vipsβ drop VIP on transition from signal.-V,--dont-release-vrrpβ don't remove VRRP VIPs and VROUTEs on daemon stop. The default behavior is to remove all VIPs and VROUTEs whenkeepalivedexits.-I,--dont-release-ipvsβ don't remove IPVS topology on daemon stop. The default behavior it to remove all entries from the IPVS virtual server table whenkeepalivedexits.-R,--dont-respawnβ don't respawn child processes. The default behavior is to restart the VRRP and checker processes if either process exits.-n,--dont-forkβ don't fork the daemon process. This option will causekeepalivedto run in the foreground. Main character stays visible. π-d,--dump-confβ dump the configuration data.-p,--pid=FILEβ use the specified pidfile for the parentkeepalivedprocess. The default pidfile forkeepalivedis/run/keepalived.pid, unless a network namespace is being used. See NAMESPACES below for more details.-r,--vrrp_pid=FILEβ use the specified pidfile for the VRRP child process. The default pidfile for the VRRP child process is/run/keepalived_vrrp.pid, unless a network namespace is being used.-T,--genhashβ entergenhashutility mode. Previous versions ofkeepalivedwere shipped with a dedicatedgenhashutility.genhashis now part of the mainline code. We keep compatibility with previousgenhashutility command line option. For more information please refer to thegenhash(1)manpage.-c,--checkers_pid=FILEβ use the specified pidfile for checkers child process. The default pidfile for the checker child process is/run/keepalived_checkers.pidunless a network namespace is being used.-a,--address-monitoringβ log all address additions/deletions reported by netlink. All of them. We're watching. π-b,--bfd_pid=FILEβ use the specified pidfile for the BFD child process. The default pidfile for the BFD child process is/run/keepalived_bfd.pidunless a network namespace is being used.-s,--namespace=NAMEβ runkeepalivedin network namespaceNAME. See NAMESPACES below for more details.-e,--all-configβ don't load if any configuration file is missing or cannot be read. If even one is missing, it's a no. π«-i,--config-id IDβ use configuration idID, for conditional configuration (defaults to hostname without the domain name).-x,--snmpβ enable the SNMP subsystem.-A,--snmp-agent-socket=FILEβ use the specified socket for connection to SNMP master agent.-u,--umask=NUMBERβ the umask specified in the usual numeric way β see manumask(2).-m,--core-dumpβ override theRLIMIT_COREhard and soft limits to enablekeepalivedto produce a coredump in the event of a segfault or other failure. This is most useful ifkeepalivedhas been built with'make debug'. Core dumps will be created in/, unlesskeepalivedis run with the--dont-forkoption, in which case they will be created in the directory from whichkeepalivedwas run, or they will be created in the directory of a configuraton file if the fault occurs while reading the file.-M,--core-dump-pattern[=PATTERN]β sets option--core-dump, and also updates/proc/sys/kernel/core_patternto the pattern specified, or'core'if none specified. Provided the parent process doesn't terminate abnormally, it will restore/proc/sys/kernel/core_patternto its original value on exit.
β οΈ Note: this will also affect any other process producing a core dump while keepalived is running. She's not just touching her own stuff, bestie. Be aware. π
--signum=PATTERNβ returns the signal number to use forSTOP,RELOAD,DATA,STATS,STATS_CLEAR,JSONandTDATA. For example, to stopkeepalivedrunning, execute:
kill -s $(keepalived --signum=STOP) $(cat /run/keepalived.pid)
-t,--config-test[=FILE]βkeepalivedwill check the configuration file and exit with non-zero exit status if there are errors in the configuration, otherwise it exits with exit status0(see Exit status below for details).
Rather that writing to syslog, it will write diagnostic messages to stderr unless file is specified, in which case it will write to the file.
--perf[={all|run|end}]β record perf data for the vrrp process. Data will be written to/perf_vrrp.data. The data recorded is for use with the perf tool.--no-mem-checkβ disablemalloc()etc mem-checks if they have been compiled intokeepalived.--ignore-sigintβ disableSIGINThandling (defaults to terminatingkeepalived). This is needed for runningkeepalivedunder GDB. GDB girlies, this one's for you. π«Ά--debug[=debug-options]]β enables debug options if they have been compiled intokeepalived.debug-optionsis made up of a sequence of strings of the formUlll.
The upper case letter specifies the debug option, and the lower case letters specify for which processes the option is to be enabled.
If a debug option is not followed by any lower case letters, the debug option is enabled for all processes.
The characters to identify the processes are:
pβ Parent processbβ BFD processcβ Checker processvβ VRRP process
The characters used to identify the debug options are:
Dβ Epoll thread dumpEβ Epoll debugFβ VRRP fd debugNβ Netlink timersPβ Network timestampXβ Regex timersMβ Email alert debugTβ Timer debugSβ TSM debugRβ Regex debugBβ Smtp connect debugUβ Checksum diagnosticsOβ Track process debugAβ Track process debug with extra detailCβ Parser (config) debugHβ Checker debugZβ Memory alloc/free error debugGβ VRRPrecvmsg()debugJβ VRRPrecvmsg()log rx dataVβ Script debuggingKβ Dump keywords
Example: --debug=DvEcvNR
-v,--versionβ display the version and exit.-h,--helpβ display this help message and exit.
π₯ Exit status π₯
Because knowing why it bailed is the whole point:
0β if OK β¨1β if unable to malloc memory2β if cannot initialise subsystems3β if running with--config-testand configuration cannot be run4β if running with--config-testand there are configuration errors butkeepalivedwill run after modifying the configuration5β if running with--config-testand script security hasn't been enabled but scripts are configured.
π¦ NAMESPACES π¦
So keepalived can be run in a network namespace (see keepalived.conf(5) for configuration details). When run in a network namespace, a local mount namespace is also created, and /run/keepalived/keepalived_NamespaceName is mounted on /run/keepalived.
By default, pid files with the usual default names are then created in /run/keepalived from the perspective of a process in the mount namespace, and they will be visible in /run/keepalived/keepalived_NamespaceName for a process running in the default mount namespace. It's giving nested realities, iykyk. π
π SIGNALS π
okay bestie so keepalived reacts to a whole set of signals. You can yeet a signal at the parent keepalived process like this:
kill -SIGNAL $(cat /run/keepalived.pid)
or, lowkey the better way:
kill -s $(keepalived --signum=SIGFUNC) $(cat /run/keepalived.pid)
heads up though β if you go with the first option, you gotta swap out -SIGNAL for the actual signal you're trying to send, like HUP. So it turns into this:
kill -HUP $(cat /run/keepalived.pid)
β¨ Important vibe check: signals other than for STOP, RELOAD, DATA and STATS may change depending on the kernel, and also on what functionality got included in your build of keepalived based on the build options used. So like, ymmv bestie. π
HUPorSIGFUNC=RELOADβ this makes keepalived close down all its interfaces, reload its configuration, and start up fresh with the new config. Slay. π
β οΈ Note: if avirtual_ipaddress,virtual_routeorvirtual_ruleis being moved from one VRRP instance to another one, you're gonna need two reloads β the first one to remove the virtual ipaddress/route/rule, and the second reload to add it to the VRRP instance it's now supposed to be configured on. If you skip this, the ipaddress/route/rule might not get configured on the new instance at all when both the old and new instances are in master state. π Note2: usually it works fine with a single reload, though, if either of the VRRP instances isn't in MASTER state, or if the VRRP instance the ipaddress/route/rule is being added to comes later in the original configuration file than the instance it's being removed from. π«Ά Note3 (real one): if a configuration is running with SNMP enabled, and then you do a reload with a configuration that does not enable SNMP, it is not possible to subsequently re-enable SNMP. The reason for this is not currently understood. (genuinely nobody knows, it's giving mystery π)
TERM,INTorSIGFUNC=STOPβ keepalived will shut down. bye bestie πUSR1orSIGFUNC=DATAβ write configuration data to/tmp/keepalived.dataor to the file configured bystate_dump_file. πUSR2orSIGFUNC=STATSβ write statistics info to/tmp/keepalived.statsor to the file configured bystats_dump_file. πSIGFUNC=STATS_CLEARβ write statistics info to/tmp/keepalived.statsor to the file configured bystats_dump_file, and clear the statistics counters. fresh start era β¨SIGFUNC=JSONβ write configuration data in JSON format to/tmp/keepalived.jsonor to the file configured byjson_dump_file. π§SIGFUNC=TDATAβ this makes keepalived write the current state of its internal threads to the log. π§΅
π₯ USING KEEPALIVED WITH FIREWALLD π₯
If you're running a firewall (peep firewalld(8)) you must let VRRP protocol traffic through it. No exceptions bestie, the firewall will simply not let it through otherwise. π«
For example, if this instance of keepalived(8) has a peer node on IPv4 address 192.168.0.1:
# firewall-cmd \
--add-rich-rule="rule family='ipv4' \
source address='192.168.0.1' \
protocol value='vrrp' accept" --permanent
# firewall-cmd --reload
and that's the whole vibe. π
π SEE ALSO π
keepalived.conf(5), ipvsadm(8)
go read those too, they're part of the lore, iykyk π
π AUTHOR π
This man page was written by Ryan O'Hara <rohara@redhat.com> π«Ά
okay that's a wrap bestie!! this page is from the keepalived 2025-03-29 era, and you were reading KEEPALIVED(8) the whole time β iconic, no cap, periodt π
β¨
π¦ where this page comes from
- alpine 3.24: keepalived-doc 2.3.4-r2 Β· GPL-2.0-only
- arch rolling: keepalived 2.4.3-1 Β· GPL-2.0-or-later
- debian trixie: keepalived 1:2.3.3-1
- ubuntu questing: keepalived 1:2.3.3-1
- ubuntu resolute: keepalived 1:2.3.4-1
- ubuntu stonking: keepalived 1:2.3.4-1build2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms