Floating IP Setup for High Availability: Step-by-Step Guide

Floating IP setup is one of the simplest ways to cut downtime on a VPS or dedicated server. A floating IP is a public IP address that you can move from one server to another in seconds. If your main server fails, you move the address to a backup server. Visitors keep using the same address, and your site stays online.

This guide shows how floating IP setup works from start to finish. You will learn what a floating IP is, how it compares with a static IP, how to attach it to a server, how to add it to your network settings, and how to automate failover with Keepalived. We also cover testing, security, and common problems. The steps use plain language and example commands that you can adapt to your own servers.

Quick answer:

  • A floating IP is a public IP that you can move between servers in the same location.
  • Floating IP setup has four parts: get the IP, attach it to a server, add it to the server’s network settings, and test it.
  • For automatic failover, use two servers, a health check, and a tool such as Keepalived.
  • A floating IP sends traffic to one server at a time. It is not a load balancer.
  • Keep backups and monitoring in place. A floating IP does not protect your data.

What Is a Floating IP?

A floating IP is a public IP address that is not tied to one server for good. You can point it at server A today and server B tomorrow. Some providers call it a reserved IP, an elastic IP, a movable IP, or a failover IP. The idea is the same.

Think of it like a phone number that you can forward. People always dial the same number. You decide which phone rings.

Key Terms

  • Floating IP: the public address that your visitors and apps use.
  • Anchor IP: the main IP of the server that currently receives the traffic. Some providers use this term. Others simply say the IP is attached to a server.
  • Active server: the server that holds the floating IP right now.
  • Standby server: the backup that takes over when the active server fails.
  • Failover: the move of the floating IP from the failed server to the standby.

Where Floating IPs Are Used

Floating IPs fit VPS hosting, dedicated servers, and cloud setups. Most providers let you move them only inside one data center or region. Support also differs from provider to provider, so always check your plan first.

How a Floating IP Works

A floating IP works at the network level. Your provider’s network sends traffic for that address to one server. When you change the target, the network starts sending traffic to the new server.

Here is the normal flow:

  1. A visitor types your domain name. DNS returns the floating IP.
  2. The visitor’s request reaches your provider’s network.
  3. The network sends the request to the active server.
  4. The active server fails or goes into maintenance.
  5. You, or an automatic script, move the floating IP to the standby server.
  6. New requests go to the standby server. The visitor does not need to change anything.

Why It Is Faster Than a DNS Change

With a normal static IP, moving a site means changing DNS records. DNS changes can take minutes or even hours to spread, because many networks keep old answers in a cache. A floating IP move does not touch DNS. Your domain still points to the same address, so the switch is much quicker.

One Server at a Time

A floating IP sends traffic to one server at a time. Both servers can have the address in their settings, but only the server that the network points to receives traffic. That makes floating IPs a great fit for active/standby setups. To share traffic among many servers, you need a load balancer.

Benefits and Common Use Cases

Main Benefits

  • Less downtime. Move the IP in seconds when a server fails.
  • No DNS delay. Your domain keeps the same address.
  • Easy maintenance. Move traffic to a standby, patch the main server, then move it back.
  • Zero-downtime updates. Build a new version on a new server and switch the IP when it is ready.
  • A stable address. Keep the same IP when you replace or upgrade a server.
  • A simple design. It is easier to run than a large cluster.

Common Use Cases

  • Online stores. Keep checkout working during a server problem.
  • Databases. Point apps at a standby database after a failure, together with data replication.
  • Game servers. Players keep one address, even when you swap hardware.
  • Firewalls and proxies. Run a pair so that one can fail without losing the entry point.
  • Web apps and APIs. Release new versions with a quick switch and an easy way back.
  • Email and other services that depend on a fixed IP and a good sending reputation.

Floating IP vs Static IP vs Load Balancer

People often mix these up. This table shows the main differences.

FeatureFloating IPStatic IPLoad balancerDNS failover
Tied to one serverNoYesNoNo
Move speedSecondsNeeds a new IP and a DNS updateNot neededMinutes to hours (DNS cache)
Spreads trafficNo, one server at a timeNoYesLimited
Best forActive/standby failoverSimple, fixed serversMany servers, high trafficBasic backup
Cost and setupLow to mediumLowMedium to highLow

You can also combine them. For example, point a floating IP at a pair of load balancers. If one balancer fails, the other takes over, and your app servers keep working behind them.

Before You Start: Requirements and Planning

Check these items before you begin your floating IP setup.

  • Provider support. Not every VPS or dedicated plan includes floating IPs. Check your plan or ask your provider.
  • Two servers. You need at least one server. For failover, use two: one active and one standby.
  • The same location. Most providers only move a floating IP inside one data center or region. Keep both servers together.
  • Root or sudo access. You need it to change network settings.
  • Matching setups. The standby should run the same web server, app, and settings.
  • Firewall rules. Both servers must allow the ports your service uses, such as 80, 443, and 22.
  • A domain that points to the floating IP. Update your DNS A record once. After that, you rarely need to touch it. See our guide to DNS management.
  • Basic monitoring. You should know when a server goes down.

Plan Your Data

A floating IP moves traffic, not data. If your site uses a database or uploaded files, you need replication or shared storage so the standby has the same data. Without it, failover can send visitors to a server with old or missing information.

Floating IP Setup: Step by Step

The exact buttons differ by provider, but the steps are almost always the same. The example addresses below come from documentation ranges. Replace them with your own.

Step 1: Create or Request a Floating IP

Open your provider’s control panel and go to the IP or network section. Request a new floating IP. Choose the location that matches your servers. Some providers also let you convert an IP you already own, so ask support if that applies to you.

Step 2: Attach It to Your Active Server

Select the floating IP and attach it to your main server. Some providers ask you to pick an anchor IP, which is the server’s main address. This tells the network where to send traffic.

Step 3: Add the IP to the Server

Connect with SSH. Then find your network interface name:

ip -4 address show

Add the floating IP as an extra address. Use /32 as the mask. A /32 mask means the address stands alone and does not claim a whole network, which helps avoid routing conflicts. Replace eth0 with your interface name:

sudo ip address add 198.51.100.20/32 dev eth0

Some providers add the address for you. Others need this step. Check your provider’s notes.

Step 4: Make the Change Permanent

The command above is lost after a reboot. To keep the address, add it to your network files. On Ubuntu with Netplan, the file might look like this:

network:
  version: 2
  ethernets:
    eth0:
      addresses:
        - 203.0.113.10/24
        - 198.51.100.20/32

Then apply it:

sudo netplan apply

Other systems use different files, such as NetworkManager or ifupdown. Follow the guide for your operating system.

Step 5: Prepare the Standby Server

Install the same software and settings on the standby server. If your provider requires it, add the same floating IP to its network settings too. The provider’s panel or API decides which server receives the traffic.

Step 6: Check Your Firewall and App

Make sure your firewall allows traffic to the floating IP. Make sure your web server listens on all addresses, or on the floating IP as well. Do not hardcode one server’s own IP in your app settings.

Step 7: Point Your Domain

Update your domain’s A record to the floating IP. If you need to add more than one address to a single machine, our guide on configuring multiple IP addresses on a single server can help.

Step 8: Test It

Run these checks from your own computer, not from the server:

ping 198.51.100.20
curl -I http://198.51.100.20
ssh user@198.51.100.20

If ping, the web request, and SSH all work, the first part of your floating IP setup is done.

Automatic Failover with Keepalived

Moving a floating IP by hand works for planned maintenance. For real failures, you want automation. Keepalived is a popular Linux tool for this job. It uses VRRP, a protocol where servers check on each other and agree on which one is in charge. It can also run health checks and custom scripts.

How the Pieces Fit

  • Two servers run Keepalived.
  • One is the MASTER with a higher priority. The other is the BACKUP.
  • A health check script tests your service, such as Nginx.
  • If the master fails the check, it gives up its role, and the backup becomes master.
  • The new master runs a script that moves the floating IP to itself.

Two Ways to Move the IP

  1. Provider API. The new master calls your provider’s API to attach the floating IP to itself. This is common on VPS and cloud platforms.
  2. VRRP virtual IP. On a shared network where your provider allows it, Keepalived can add the address to the new master directly with the virtual_ipaddress setting.

Ask your provider which method it supports.

Example Configuration

Install Keepalived on both servers:

sudo apt install -y keepalived

Create a health check script at /etc/keepalived/chk_nginx.sh:

#!/bin/sh
/bin/pidof nginx

Make it executable:

sudo chmod +x /etc/keepalived/chk_nginx.sh

Main server config at /etc/keepalived/keepalived.conf:

vrrp_script chk_nginx {
    script /etc/keepalived/chk_nginx.sh
    interval 2
    fall 2
    rise 2
}

vrrp_instance WEB_HA {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 200
    advert_int 1
    unicast_src_ip 203.0.113.10
    unicast_peer {
        203.0.113.11
    }
    authentication {
        auth_type PASS
        auth_pass ChangeMe
    }
    track_script {
        chk_nginx
    }
    notify_master /etc/keepalived/notify_master.sh
}

On the standby server, use the same file with four changes: state BACKUP, priority 100, unicast_src_ip 203.0.113.11, and unicast_peer 203.0.113.10.

Failover script at /etc/keepalived/notify_master.sh:

#!/bin/sh
# Ask the provider API to attach the floating IP to THIS server.
# The URL, token, and fields below are placeholders. Use your provider's values.
curl --silent --request POST --header 'Authorization: Bearer YOUR_API_TOKEN' --data 'floating_ip=198.51.100.20&target=THIS_SERVER_ID' https://api.example-provider.test/floating-ips/attach

Make the script executable with chmod +x, then start Keepalived on both servers:

sudo systemctl enable --now keepalived
sudo systemctl status keepalived

Notes on This Setup

  • The virtual_router_id must match on both servers. Use a number from 1 to 255 that no other pair on your network uses.
  • VRRP password authentication only uses up to eight characters. Treat it as a light safeguard, not strong security.
  • Keep your API token in a file with tight permissions. Never place it in a public repository.
  • The fall and rise settings make Keepalived wait for two failed or two good checks before it acts. This avoids a switch caused by one slow response.
  • The scripts run with high privileges. Follow the Keepalived documentation for script security settings in your version.
  • Watch out for split brain. This happens when both servers believe they are master. A reliable link between the servers and a good health check lower the risk. Make sure your firewall allows VRRP traffic (IP protocol 112) between them.

How to Test Floating IP Failover

Never trust a failover setup that you have not tested. Run these tests before you go live, and repeat them every few months.

A Simple Test Plan

  1. Check the starting point. Confirm that the floating IP reaches the active server. Make the home page on each server print a different label, so you can tell them apart.
  2. Run a constant check. In a terminal, request the page once per second:
while true; do curl -s -m 2 http://198.51.100.20/ | head -n 1; sleep 1; done
  1. Break the active server. Stop the web service:
sudo systemctl stop nginx
  1. Watch the output. After a few seconds, the label should change to the standby server. Note how many requests failed.
  2. Check the logs. Confirm that the standby became master:
sudo journalctl -u keepalived --no-pager | tail -n 20
  1. Restore the first server. Start the web service again and see what happens. Decide whether the IP should move back on its own or stay on the new server.

Test Other Failures

  • Reboot the active server.
  • Shut down the active server completely.
  • Block the health check port with a firewall rule.
  • Break the link between the two servers, and watch for split brain.

What to Measure

Record how long failover takes, from the first failed request to the first good one. Also check that sessions, carts, and logins still work on the standby. If they do not, you may need shared session storage.

Floating IP Security and Best Practices

  • Use the same firewall rules on both servers. A gap on the standby is a gap in your whole setup.
  • Keep both servers equal. Use the same OS version, packages, and settings. Scripts or configuration tools help prevent drift.
  • Use health checks that test the real service. Checking that a process exists is a start. Checking that a page returns a good answer is better.
  • Protect API tokens. Give each token only the rights it needs. Store it safely and replace it from time to time.
  • Use each server’s own IP for admin work. SSH to the floating IP reaches whichever server is active, which can be confusing and can change the host key you see.
  • Sync your data. Use database replication, file sync, or shared storage so the standby is ready.
  • Monitor everything. Watch both servers, the floating IP, and Keepalived. Our article on how to monitor and track IP address usage is a good place to start.
  • Set reverse DNS if you send email. A matching PTR record helps mail delivery. See our guide to setting up reverse DNS.
  • Install the same SSL certificate on both servers. Then HTTPS keeps working after a switch. Learn more about SSL certificates.
  • Keep backups. A floating IP does not protect against deleted data, bugs, or ransomware. Keep off-site copies.
  • Write down the process. Record who can move the IP and what to do when failover happens.

Common Floating IP Problems and Fixes

ProblemLikely causeFix
Cannot ping the floating IPThe IP is not attached to the right server, or ICMP is blockedCheck the control panel and your firewall rules
SSH to the floating IP failsSSH is not running, or port 22 is blockedStart the SSH service and allow the port
Website does not loadThe web server is down or not listening on the IPCheck the service status and its listen settings
IP works until a rebootThe address was added by command onlyAdd it to your permanent network config
Failover does not happenThe health check never fails, or the script has no permissionTest the check by hand and fix file permissions
Both servers think they are masterThe servers cannot see each otherFix the link between them and allow VRRP in the firewall
IP will not attach across sitesFloating IPs usually stay inside one regionKeep both servers in the same data center or region
Old content after failoverThe standby has old data or a different configSync data and settings between the servers
Apps fail after failoverThe app uses a hardcoded server IPUse the domain name or the floating IP in settings

If a connection is refused, check the service and the firewall first. Most floating IP problems come from a blocked port or a missing network setting.

Build a Highly Available Setup with AvenaCloud

A good floating IP setup starts with solid servers and clear IP management. AvenaCloud offers VPS servers for flexible projects and dedicated servers for workloads that need full control and steady performance. You can also learn about IP address services to plan the addresses your project needs.

These guides can help with the next steps:

Floating IP support depends on the plan and location, so confirm the details before you build your design. If you are unsure which servers and IP options fit your project, contact AvenaCloud and describe your goals.

Key Takeaways

  • A floating IP is a public IP that you can move between servers in seconds.
  • It avoids DNS delays, because your domain keeps pointing to the same address.
  • It sends traffic to one server at a time, so it suits active/standby setups, not load balancing.
  • Floating IP setup means creating the IP, attaching it, adding it with a /32 mask, making it permanent, and testing it.
  • Use Keepalived with a health check to automate failover.
  • Keep both servers equal, and keep data in sync with replication or shared storage.
  • Test failover on a schedule, and measure how long it takes.
  • A floating IP is not a backup. Keep off-site copies of your data.

Frequently Asked Questions

What is a floating IP?

A floating IP is a public IP address that is not fixed to one server. You can move it to another server in the same location within seconds, so visitors keep using the same address.

What is the difference between a floating IP and a static IP?

A static IP stays tied to one server. If that server fails, you must change DNS records, which can take a long time to spread. A floating IP can move to a new server right away.

How do I set up a floating IP?

Create the floating IP in your control panel, attach it to a server, add it to the server’s network settings with a /32 mask, make the change permanent, and test it with ping, curl, and SSH.

Can a floating IP be used for load balancing?

No. A floating IP sends traffic to one server at a time. For load balancing, use a load balancer. You can point a floating IP at a pair of load balancers to protect the entry point.

How fast is floating IP failover?

Moving the address usually takes seconds. With Keepalived and a health check, total failover often takes a few seconds more, depending on your check interval and your provider’s API.

Do I need two servers for a floating IP?

You can use a floating IP with one server, for example to keep the same address when you replace it. For high availability, you need at least two servers.

Does a floating IP work with any VPS provider?

No. Some providers do not offer floating IPs, and the rules differ. Check your plan’s documentation or ask support before you design your setup.

Can I use a floating IP across data centers?

Usually not. Most providers limit floating IPs to one data center or region. For multi-region failover, you need other tools, such as DNS-based failover or a global load balancer.

Does a floating IP support IPv6?

It depends on the provider. Some support IPv4 only. Check your provider’s notes before you plan an IPv6 setup.

Is a floating IP safe?

It is as safe as the servers behind it. Use the same firewall rules on both servers, protect your API tokens, install the same SSL certificate, and keep backups.

Conclusion

A floating IP gives you a fast, simple way to keep your site online when a server fails or needs maintenance. Floating IP setup takes only a few steps: get the IP, attach it, add it to your network settings, and test it. With Keepalived and a good health check, the move can happen on its own.

Remember that a floating IP is only one layer of protection. Pair it with matching servers, data replication, monitoring, and regular backups. Test your failover often, so it works when you need it.

Ready to plan a more resilient setup? Explore AvenaCloud VPS and dedicated servers, or talk to the team about the right option for your project.

Related Posts