IP addresses > Configuring a public IP address associated with a Cloud Server

05 Configuring a public IP address associated with a Cloud Server

What to know before proceeding

To use a new public IP address associated with a Cloud Server, you must also configure it in the server operating system.

Before proceeding, make sure you:

The following procedures describe how to permanently add a public IPv4 address to an already configured Cloud Server. The settings are retained after a restart.

Before changing the network configuration, check which interface should use the new IP address and keep a copy of the existing configuration. Do not replace the primary IP address or change any existing gateways, DNS servers or routes.

Changing the network configuration may interrupt Cloud Server connectivity. Before proceeding, make sure you can use the recovery console to check or correct the settings.

Configuring a public IP address on Windows

Access the Cloud Server using the recovery console and proceed as follows:
  • go to Start > Control Panel > Network and Internet > Network and Sharing Center;
  • select Change adapter settings;
  • locate the network adapter on which you want to configure the new public IP address, right-click it and select Properties;
  • select Internet Protocol Version 4 (TCP/IPv4) and click Properties;
  • if the adapter already uses a static IPv4 configuration, click Advanced;
  • in the IP addresses section of the IP Settings tab, click Add;
  • enter the parameters of the new public IP address:
    • IP address: the new public IPv4 address;
    • Subnet mask: the corresponding subnet mask.
  • confirm by clicking Add and then OK, without changing any existing IP addresses, gateways or DNS servers;
  • check that the new address has been added to the network adapter.

To check the configured IPv4 addresses, open Command Prompt and run:

ipconfig /all

Configuring a public IP address on AlmaLinux 9 and CentOS Stream 9

AlmaLinux 9 and CentOS Stream 9 use NetworkManager to manage network connections.

To permanently add a public IPv4 address to an existing connection, proceed as follows:
  • access the Cloud Server using the recovery console;
  • display the available network connections:

    nmcli connection show

  • identify the name of the connection associated with the network interface on which you want to configure the new public IP address;
  • display the IPv4 configuration of the connection:

    nmcli -f ipv4.method,ipv4.addresses,ipv4.gateway,ipv4.dns connection show "CONNECTION_NAME"

  • add the new public IPv4 address, specifying the network prefix corresponding to the subnet mask:

    sudo nmcli connection modify "CONNECTION_NAME" +ipv4.addresses "NEW_IP/PREFIX"

  • apply the change to the connection:

    sudo nmcli device reapply INTERFACE_NAME

  • check that the new public IPv4 address is present:

    ip -4 address show dev INTERFACE_NAME

Replace CONNECTION_NAME, INTERFACE_NAME, NEW_IP and PREFIX with the values for your configuration.

The + symbol before ipv4.addresses allows you to add the new address without replacing those already present in the connection profile. The change is saved in the persistent NetworkManager configuration.

If the nmcli device reapply command cannot apply the change, check the connection status before attempting to reactivate it, as this may temporarily interrupt connectivity.

Configuring a public IP address on Debian and Ubuntu

Persistent network configuration depends on the network management system used by the template. Before proceeding, check whether the connection is managed by Netplan or ifupdown.

Configuration using Netplan

To permanently add a public IPv4 address to an existing connection, proceed as follows:
  • access the Cloud Server using the recovery console;
  • display the available configuration files:

    ls /etc/netplan/

  • identify the YAML file containing the configuration of the relevant network interface and make a backup copy;
  • open the file using a text editor:

    sudo nano /etc/netplan/FILE_NAME.yaml

  • add the new public IPv4 address to the interface configuration, keeping the existing addresses and other settings:
    • if the interface already has static addresses, add the new address to the existing addresses list. The following example shows only the address settings:

      addresses:
        - EXISTING_IP/EXISTING_PREFIX
        - NEW_IP/NEW_PREFIX

    • if the interface uses DHCP for its primary address, keep DHCP enabled and add the new static address. The following example shows only the relevant settings:

      dhcp4: true
      addresses:
        - NEW_IP/NEW_PREFIX

  • do not replace the rest of the existing YAML configuration with the example snippets;
  • save the file and validate the configuration:

    sudo netplan generate

  • test the changes:

    sudo netplan try

  • confirm the configuration if connectivity is working correctly;
  • check that the new public IPv4 address is present:

    ip -4 address show

Replace FILE_NAME, EXISTING_IP, EXISTING_PREFIX, NEW_IP and NEW_PREFIX with the values for your configuration.

Configuration using ifupdown

To permanently add a public IPv4 address to an existing connection, proceed as follows:
  • access the Cloud Server using the recovery console;
  • locate the file containing the interface configuration, usually /etc/network/interfaces or a file in the /etc/network/interfaces.d/ directory;
  • make a backup copy of the file before modifying it;
  • open the file using a text editor;
  • in the existing configuration of the relevant interface, add the directives to configure the new public IPv4 address:

    up ip address add NEW_IP/NEW_PREFIX dev INTERFACE_NAME
    down ip address del NEW_IP/NEW_PREFIX dev INTERFACE_NAME

  • save the file without changing the existing primary IP address, gateway or DNS servers;
  • to make the new address available immediately, run:

    sudo ip address add NEW_IP/NEW_PREFIX dev INTERFACE_NAME

  • check that the new public IPv4 address is present:

    ip -4 address show dev INTERFACE_NAME

Replace NEW_IP, NEW_PREFIX and INTERFACE_NAME with the values for your configuration.
 
The up and down directives are executed when the interface managed by ifupdown is brought up and down, respectively. The ip address add command applies the address immediately, without restarting the connection. The configuration saved in the file ensures that the address is restored when the interface is brought up again.

Configuring a public IP address on openSUSE

The following procedure applies to openSUSE templates that use YaST with the Wicked network manager. If the installed version does not provide the Additional Addresses feature, check the network management system before proceeding.

To permanently add a public IPv4 address to the existing configuration without replacing the primary address, proceed as follows:
  • access the Cloud Server using the recovery console;
  • start YaST:

    sudo yast2

  • go to Network Settings;
  • on the Overview tab, locate the network interface on which you want to configure the new public IP address and select Edit;
  • in the Address section, locate the additional address settings (Additional Addresses);
  • select Add and enter the new public IPv4 address and the corresponding subnet mask;
  • confirm the changes without replacing the primary address or modifying any existing gateways or DNS servers;
  • save the configuration and wait for the changes to be applied;
  • check that the new public IPv4 address has been added:

    ip -4 address show