MCPcopy Index your code
hub / github.com/acassen/keepalived

github.com/acassen/keepalived @v2.4.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v2.4.1 ↗ · + Follow
3,004 symbols 9,120 edges 204 files 560 documented · 19%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Keepalived

Load balancing & high availability for Linux

Keepalived CI CodeQL Snap Status License: GPL v2+ GitHub Sponsor Follow on X

Website · Documentation · Download · Quick Start · Community

Keepalived is a routing software written in C. It brings simple and robust load balancing and high availability to Linux systems and Linux based infrastructures, and it runs in production across data centers, ISPs and hardware vendors worldwide.

What is Keepalived?

Keepalived builds load balancing on top of the well known Linux Virtual Server (IPVS) kernel module, which delivers Layer 4 load balancing. On top of IPVS, Keepalived runs a set of health checkers that watch each server pool and decide, in real time, whether a real server stays in the topology or drops out according to its health.

High availability comes from the VRRP protocol, the fundamental brick for router failover. Keepalived adds a set of hooks to the VRRP finite state machine so it can react with low level, high speed protocol interactions. To detect network failures as fast as possible it also implements BFD, and a VRRP state transition can take a BFD hint into account to drive a fast failover.

Each framework works on its own or together with the others, so you can build exactly the resilient infrastructure you need.

Three frameworks, one daemon

:shield: High availability (VRRP) :balance_scale: Load balancing (LVS/IPVS) :heartpulse: Health checking & BFD
A full implementation of VRRP v2 and v3 for IPv4 and IPv6, with sync groups that keep routing paths consistent after a takeover, plus IPSEC-AH securing of protocol adverts. Layer 4 load balancing driven by the kernel IPVS module, configured and maintained from a single place, with several scheduling algorithms and forwarding methods. Layer 4 to Layer 7 checkers add and remove real servers automatically, while BFD detects link and peer failures in milliseconds to trigger fast VRRP transitions.

Keepalived is articulated around a central I/O multiplexer that drives a strong multi threaded framework, and every event runs through this multiplexer. For robustness the daemon splits into a minimalistic parent process that monitors its children, while dedicated child processes run the VRRP, health checking and BFD stacks. The Software Design page covers the internals in detail.

Quick start

Most Linux distributions ship Keepalived as a mainline package, which is the quickest path to a working install:

sudo apt install keepalived     # Debian / Ubuntu
sudo dnf install keepalived     # RHEL / Fedora / Rocky

A minimal floating IP that fails over between two nodes needs a single file, /etc/keepalived/keepalived.conf. On the master:

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 150
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass changeme
    }
    virtual_ipaddress {
        192.168.1.100/24
    }
}

On the backup use the same file, but set state BACKUP and a lower priority. The node with the highest priority becomes master and carries the address.

[!NOTE] The virtual_router_id must be identical on both nodes and unique among the VRRP routers on the LAN. Change auth_pass to your own value, and remember it travels in clear text, so VRRP authentication only guards against misconfiguration, not against an attacker on the wire.

Start the service on both hosts:

sudo systemctl enable --now keepalived

The full Quick Start goes further and adds a load balanced service behind the floating IP.

Building from source

git clone https://github.com/acassen/keepalived.git
cd keepalived
./configure
make && sudo make install

Building from the git tree needs autoconf, automake and a few libraries. The INSTALL file lists what to install per distribution and what to run before building.

Documentation

The full documentation lives at keepalived.org:

Community

The Keepalived Users Group is the place to ask questions, share configurations and follow announcements. Report bugs and propose features on the issue tracker, and include a minimal configuration that reproduces the problem. Release announcements are posted on the Keepalived account on X.

[!IMPORTANT] AI tools are welcome, yet the core team keeps the code base small, clear and auditable. Large machine generated patches, comments or reports will not be read. Keep your work lean whether or not an AI helped, and read the Using AI tools guidance first.

License

Keepalived is free software, Copyright (C) 2000-2026 Alexandre Cassen. You can redistribute it and modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or any later version. See the COPYING file for the full terms.

OpenSSL toolkit licence exception

In addition, as the copyright holder of Keepalived, I, Alexandre Cassen, <acassen@linux-vs.org>, grant the following special exception:

I, Alexandre Cassen, <acassen@gmail.com>, explicitly allow the compilation and distribution of the Keepalived software with the OpenSSL Toolkit.

Core symbols most depended-on inside this repo

log_message
called by 1159
lib/logger.c
report_config_error
called by 847
lib/parser.c
strvec_slot
called by 664
lib/vector.c
conf_write
called by 633
lib/logger.c
install_keyword
called by 354
lib/parser.c
list_empty
called by 192
lib/list_head.h
register_thread_address
called by 102
lib/scheduler.c
list_add_tail
called by 86
lib/list_head.h

Shape

Function 2,411
Class 523
Enum 63
Method 7

Languages

C89%
C++10%
Python1%

Modules by API surface

keepalived/core/global_parser.c157 symbols
keepalived/vrrp/vrrp_parser.c140 symbols
lib/parser.c102 symbols
lib/scheduler.c98 symbols
keepalived/vrrp/vrrp.c90 symbols
keepalived/vrrp/vrrp_snmp.c79 symbols
keepalived/core/keepalived_netlink.c71 symbols
keepalived/vrrp/vrrp_data.c70 symbols
lib/utils.c63 symbols
keepalived/check/check_parser.c62 symbols
keepalived/check/libipvs.c59 symbols
keepalived/bfd/bfd_scheduler.c59 symbols

For agents

$ claude mcp add keepalived \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact