Interview Prep/Linux/Networking, SSH and remote access

A service must be reachable on a virtual IP that fails over between two Linux load balancers. How?

AdvancedScenarioNetworking, SSH and remote access
Answer

Situation read → VRRP with keepalived.

What I'd do → /etc/keepalived/keepalived.conf on the primary:

vrrp_script chk_haproxy {
    script "/usr/bin/systemctl is-active --quiet haproxy"
    interval 2
}
vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 150
    advert_int 1
    authentication { auth_type PASS auth_pass s3cr3t }
    virtual_ipaddress { 10.0.1.100/24 }
    track_script { chk_haproxy }
}

Backup node: state BACKUP, priority 100. Allow VRRP (protocol 112) in the firewall.

Why → If HAProxy dies, the priority drops and the VIP moves; neighbours learn the new MAC via gratuitous ARP.

Interview tip → In most clouds VRRP multicast doesn't work, so use the cloud LB or an API-driven failover.

All Linux questions Roadmap: Linux

More on Networking, SSH and remote access