Adding a Public IPv6 Address on a Dedicated Server (Ubuntu 20.04)

For Dedicated Servers

This article explains how to add an additional, public IPv6 address on a Dedicated Server where Ubuntu 20.04 is installed.

To configure an additional public IPv6 address in Ubuntu 20.04, please proceed as follows:

Requirements
  • In the  Cloud Panel, you have assigned an additional public IPv6 address to your server. 

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

  • Check which network interface is in use and enter the following command:[root@localhost ~]# ip addr

  • Open the /etc/network/interfaces file in the vi Editor.  [root@localhost ~]# vi /etc/network/interfaces

Notes
  • The vi Editor has a command mode and an insert mode. To switch to input mode, press [i] on your keyboard. You can now insert the required content or make the required changes. Press the [ESC] key on your keyboard to exit the input mode.

  • To exit vi and save the file, type the command :wq, then press Enter.

  • Replace the entries with the following information:
    auto lo eth0
    iface lo inet loopback

    allow-hotplug eth0
    iface eth0 inet static
     address Main IPv4 ADDRESS/32

    iface eth0 inet6 manual
          pre-up sleep 5
          up dhclient -6 -nw -v eth0
          post-up sleep 5; /sbin/ip -family inet6 route add default via fe80::1 dev eth0
          pre-down /sbin/ip -family inet6 route del default via fe80::1 dev eth0
          down dhclient -6 -r -v eth0

    auto eth0:0     
    iface eth0:0 inet6 static
        accept_ra 0
        address Additional IPv6 Address/64

Note

For each additional IPv6 address, you need to add an additional section that contains the information below. To do this, a consecutive number is simply appended to the interface name, starting with 1.

auto eth0:1     
iface eth0:1 inet6 static
    accept_ra 0
    address Additional IPv6 Address/64

Example:

auto lo eth0
iface lo inet loopback

allow-hotplug eth0
iface eth0 inet static
 address 217.160.244.147/24

iface eth0 inet6 manual
      pre-up sleep 5
      up dhclient -6 -nw -v eth0
      post-up sleep 5; /sbin/ip -family inet6 route add default via fe80::1 dev eth0
      pre-down /sbin/ip -family inet6 route del default via fe80::1 dev eth0
      down dhclient -6 -r -v eth0

auto eth0:0      
iface eth0:0 inet6 static
    accept_ra 0
    address 2001:8d8:1800:1a1::1/64

auto eth0:1
iface eth0:1 inet6 static
    accept_ra 0
    address 2001:8d8:1800:1a1::2/64

 

  • Save the file.

  • Restart the server.

  • To check if the additional public IPv6 address has been added, type the following command:
    [root@localhost ~]# ip addr
    The additional public IPv6 address will now be displayed. Example:root@A34C022:~# ip addr
    1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
        link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
        inet 127.0.0.1/8 scope host lo
           valid_lft forever preferred_lft forever
        inet6 ::1/128 scope host
           valid_lft forever preferred_lft forever
    2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether ac:1f:6b:9b:22:44 brd ff:ff:ff:ff:ff:ff
        inet 217.160.244.147/32 scope global dynamic eth0
           valid_lft 42828sec preferred_lft 42828sec
        inet6 2001:8d8:1800:1a1::2/64 scope global deprecated
           valid_lft forever preferred_lft 0sec
        inet6 2001:8d8:1800:1a1::1/128 scope global
           valid_lft forever preferred_lft forever
        inet6 fe80::ae1f:6bff:fe9b:2244/64 scope link
           valid_lft forever preferred_lft forever
    3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
        link/ether ac:1f:6b:9b:22:45 brd ff:ff:ff:ff:ff:ff