Jump toUpdate content

How to configure a flexible IP on a Bare Metal Cloud Server

Reviewed on 26 May 2021Published on 26 May 2021

Learn how to configure a flexible IP address on your Bare Metal Cloud Server. The configuration depends on the Linux distribution running on your machine. You can configure your flexible IP on machines running one of Ubuntu Linux, Debian Linux or CentOS.

Requirements:

How to configure a flexible IP on Ubuntu Linux

Since the LTS release of Ubuntu Version 18.04 (Bionic Beaver) the recommended way to configure a flexible IP is by using Netplan. If you prefer a more traditional configuration, refer to the instructions for Flexible IP configuration on Debian.

  1. Log into your server using SSH with a user having super-user rights.

  2. Open the file /etc/netplan/01-netcfg.yaml with superuser rights in your favorite text editor and configure the networking for your machine.

    Note:

    IP addresses in the configuration file have to be specified in CIDR notation. The netmask is /24 for the principal IP of the server and /32 for each flexible IP.

    Your configuration file should look like the following example:
    network:
    version: 2
    renderer: networkd
    ethernets:
    enp1s0f0:
    addresses: [163.172.123.123/24, 212.83.123.123/32]
    gateway4: 163.172.123.1
    nameservers:
    addresses: [ "62.210.16.6", "62.210.16.7" ]
    Tip:

    The interface name for your primary interface may be different than enp1s0f0. You can use the ip link show command to determine the name of your public Internet interface.

  3. Once the file is edited as required, save it and quit the text editor. Then apply the configuration using the following command:

    sudo netplan apply 

Your server now responds on both the primary IP address and the flexible IP address.

How to configure a flexible IP on Debian Linux

  1. Log into your server using SSH with a user having super-user rights.

  2. Open the file /etc/network/interfaces with superuser rights in your favorite text editor and configure the networking for your machine.

  3. Edit the file and add the flexible IP as shown in the following example:

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).
    # The loopback network interface
    auto lo
    iface lo inet loopback
    # The primary network interface
    auto eth0
    iface eth0 inet static
    address 195.154.123.123
    netmask 255.255.255.0
    gateway 195.154.123.1
    auto eth0:0
    iface eth0:0 inet static
    address ip_flexible
    netmask 255.255.255.255
    Note:

    The interface name of your server might be different depending on the hardware of the server. You can use the ip link show command to determine the name of your public Internet interface.

  4. Save the file and quit the editor.

  5. Bring the interface up using the ifup command:

    ifup eth0:0 

Your server now responds on both the primary IP address and the flexible IP address.

How to configure a flexible IP on CentOS

  1. Log into your server using SSH using the root user.

  2. Copy the default network configuration file to create an alias:

    cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
  3. Open the file /etc/sysconfig/network-scripts/ifcfg-eth0:0 in your favourite text editor and modify it as in the following example:

    DEVICE="eth0:0"
    BOOTPROTO=static
    IPADDR="my_flexible_ip"
    NETMASK="255.255.255.255"
    ONBOOT=yes
  4. Save the file, exit the text editor and run the following command to reload the network configuration:

    /etc/init.d/network restart

    Your server now responds on both the primary IP address and the flexible IP address.

See Also