Once you get a confirmation from the UpCloud Support that a floating IP has been added, you can find it attached to one of your 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 a CoreOS server.
Set up static IP addresses
For this example, the server 1 (18.104.22.168) and the server 2 (22.214.171.124) have a common floating IP 126.96.36.199 and a gateway 188.8.131.52.
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, like in the example output 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:20:df brd ff:ff:ff:ff:ff:ff inet 184.108.40.206/22 brd 220.127.116.11 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::6cd7:1bff:febf:20df/64 scope link 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.
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 18.104.22.168 0.0.0.0 UG 0 0 0 eth0 10.0.0.0 10.1.8.1 255.0.0.0 UG 1024 0 0 eth1 10.1.8.0 0.0.0.0 255.255.252.0 U 0 0 0 eth1 22.214.171.124 0.0.0.0 255.255.252.0 U 0 0 0 eth0 172.17.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0 172.18.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker_gwbridge
Set the addresses statically on the NIC with your public IPv4, eth0 in this case. On a CoreOS host, this can be done by creating a network configuration file at /etc/systemd/network.
sudo vi /etc/systemd/network/static.network
Enter the following two sections with the specified details found in the outputs above. The name match defines which network interface the addresses belong to, while the addresses include the normal IPv4 and the floating IP address. For the gateway, use the IP address ending in .1 shown in the Kernel IP routing table for your network interface.
[Match] Name=eth0 [Network] Address=126.96.36.199/22 Address=188.8.131.52/22 Gateway=184.108.40.206
After adding in the required details, save the file and exit. You will then need to restart the networking process to enable the static configuration.
sudo systemctl restart systemd-networkd
If you were connected with SSH, the networking restart should 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 addresses as well.
Enabling traffic to the floating IP
With the static IP addresses set up, check which server the floating IP is attached to under the Public network list at your UpCloud Control Panel. The traffic to the floating IP is by default directed to the server it was initially assigned to.
Check your network configuration again with the same command as before.
The newly added floating IP should show up under the same NIC as the public IP address.
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether 6e:d7:1b:bf:20:df brd ff:ff:ff:ff:ff:ff inet 220.127.116.11/22 brd 18.104.22.168 scope global eth0 valid_lft forever preferred_lft forever inet 22.214.171.124/22 brd 126.96.36.199 scope global secondary eth0 valid_lft forever preferred_lft forever inet6 fe80::6cd7:1bff:febf:20df/64 scope link valid_lft forever preferred_lft forever
Now attempt to connect to your server using 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 gateway correctly, that your firewall isn’t blocking your connections, or try another method to connect.
Transferring the floating IP
Your configuration should now be working, but a static floating IP would be of a little use. Test that the address can be transferred between the server.
To do this, you will need to tell the gateway which host the traffic coming to the floating IP should be directed to. A simple way to do this is using the arping command line network tool, but it is not installed on the minimalistic CoreOS by default. Fortunately, docker is able to provide the solution with the busybox container image, which includes many useful tools in a small and simple package.
Use the following docker command to run a single arping request.
docker run --network=host --entrypoint=/bin/arping --rm busybox -c 3 -U -s <floating IP> <gateway>
Docker will download the latest busybox image, starts it up attached to the host network and runs the arping command with the parameters after the busybox image name. Replace the <floating IP> and <gateway> with the correct IP addresses for your system and you should see an output similar to the example below.
docker run --network=host --entrypoint=/bin/arping --rm busybox -c 3 -U -s 188.8.131.52 184.108.40.206 ARPING to 220.127.116.11 from 18.104.22.168 via eth0 Unicast reply from 22.214.171.124 [00:00:0c:9f:f0:10] 0.895ms Unicast reply from 126.96.36.199 [00:00:0c:9f:f0:10] 0.747ms Sent 3 probe(s) (1 broadcast(s)) Received 2 reply (0 request(s), 0 broadcast(s))
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 running the busybox arping command 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 command.