Primary IP Configuration

Last change on 2022-06-28 • Created on 2022-06-28 • ID: CL-470EB

Primary IPs of either type (IPv4, IPv6) that are assigned to a cloud server at the server's creation, do not require a manual configuration.

Changing the Primary IPs of an existing cloud server, requires the following:

  • Changing/assigning the Primary IPv4 does not require any manual configurations.
  • Changing/assigning the Primary IPv6 does require a basic manual configuration.

The following examples explain how to edit the server's network configuration file for the new IPv6 address.


On servers that only have an IPv6 after the changes were applied, you will have to edit the configuration file before the new Primary IPv6 is assigned to the server.

If you don't edit the configuration file before the new Primary IPv6 is assigned, you will have to use the console on the Cloud Console or the Rescue System to edit the IPv6 on the server. Once the changes are made, you will be able to connect to your server as before.


Ubuntu using netplan (20.04 or later)

  1. Access the server via SSH

  2. Open the configuration file with an editor

    nano /etc/netplan/50-cloud-init.yaml
  3. Edit the configuration file

    Go to addresses and add your public IPv6. In the example below, you would have to replace 2001:db8:1234::1 with your own Primary IPv6. No other changes are needed in your original configuration file. Do not change any other settings, such as your own MAC address.

    # This file is generated from information provided by the datasource.  Changes
    # to it will not persist across an instance reboot.  To disable cloud-init's
    # network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    network:
       version: 2
       ethernets:
          eth0:
                addresses:
                - 2001:db8:1234::1/64
                dhcp4: true
                gateway6: fe80::1
                match:
                   macaddress: your-original-macaddress
                nameservers:
                   addresses:
                   - 2a01:4ff:ff00::add:2
                   - 2a01:4ff:ff00::add:1
                set-name: eth0
  4. Change/assign your Primary IPv6

    Now that the configuration file has been changed, you can safely assign the new Primary IPv6 to your server.


Debian-based distributions using ifupdown (Ubuntu 18.04, Debian)

  1. Access the server via SSH

  2. Open the configuration file with an editor

    nano /etc/network/interfaces.d/50-cloud-init
  3. Edit the configuration file

    Go to the address line and add your public IPv6. In the example below, you would have to replace 2001:db8:1234::1 with your own Primary IPv6. No other changes are needed in your original configuration file.

    # This file is generated from information provided by the datasource.  Changes
    # to it will not persist across an instance reboot.  To disable cloud-init's
    # network configuration capabilities, write a file
    # /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
    # network: {config: disabled}
    auto lo
    iface lo inet loopback
    
    auto eth0
    iface eth0 inet dhcp
       dns-nameservers 185.12.64.2 185.12.64.1
    
    # control-alias eth0
    iface eth0 inet6 static
       address 2001:db8:1234::1/64
       dns-nameservers 2a01:4ff:ff00::add:1 2a01:4ff:ff00::add:2
       gateway fe80::1
  4. Change/assign your Primary IPv6

    Now that the configuration file has been changed, you can safely assign the new Primary IPv6 to your server.


RHEL-based distributions (CentOS, Fedora, Rocky)

  1. Access the server via SSH

  2. Open the configuration file with an editor

    vi /etc/sysconfig/network-scripts/ifcfg-eth0
  3. Edit the configuration file

    Go to the IPV6ADDR line and add your public IPv6. In the example below, you would have to replace 2001:db8:1234::1 with your own Primary IPv6. No other changes are needed in your original configuration file. Do not change any other settings, such as your own MAC address.

    # Created by cloud-init on instance boot automatically, do not edit.
    #
    BOOTPROTO=dhcp
    DEFROUTE=yes
    DEVICE=eth0
    DNS1=2a01:4ff:ff00::add:1
    DNS2=2a01:4ff:ff00::add:2
    HWADDR=your-original-macaddress
    IPV6ADDR=2001:db8:1234::1/64
    IPV6INIT=yes
    IPV6_AUTOCONF=no
    IPV6_DEFAULTGW=fe80::1%eth0
    IPV6_FORCE_ACCEPT_RA=no
    ONBOOT=yes
    TYPE=Ethernet
    USERCTL=no
  4. Change/assign your Primary IPv6

    Now that the configuration file has been changed, you can safely assign the new Primary IPv6 to your server.

Table of Contents