DigitalOcean floating IPs are publicly-accessible static IP addresses that you can assign to Droplets and instantly remap between other Droplets in the same datacenter. Implement a failover mechanism with floating IPs to build a high availability infrastructure.
Network traffic between a Floating IP and a Droplet flows through an anchor IP, which is an IP address aliased to the Droplet’s public network interface (
eth0). Droplets must have an anchor IP before you can assign a Floating IP to it.
Droplets created before 20 October 2015 or that were created using a custom image do not have anchor IP addresses automatically assigned to them. To use floating IPs with Droplets created before this date or Droplets created using a custom image, you need to manually add an anchor IP address to the Droplet’s public network interface (usually
If you try to add a floating IP to a Droplet without an anchor IP, you’ll receive a warning in the control panel with instructions on how to add the anchor IP.
First, find your Droplet’s anchor IP. You’ll use it in all of the following commands.
On Linux distributions (like Ubuntu, Debian, CentOS, and Fedora), use the following command to add the anchor IP address to your networking configuration, substituting in your anchor IP.
sudo ip addr add use_your_anchor_ip/16 dev eth0
On FreeBSD, add the anchor IP with this command:
sudo ifconfig vtnet0 use_your_anchor_ip netmask 255.255.0.0 alias
To make the setting persist after reboots, you need to modify the network interface of your Droplet. How you do this depends on the Droplet’s operating system.
/etc/network/interfaces and add the line highlighted below, substituting in your anchor IP.
auto eth0 iface eth0 inet static address 203.0.113.0 netmask 255.255.252.0 gateway 220.127.116.11 up ip addr add use_your_anchor_ip/16 dev eth0 dns-nameservers 18.104.22.168 22.214.171.124
/etc/sysconfig/network-scripts/ifcfg-eth0 and add the line highlighted below, substituting in your anchor IP.
DEVICE='eth0' TYPE=Ethernet BOOTPROTO=none ONBOOT='yes' HWADDR=04:01:76:bc:91:01 IPADDR=126.96.36.199 NETMASK=255.255.192.0 GATEWAY=188.8.131.52 NM_CONTROLLED='yes' IPADDR2=use_your_anchor_ip PREFIX2=16 DNS1=184.108.40.206 DNS2=220.127.116.11
Again, remember to replace the highlighted IP address with your anchor IP.
In order for your anchor IP to persist after reboot, you must create a new file containing the networking information at
/etc/sysconfig/network-scripts/ifcfg-eth0 on the Droplet. This can be done by copying the existing
sudo cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
/etc/sysconfig/network-scripts/ifcfg-eth0:0 file just created and modify the lines highlighted below to update the value of the
DEVICE fields to the value of your anchor IP.
DEVICE='eth0:0' TYPE=Ethernet BOOTPROTO=none ONBOOT='yes' HWADDR=04:01:76:d6:cb:01 IPADDR=use_your_anchor_ip NETMASK=255.255.224.0 GATEWAY=18.104.22.168 NM_CONTROLLED='yes' PREFIX2=16 DNS1=22.214.171.124 DNS2=126.96.36.199
In order for your anchor IP to persist after reboot, append the new networking information to the file
/etc/rc.digitalocean.d/droplet.conf, substituting in your anchor IP.
echo 'ifconfig_vtnet0_alias0="inet use_your_anchor_ip netmask 255.255.0.0"' | sudo tee -a /etc/rc.digitalocean.d/droplet.conf