Floating IP Persistent

Last change on 2023-08-24 • Created on 2020-07-02 • ID: CL-BD51C

If you are using more than one Floating IP, then the number on the interface (eth0:1) will be increased (example eth0:2).

On Debian based distributions (Ubuntu versions before 20.04, Debian):

  1. Access the server via SSH.

  2. Create the configuration file and open an editor:

 touch /etc/network/interfaces.d/60-my-floating-ip.cfg
 nano /etc/network/interfaces.d/60-my-floating-ip.cfg
  1. Paste the following configuration into the editor and replace your.Float.ing.IP with your Floating IP:

IPv4:

 auto eth0:1
 iface eth0:1 inet static
     address your.Float.ing.IP
     netmask 32

IPv6:

 auto eth0:1
 iface eth0:1 inet6 static
     address one IPv6 address of the subnet, e.g. 2a01:4f9:0:2a1::2
     netmask 64
  1. Now you should restart your network. Caution: This will reset your network connection:
 sudo service networking restart

Ubuntu 20.04:

  1. Access the server via SSH.

  2. Create the configuration file and open an editor:

 touch /etc/netplan/60-floating-ip.yaml
 nano /etc/netplan/60-floating-ip.yaml
  1. Paste the following configuration into the editor and replace your.Float.ing.IP with your Floating IP:

    IPv4:

    network:
       version: 2
       renderer: networkd
       ethernets:
         eth0:
           addresses:
           - your.float.ing.ip/32

    IPv6:

    network:
       version: 2
       renderer: networkd
       ethernets:
         eth0:
           addresses:
           - your.float.ing.ip/64
  2. Now you should restart your network. Caution: This will reset your network connection:

 sudo netplan apply

On RHEL based distributions (Fedora, CentOS):

  1. Access the server via SSH.

  2. Create the configuration file and open an editor:

 touch /etc/sysconfig/network-scripts/ifcfg-eth0:1
 vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
  1. Paste the following configuration into the editor and replace your.Float.ing.IP with your Floating IP:

IPv4:

 BOOTPROTO=static
 DEVICE=eth0:1
 IPADDR=your.Float.ing.IP
 PREFIX=32
 TYPE=Ethernet
 USERCTL=no
 ONBOOT=yes

IPv6:

 BOOTPROTO=none
 DEVICE=eth0:1
 ONBOOT=yes
 IPV6ADDR=one IPv6 address of the subnet, e.g. 2a01:4f9:0:2a1::2/64
 IPV6INIT=yes
  1. Now you should restart your network. Caution: This will reset your network connection:
 systemctl restart network

On Fedora 38:

  1. Access the server via SSH

  2. Open the configuration file /etc/NetworkManager/system-connections/cloud-init-eth0.nmconnection

    [connection]
    id=cloud-init eth0
    uuid=<keep the UUID as is!!>
    type=ethernet
    
    [ethernet]
    mac-address=<keep the HWADDR as is!!>
    
    [ipv4]
    address1=<your IPv4 address>/32,172.31.1.1
    address2=<your floating ip>/32
    dns=185.12.64.1;185.12.64.2;
    may-fail=false
    method=manual
    
    [ipv6]
    address1=<one IPv6 address from your subnet, e.g. 2001:db8:0:3df1::1>/64,fe80::1
    dns=2a01:4ff:ff00::add:1;2a01:4ff:ff00::add:2;
    may-fail=false
    method=manual
    
    [proxy]
    
    [user]
    org.freedesktop.NetworkManager.origin=cloud-init
Table of Contents