Keepalived

A routing software written in C which provide a simple and robust facilities for load balancing and high-availability to Linux system and Linux based infrastructures.

Prerequisite

  • Linux servers (for MASTER & BACKUP)

Installation

sudo apt install keepalived libipset13 -y

Configuration

Paste into /etc/keepalived/keepalived.conf:

MASTER

vrrp_instance VI_01 {
    state MASTER
    interface ens160
    virtual_router_id 55
    priority 150
    advert_int 1
    unicast_src_ip 192.168.1.51
    unicast_peer {
        192.168.1.52
    }
    authentication {
        auth_type PASS
        auth_pass Changeme
    }
    virtual_ipaddress {
        192.168.1.100/24
    }
}

BACKUP

vrrp_instance VI_01 {
    state BACKUP
    interface ens160
    virtual_router_id 55
    priority 100
    advert_int 1
    unicast_src_ip 192.168.1.52
    unicast_peer {
        192.168.1.51
    }
    authentication {
        auth_type PASS
        auth_pass Changeme
    }
    virtual_ipaddress {
        192.168.1.100/24
    }
}

Modify the unicast_src_ip, unicast_peer, auth_pass and virtual_ipaddress according to your usage. Save the file and start and enable start on boot.

sudo systemctl start keepalived
sudo systemctl enable --now keepalived

On client side, use the virtual_ipaddress to access the service.

Last updated