Adding a Public IPv6 Address to a Linux Server (Ubuntu)

In this article, we'll show you how to configure an additional, public IP address in an Ubuntu server.

Requirements
  • You have taken note of the main IPv4 address.

  • You have assigned a main IPv6 address and an additional IPv6 address to the server and made a note of them as well. The complete, public IPv6 addresses are shown in the Cloud Panel after selecting the desired server in the Infrastructure > Server section.

  • You have logged on to the server as an administrator.

  • To add the main address, you must add the following entries to /etc/network/interfaces:
    allow-hotplug ens192
    # IPV6 Setup
    iface ens192 inet6 static
    accept_ra 0
    address MAIN-IPv6-ADDRESS
    netmask 64
    gateway fe80::1
    iface ens192 inet6 static

    Example:
    [root@localhost ~]# vi /etc/network/interfaces
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    source /etc/network/interfaces.d/*

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    allow-hotplug ens192
    iface ens192 inet dhcp
    # IPV6 Setup
    iface ens192 inet6 static
    accept_ra 0
    address 2001:ba0:2020:1cc:3fe0:4d12:cd52:491a
    netmask 64
    gateway fe80::1

  • To add the additional IPv6 address, you need to add the following additional entries to /etc/network/interfaces:
    iface ens192 inet6 static
    accept_ra 0
    address ADDITIONAL-IPv6-ADDRESS
    netmask 64
    gateway fe80::1

    Example:
    [root@localhost ~]# vi /etc/network/interfaces
    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    source /etc/network/interfaces.d/*

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    allow-hotplug ens192
    iface ens192 inet dhcp
    # IPV6 Setup
    iface ens192 inet6 static
    accept_ra 0
    address 2001:ba0:2020:1cc:3fe0:4d12:cd52:491a
    netmask 64
    gateway fe80::1
    iface ens192 inet6 static
    accept_ra 0
    address 2001:ba0:2020:1cc:b62d:b9ef:e843:a0c1
    netmask 64
    gateway fe80::1

Notes
  • Make sure that the additional public IPv6 address is entered in /etc/network/interfaces.

  • To configure multiple, additional IPv6 addresses, enter them in the IPV6ADDR_SECONDARIES= entry and separate them with a space.

  • To reboot the network, enter the following command: [
    root@localhost ~]# /etc/init.d/networking restart

  • To check if the additional IPv6 address has been assigned to itServer, enter the following command: [
    root@localhost ~]# ifconfig ens192