Floating IP assignment in Ubuntu and Debian 12 OS: Step-by-step guide

While a static IP address provides a fixed address for each server, floating IP addresses have the advantage of being moved from one server to another as needed.

Having a floating IP address is helpful in handling various services or applications on the same server. This guide will explain how to set up a floating IP address on your server using the “netplan” tool. 

Some key points to consider: 

  • This guide applies to VPS, VDS, and Bare Metal servers running Ubuntu 20.04, 22.04, and 24.04 operating systems. For the Debian 12 operating system, it applies to VPS and VDS servers only. 
  • Floating IPs are public IP addresses that can be instantly moved from one server to another within the same region, making managing and scaling your services easier. 

Step-by-Step instructions 

Step 1: Access the Client Portal 

  1. Log in to your client portal. 
  2. Click on the "Network" button at the top of the menu bar (see Fig. 1). 

    Fig. 1. Accessing the ”Network” section in the client portal.

 Step 2: Verify your floating IP address 

  1. In the "Network" section, confirm that a floating IP address is linked to an instance. 
  2. Assign it using the "Attach +" button (see Fig. 2).

    Fig. 2. Verifying and attaching a floating IP address in the client portal. 

Step 3: Configure the floating IP address manually 

If you have essential data on your server, it is advisable to configure the floating IP manually. This article will explain how to do this for Ubuntu 20.04, 22.04, 24.04, and Debian 12 operating systems. 

  1. Navigate to the “netplan” directory: 
    $ cd /etc/netplan/
    $ ls 
    Look for files ending in .yaml. For example, you might see "50-cloud-init.yaml" (see Fig. 3)

    Fig. 3. Navigating to the ‘netplan’ directory and listing files. 
  2. Edit the configuration file:  
    $ nano 50-cloud-init.yaml
  3.  Add your floating IP address:
    In the "addresses" section of the file, add your new floating IP address using the /32 subnet notation (e.g., 93.115.24.186/32). This should go below your public IP address (see Fig. 4)

    Fig. 4. Editing the configuration file to add the floating IP address. 
  4. Save the changes:

    • Press Ctrl + X to exit. 

    • Press Y to confirm you want to save the changes. 

    • Press Enter to finalize the save. 

  5. Apply the Configuration:   
    $ sudo netplan apply   

Step 4: Ensure configuration persists through reboots 

You must turn off Cloud-init's network configuration to ensure your changes stick after a reboot. 

  1. Create the persistence configuration file and add the configuration:
    $ echo "network: {config: disabled}" | sudo tee /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg 

Summary 

Following these steps, you can successfully set up a floating IP on your server, ensuring it remains persistent through reboots.