Once you get a confirmation from the UpCloud Support that a floating IP has been added, you can find it attached to one of the servers at your UpCloud Control Panel, but using the added IP will require some manual setup. Follow the steps below to find out how to get this done on Debian servers.
Set up static IP addresses
For this example, the server 1 (126.96.36.199) and the server 2 (188.8.131.52) have a common floating IP 184.108.40.206, netmask 255.255.252.0 and gateway 220.127.116.11.
Next, you need to configure the servers at the OS level, so start up your systems and log in.
Check your current network settings with the following command.
Commonly the second network interface card (NIC) named eth0 has your public IPv4 address assigned to it, see the example below.
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 6e:d7:1b:bf:5a:b0 brd ff:ff:ff:ff:ff:ff inet 18.104.22.168/22 brd 22.214.171.124 scope global eth0 valid_lft forever preferred_lft forever
In addition to the IP addresses, you will need the default gateway, it can be found with the command underneath.
default via 126.96.36.199 dev eth0 10.0.0.0/8 via 10.1.4.1 dev eth1 10.1.4.0/22 dev eth1 proto kernel scope link src 10.1.7.180 188.8.131.52/22 dev eth0 proto kernel scope link src 184.108.40.206
Set the address to static on the NIC with your public IPv4, eth0 in this case. You can do this by editing the interfaces configuration file.
sudo nano /etc/network/interfaces
At the settings group that starts with auto eth0, change the dhcp to static and add the address, netmask and gateway below that as shown in the following example.
auto eth0 iface eth0 inet static address 220.127.116.11 netmask 255.255.252.0 gateway 18.104.22.168
After making the changes, save the file and exit. You will then need to restart the interface to enable the static configuration.
sudo ifdown eth0 && sudo ifup eth0
If you were connected with SSH, the interface restart should be fast enough to not cause you to disconnect. In case you do loose connection and are unable to reconnect, you can always use the web Console at UpCloud Control Panel under your Server settings to go through the setup again to make sure everything is entered correctly.
Repeat the steps on your other server to configure it with static IP address as well.
Configure the floating IP
To set up the floating IP, you’ll need to add it as an alias to the network interface with your public static IP configured to.
On Debian systems, you can do this by adding eth0:1 to the same interfaces file that you edited before.
sudo nano /etc/network/interfaces
Enter the example configuration shown below with your floating IP and netmask as shown in the support reply.
auto eth0:1 iface eth0:1 inet static address 22.214.171.124 netmask 255.255.252.0
Save the file and exit after these changes.
Repeat the process to add the alias on any other servers you wish to use the floating IP on.
Enabling traffic to the floating IP
With the new alias interfaces set up, check which server the floating IP is attached to under the Public network list at your UpCloud Control Panel. You should then turn on the alias NIC on that server, in this case, using the following command on your Debian host.
sudo ifup eth0:1
Check your network configuration again with the same command as before.
The newly added alias shows up under the NIC with your public IP with the floating IP.
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 6e:d7:1b:bf:30:50 brd ff:ff:ff:ff:ff:ff inet 126.96.36.199/22 brd 188.8.131.52 scope global eth0 valid_lft forever preferred_lft forever inet 184.108.40.206/22 brd 220.127.116.11 scope global secondary eth0:1 valid_lft forever preferred_lft forever
Now attempt to connect to your server through the floating IP with SSH or if you have a web server configured open the floating IP on your web browser.
If you get a reply, the floating IP works on that server and you can continue forward. If it didn’t work, make sure you entered the IP address and net mask correctly, that your firewall isn’t blocking your connections, or try another method to connect.
Test the configuration
Your configuration should now be complete, you can test that it works by transferring the floating IP from one server to an other.
To do this, turn off the floating IP alias NIC on the server it’s currently attached to using the command underneath.
sudo ifdown eth0:1
Then turn on the alias NIC on your other server.
sudo ifup eth0:1
Lastly, update the gateway on the new floating IP destination server with arping -S <floating IP> <gateway IP>. In this example, the command would be the following.
sudo arping -S 18.104.22.168 22.214.171.124
If you do not have arping tool installed, you can get it with this command.
sudo aptitude install arping -y
Test the floating IP again with any method you prefer. When you get a connection you have successfully transferred the floating IP.
Using your new floating IP
You can now transfer the floating IP between your cloud servers by turning off the alias NIC on the current server, and then turning on the alias on the new destination host.
Depending on your intended use case for the floating IP you may wish to continue by setting up automated load balancing, but if you wish to manually transfer the traffic between your servers, it might be useful to create scripts of the required commands.