How to set up floating IP addresses on DigitalOcean
Floating IP addresses on DigitalOcean provide static IP addresses that can be reassigned between Droplets for high availability. You can create them through the Control Panel's Networking section and assign them to any Droplet in the same datacenter region.
Prerequisites
- Active DigitalOcean account with billing enabled
- At least one Droplet running in your account
- Basic understanding of IP networking concepts
- Access to DigitalOcean Control Panel
Step-by-Step Instructions
Access the Networking section
Create a new floating IP
Assign the floating IP to a Droplet
Configure the floating IP on your Droplet
/etc/netplan/50-cloud-init.yaml or use ip addr add FLOATING_IP/16 dev eth0. For CentOS/RHEL, edit /etc/sysconfig/network-scripts/ifcfg-eth0:0 with the floating IP configuration.Test the floating IP connectivity
ping YOUR_FLOATING_IP. Test HTTP/HTTPS connectivity if you're running web services. Use curl -I http://YOUR_FLOATING_IP to test web server response.Enable floating IP in application configuration
Set up automatic failover (optional)
curl -X POST requests to the floating IP assignment endpoint. Implement health checks to trigger failover when needed.Common Issues & Troubleshooting
Floating IP is not responding to ping or HTTP requests
Verify the floating IP is properly configured on the network interface with ip addr show. Check that your firewall (ufw/iptables) allows traffic on the floating IP. Ensure you're using the correct /16 subnet mask for the floating IP configuration.
Cannot assign floating IP to Droplet in different region
Floating IPs are region-locked and cannot be assigned across regions. Create a new floating IP in the target Droplet's region, or migrate your Droplet to the same region as the existing floating IP using DigitalOcean's snapshot and restore functionality.
Floating IP assignment fails with API errors
Verify your DigitalOcean account has sufficient permissions and billing is current. Check that the target Droplet is powered on and in a running state. Ensure the floating IP is not already assigned to another Droplet before attempting reassignment.
Network interface doesn't retain floating IP after reboot
Make the floating IP configuration persistent by adding it to your network configuration files. For systemd systems, use systemctl enable systemd-networkd. For Ubuntu, ensure the floating IP is properly configured in /etc/netplan/ files and run netplan apply.