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 to LOG_LOCAL[0-7], LOG_USER or LOG_DAEMON. The default syslog facility is LOG_DAEMON.
  • -g, --log-file=FILE β€” write log entries to FILE. Here's the cute detail: FILE will have _vrrp, _healthcheckers, and _bfd inserted before the last . in FILE for the log output for those processes. It's giving organized. ✨
  • --flush-log-file β€” if you're using the -g option, 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 -g option 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 when keepalived exits.
  • -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 when keepalived exits.
  • -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 cause keepalived to run in the foreground. Main character stays visible. πŸ‘‘
  • -d, --dump-conf β€” dump the configuration data.
  • -p, --pid=FILE β€” use the specified pidfile for the parent keepalived process. The default pidfile for keepalived is /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 β€” enter genhash utility mode. Previous versions of keepalived were shipped with a dedicated genhash utility. genhash is now part of the mainline code. We keep compatibility with previous genhash utility command line option. For more information please refer to the genhash(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.pid unless 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.pid unless a network namespace is being used.
  • -s, --namespace=NAME β€” run keepalived in network namespace NAME. 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 id ID, 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 man umask(2).
  • -m, --core-dump β€” override the RLIMIT_CORE hard and soft limits to enable keepalived to produce a coredump in the event of a segfault or other failure. This is most useful if keepalived has been built with 'make debug'. Core dumps will be created in /, unless keepalived is run with the --dont-fork option, in which case they will be created in the directory from which keepalived was 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_pattern to the pattern specified, or 'core' if none specified. Provided the parent process doesn't terminate abnormally, it will restore /proc/sys/kernel/core_pattern to 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 for STOP, RELOAD, DATA, STATS, STATS_CLEAR, JSON and TDATA. For example, to stop keepalived running, execute:
kill -s $(keepalived --signum=STOP) $(cat /run/keepalived.pid)
  • -t, --config-test[=FILE] β€” keepalived will check the configuration file and exit with non-zero exit status if there are errors in the configuration, otherwise it exits with exit status 0 (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 β€” disable malloc() etc mem-checks if they have been compiled into keepalived.
  • --ignore-sigint β€” disable SIGINT handling (defaults to terminating keepalived). This is needed for running keepalived under GDB. GDB girlies, this one's for you. 🫢
  • --debug[=debug-options]] β€” enables debug options if they have been compiled into keepalived. debug-options is made up of a sequence of strings of the form Ulll.

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 process
  • b β€” BFD process
  • c β€” Checker process
  • v β€” VRRP process

The characters used to identify the debug options are:

  • D β€” Epoll thread dump
  • E β€” Epoll debug
  • F β€” VRRP fd debug
  • N β€” Netlink timers
  • P β€” Network timestamp
  • X β€” Regex timers
  • M β€” Email alert debug
  • T β€” Timer debug
  • S β€” TSM debug
  • R β€” Regex debug
  • B β€” Smtp connect debug
  • U β€” Checksum diagnostics
  • O β€” Track process debug
  • A β€” Track process debug with extra detail
  • C β€” Parser (config) debug
  • H β€” Checker debug
  • Z β€” Memory alloc/free error debug
  • G β€” VRRP recvmsg() debug
  • J β€” VRRP recvmsg() log rx data
  • V β€” Script debugging
  • K β€” 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 memory
  • 2 β€” if cannot initialise subsystems
  • 3 β€” if running with --config-test and configuration cannot be run
  • 4 β€” if running with --config-test and there are configuration errors but keepalived will run after modifying the configuration
  • 5 β€” if running with --config-test and 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. πŸ™ˆ


  • HUP or SIGFUNC=RELOAD β€” this makes keepalived close down all its interfaces, reload its configuration, and start up fresh with the new config. Slay. πŸ’…
⚠️ Note: if a virtual_ipaddress, virtual_route or virtual_rule is 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, INT or SIGFUNC=STOP β€” keepalived will shut down. bye bestie πŸ‘‹
  • USR1 or SIGFUNC=DATA β€” write configuration data to /tmp/keepalived.data or to the file configured by state_dump_file. πŸ“
  • USR2 or SIGFUNC=STATS β€” write statistics info to /tmp/keepalived.stats or to the file configured by stats_dump_file. πŸ“Š
  • SIGFUNC=STATS_CLEAR β€” write statistics info to /tmp/keepalived.stats or to the file configured by stats_dump_file, and clear the statistics counters. fresh start era ✨
  • SIGFUNC=JSON β€” write configuration data in JSON format to /tmp/keepalived.json or to the file configured by json_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 πŸ’…βœ¨