How to configure Floating IP on CentOS
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 CentOS Stream 9 and 10 servers.
As an example, we have a cloud server with the public IP address 185.20.139.167, a floating IP 185.20.139.29, with a netmask 255.255.255.255.
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 cloud server at your UpCloud Control Panel and log in.
CentOS Stream manages the network with NetworkManager, so you add the floating IP to the connection of the public interface with nmcli. First, list the connections to find the one for eth0, the interface that commonly has your public IPv4 address.
nmcli con showOn CentOS Stream 10, the connection for eth0 is called cloud-init eth0, as in the example below. On CentOS Stream 9, it's called System eth0.
NAME UUID TYPE DEVICE
cloud-init eth0 1dd9a779-d327-56e1-8454-c65e2556c12c ethernet eth0
cloud-init eth2 5559a242-3421-5fdd-896e-9cb8313d5804 ethernet eth2
cloud-init eth1 3c50eb47-7260-5a6d-801d-bd4f587d6b58 ethernet eth1
lo 07acb526-4517-4644-a6e9-db6a45b6de5b loopback lo
eth0 120ebcb4-85c5-4961-b6b9-d30151798e70 ethernet --Add the floating IP to that connection with a /32 netmask. Use your own connection name and floating IP in the command.
sudo nmcli con mod "cloud-init eth0" +ipv4.addresses "185.20.139.29/32"Then reactivate the connection to apply the change.
sudo nmcli con up "cloud-init eth0"NetworkManager saves the address in the connection, so the floating IP stays configured when the server restarts. You can check that eth0 now has both addresses.
ip addr show dev eth02: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 16:44:a3:20:34:84 brd ff:ff:ff:ff:ff:ff
altname enp0s3
altname ens3
altname enx1644a3203484
inet 185.20.139.29/32 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet 185.20.139.167/22 brd 185.20.139.255 scope global dynamic noprefixroute eth0
valid_lft 84320sec preferred_lft 84320sec
inet6 fe80::1444:a3ff:fe20:3484/64 scope link noprefixroute
valid_lft forever preferred_lft foreverReactivating the connection keeps you connected if you're logged in over SSH. If you lose the connection and can't reconnect, use the web Console under your Server settings in the Control Panel to go through the setup again and check that everything is entered correctly.
Repeat the process on any other servers you wish to use the floating IP on.
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 connection name, IP address and netmask correctly, and 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.