How to Install Keepalived on Ubuntu 24.04

|
Published:
|
|
install keepalived on ubuntu 24.04

What is the easiest way to install Keepalived on Ubuntu 24.04? In this tutorial, we will cover different ways you can use to install Keepalived on Ubuntu systems. Keepalived is an open-source routing software primarily used for implementing high availability and load balancing in Linux-based systems.

Installing Keepalived on Ubuntu 24.04

There are different ways in which you can install Keepalived on Ubuntu.

  1. Install Keepalived from default Ubuntu repositories
  2. Install Keepalived from Snap Store
  3. Build and Install Keepalived from Source Code

Install Keepalived from Default Ubuntu repositories

The default Ubuntu repositories usually provides Keepalived packages. As much as this is usually an easy method to install a package on an Ubuntu system, the available packages may not always be up-to-date.

For example, the current Keepalived v2.3.1 is the current stable release version as per the release notes page.

But the available version on the default Ubuntu 24.04 repositories is v2.2.8;

sudo apt update

Confirm available version;

apt-cache madison keepalived
keepalived | 1:2.2.8-1build2 | http://de.archive.ubuntu.com/ubuntu noble/main amd64 Packages

As you can see, available version is not up-to-date.

If you want to install the available version on the default Ubuntu repositories, just execute the command below;

sudo apt install keepalived

Install Keepalived from Snap Store

Keepalived is available as a Snap package on the Snap Store. Snaps are containerized software packages that include all the dependencies needed to run an application, providing a consistent and reliable installation experience across different Linux distributions.

Latest versions of Ubuntu, including Ubuntu 24.04 ship with Snapd installed and enabled.

You can check if Snapd is installed by running:

snap --version
snap    2.62+24.04build1
snapd   2.62+24.04build1
series  16
ubuntu  24.04
kernel  6.8.0-31-generic

Check available version of Keepalived on Snap store;

snap info keepalived

Sample output;

...
channels:
  latest/stable:    2.3.1              2024-05-24 (2751) 21MB classic
  latest/candidate: 2.3.1              2024-05-24 (2751) 21MB classic
  latest/beta:      2.3.1              2024-05-24 (2751) 21MB classic
  latest/edge:      v2.3.1-8-g379faa51 2024-06-03 (2761) 21MB classic

As you can see, Snap store provides the latest release version as of this writing.

Thus, to install Keepalived from snap store;

sudo snap install keepalived --classic

Build and Install Keepalived from Source Code

It is also possible to build and install Keepalived from source code. If you really need to take this route, then proceed as follows.

Install Required Build Tools

Install the required build tools/packages;

sudo apt install curl gcc libssl-dev libnl-3-dev libnl-genl-3-dev libsnmp-dev make

Build and Install Keepalived

Next, download Keepalived source code.

Replace the value of VAR with the version of Keepalived you need to install

VER=2.3.1
wget https://www.keepalived.org/software/keepalived-${VER}.tar.gz

Extract and compile the package;

tar xzf keepalived-${VER}.tar.gz
cd keepalived-${VER}
./configure --with-systemdsystemunitdir=/etc/systemd/system/

Read more on;

./configure --help

Sample output;

...
Keepalived configuration
------------------------
Keepalived version       : 2.3.1
Compiler                 : gcc gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
Preprocessor flags       : -D_GNU_SOURCE
Compiler flags           : -g -g -O2 -Wall -Wextra -Wunused -Wstrict-prototypes -Wabsolute-value -Waddress-of-packed-member -Walloca -Walloc-zero -Warith-conversion -Warray-bounds=2 -Wattribute-alias=2 -Wbad-function-cast -Wc11-c2x-compat -Wcast-align -Wcast-qual -Wdate-time -Wdisabled-optimization -Wdouble-promotion -Wduplicated-branches -Wduplicated-cond -Wfloat-conversion -Wfloat-equal -Wformat-overflow -Wformat-security -Wformat-signedness -Wformat-truncation -Wframe-larger-than=5120 -Wimplicit-fallthrough=3 -Winit-self -Winline -Winvalid-pch -Wjump-misses-init -Wlogical-op -Wmissing-declarations -Wmissing-field-initializers -Wmissing-include-dirs -Wmissing-prototypes -Wnested-externs -Wnormalized -Wnull-dereference -Wold-style-definition -Woverlength-strings -Wpointer-arith -Wredundant-decls -Wshadow -Wshift-overflow=2 -Wstack-protector -Wstrict-overflow=4 -Wstringop-overflow=2 -Wstringop-truncation -Wsuggest-attribute=cold -Wsuggest-attribute=format -Wsuggest-attribute=malloc -Wsuggest-attribute=noreturn -Wsuggest-attribute=pure -Wsync-nand -Wtrampolines -Wundef -Wuninitialized -Wunknown-pragmas -Wunsafe-loop-optimizations -Wunsuffixed-float-constants -Wunused-const-variable=2 -Wvariadic-macros -Wwrite-strings -fno-strict-aliasing -fPIE -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -O2
Linker flags             : -pie -Wl,-z,relro -Wl,-z,now
Extra Lib                : -lm -lssl -lcrypto
Use IPVS Framework       : Yes
IPVS use libnl           : No
IPVS syncd attributes    : Yes
IPVS 64 bit stats        : Yes
HTTP_GET regex support   : No
fwmark socket support    : Yes
Use VRRP Framework       : Yes
Use VRRP VMAC            : Yes
Use VRRP authentication  : Yes
With track_process       : Yes
With linkbeat            : Yes
Use NetworkManager       : No
Use BFD Framework        : No
SNMP vrrp support        : No
SNMP checker support     : No
SNMP RFCv2 support       : No
SNMP RFCv3 support       : No
DBUS support             : No
Use JSON output          : No
libnl version            : None
Use IPv4 devconf         : Yes
Use iptables             : No
Use nftables             : No
init type                : systemd
systemd notify           : No
Strict config checks     : No
Build documentation      : No
Default runtime options  : -D

*** WARNING - this build will not support IPVS with IPv6. Please install libnl/libnl-3 dev libraries to support IPv6 with IPVS.

Compile and install Keepalived;

make
sudo make install

By default, make install will install all the files in /usr/local/bin, /usr/local/lib, /usr/local/etc/keepalived.

See where the keepalived binary is placed;

which keepalived 
/usr/local/sbin/keepalived

The configuration directory set to /usr/local/etc/keepalived/.

Similary, a Systemd service unit is created as /etc/systemd/system/keepalived.service.

Configuring Keepalived

Once the installation is done, you can now check our other guides on how to configure Keepalived to provide a VIP.

How to Configure Keepalived on Ubuntu

Conclusion

Keepalived is a valuable tool for ensuring high availability and load balancing in Linux environments. It offers a robust and flexible solution for maintaining service uptime and efficient resource utilization.

In this simple guide, you have learnt three different ways in which you can install Keepalived on Ubuntu.

  1. Install Keepalived from default Ubuntu repositories
  2. Install Keepalived from Snap Store
  3. Build and Install Keepalived from Source Code

SUPPORT US VIA A VIRTUAL CUP OF COFFEE

We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
Kifarunix
Linux Certified Engineer, with a passion for open-source technology and a strong understanding of Linux systems. With experience in system administration, troubleshooting, and automation, I am skilled in maintaining and optimizing Linux infrastructure.

Leave a Comment