Tutorials How to configure floating IP on CoreOS

How to configure floating IP on CoreOS

When you attach a new floating IP, you can find it listed to one of the servers at your UpCloud control panel that the floating IP currently points to. However, using the new floating IP will require some manual setup. Follow the steps below on how to get this done on Ubuntu servers.

As an example, we have a cloud server with the public IP address 94.237.33.165, a floating IP 94.237.33.180. These are highlighted below in red.

Before making changes to your network configuration, it’s always a good idea to take a backup. Also, note that if your network configuration becomes inoperable, remember that you can always log in to your cloud server using the console connection.

Configuring floating IP

Firstly, you’ll need to configure the servers at the OS level, so start up your servers at your UpCloud control panel and log in.

Check your current network settings with the following command.

ip addr

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 94.237.33.165/22 brd 94.237.35.255 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.

route -n
Kernel IP routing table
Destination  Gateway      Genmask        Flags  Metric  Ref  Use  Iface
0.0.0.0      94.237.32.1  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
94.237.32.0  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=94.237.33.165/22
Address=94.237.33.180/32
Gateway=94.237.32.1

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 lose 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.

Testing the configuration

Your configuration is now complete. You can test that it works by transferring the floating IP from one server to another.

First, ping the cloud server or attempt to connect to your server through the floating IP via SSH. Alternatively, if you have a web server configured, open the floating IP on your web browser.

Then transfer the floating IP to another cloud server you’ve configured. This can be done either at your UpCloud control panel or by using the UpCloud API.

Test the floating IP again with any method you prefer. When you get a connection you have successfully transferred your floating IP.

When 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 netmask correctly, that your firewall isn’t blocking your connections, or try another method to connect.

Using your new floating IP

You can now transfer the floating IP between your cloud servers at your UpCloud control panel or by using the UpCloud API!

Depending on your intended use case for the floating IP you may wish to continue by setting up automated load balancing, but it’s always possible to manually transfer the traffic between your servers.

One thought on “How to configure floating IP on CoreOS

Leave a Reply

Your email address will not be published. Required fields are marked *

Locations

Helsinki (HQ)

In the capital city of Finland, you will find our headquarters, and our first data centre. This is where we handle most of our development and innovation.

London

London was our second office to open, and a important step in introducing UpCloud to the world. Here our amazing staff can help you with both sales and support, in addition to host tons of interesting meetups.

Singapore

Singapore was our 3rd office to be opened, and enjoys one of most engaged and fastest growing user bases we have ever seen.

Seattle

Seattle is our 4th and latest office to be opened, and our way to reach out across the pond to our many users in the Americas.