Back to articles
Technology Insight

Achieving Uninterrupted Uptime: A Comprehensive Guide to High Availability VPS with Keepalived and Floating IP

May 27, 2026

Introduction to High Availability (HA) in Modern Infrastructure

In the digital-first economy, the availability of your services is directly tied to your brand's reputation and bottom line. A single point of failure (SPOF) in your server architecture can lead to significant disruptions. High Availability (HA) is a design approach that ensures a prearranged level of operational performance, usually uptime, for a higher than normal period. By utilizing Keepalived and Floating IP (also known as Reserved IP), engineers can create a seamless failover mechanism between Virtual Private Servers (VPS).

What is Keepalived?

Keepalived is a routing software written in C that provides strong and robust facilities for load balancing and high-availability to Linux-based infrastructures. It implements the Virtual Router Redundancy Protocol (VRRP) to allow two or more nodes to share a single IP address, ensuring that if the master node fails, a backup node takes over instantaneously.

The Role of Floating IP

A Floating IP is a static IP address that can be instantly redirected from one VPS to another within the same data center. Unlike standard DNS changes, which can take hours to propagate, a Floating IP re-assignment happens almost in real-time, making it the perfect tool for rapid failover scenarios.

Phase 1: Architecture Overview and Prerequisites

Before diving into the configuration, it is essential to understand the structural layout of our HA cluster. This setup requires:

  • Two VPS instances (Node A as 'Master' and Node B as 'Backup') located in the same region.
  • A Floating IP assigned to your account.
  • Private networking enabled between the nodes.
  • Root or sudo access to both servers.

The core logic is simple: Keepalived monitors the health of the Master node. If the service fails or the server goes offline, the Backup node detects the heartbeat loss and triggers an API call to re-assign the Floating IP to itself.

Phase 2: Initial System Preparation

Start by updating your system repositories and installing the necessary dependencies. On Ubuntu/Debian systems, execute the following:

sudo apt update && sudo apt install keepalived libipset13 -y

Repeat this process on both nodes. It is also recommended to install a web server like Nginx or Apache to test the failover visibility once the setup is complete.

Phase 3: Configuring Keepalived on the Master Node

The configuration file for Keepalived is located at /etc/keepalived/keepalived.conf. On the Master node, create a configuration that prioritizes its role in the cluster.

Sample Master Configuration

vrrp_script check_service {
  script "killall -0 nginx"
  interval 2
  weight 2
}

vrrp_instance VI_1 {
  state MASTER
  interface eth1
  virtual_router_id 51
  priority 101
  advert_int 1
  authentication {
    auth_type PASS
    auth_pass 12345
  }
  virtual_ipaddress {
    192.168.1.100
  }
  track_script {
    check_service
  }
}

In this configuration, priority 101 ensures this node stays the Master as long as it is healthy. The check_service script monitors the Nginx process every 2 seconds.

Phase 4: Configuring the Backup Node

The Backup node configuration is nearly identical, with two critical changes: the state becomes BACKUP and the priority is set lower (e.g., 100).

Sample Backup Configuration

vrrp_instance VI_1 {
  state BACKUP
  interface eth1
  virtual_router_id 51
  priority 100
  ...
}

When the Master's priority drops due to a script failure or the node goes offline, the Backup node will see that its priority of 100 is now the highest available and will assume the Master role.

Phase 5: Automating Floating IP Assignment

Keepalived handles the internal logic, but we need to tell our VPS provider to move the Floating IP. Most modern cloud providers (like DigitalOcean, Vultr, or Hetzner) provide a CLI tool or API for this. We use a notify script in Keepalived.

Create a script at /etc/keepalived/master.sh:

#!/bin/bash
# Trigger API to assign Floating IP to this Droplet/VPS
curl -X POST -H "Authorization: Bearer $API_TOKEN" "[https://api.provider.com/floating_ips/$IP/assign](https://api.provider.com/floating_ips/$IP/assign)"

Ensure the script is executable: chmod +x /etc/keepalived/master.sh. Add the notify_master /etc/keepalived/master.sh line to your keepalived.conf to automate the transition.

Phase 6: Testing and Validation

Reliability is only guaranteed through rigorous testing. To validate your HA setup, follow these steps:

  1. Initial Check: Ping the Floating IP and ensure it reaches the Master node.
  2. Simulate Failure: Stop the Nginx service on the Master node or shut down the server entirely.
  3. Observation: Monitor the Keepalived logs (tail -f /var/log/syslog). You should see the Backup node transition to the 'MASTER' state.
  4. Verification: Refresh your browser or run a curl command against the Floating IP. The traffic should now be served by the Backup node.

Best Practices for High Availability

Building the cluster is just the beginning. To maintain a truly High Availability environment, consider the following:

  • Database Synchronization: Ensure your data is replicated in real-time between nodes using tools like Galera Cluster or Master-Master replication.
  • Security: Secure the VRRP communication with strong passwords and restrict traffic on the private network using a firewall (UFW/IPTables).
  • Monitoring: Use external monitoring tools to alert your team whenever a failover occurs, as a failover might indicate underlying hardware issues on the primary node.

Conclusion

Setting up a High Availability VPS cluster with Keepalived and Floating IP provides a resilient foundation for any business-critical application. By eliminating single points of failure and automating the recovery process, you ensure that your services remain accessible to users regardless of localized server issues. While the initial setup requires careful configuration, the peace of mind and technical stability it provides are well worth the investment.

Achieving Uninterrupted Uptime: A Comprehensive Guide to High Availability VPS with Keepalived and Floating IP | DPTCloud