Welcome to another one of our Ubuntu guides. This guide will show you how to manually configure a static IPv6 address on your Ubuntu 22.04 VPS server.

Adding a static IPv6 address on Ubuntu 22.04

By default, Ubuntu 22.04 comes with out-of-the-box support for IPv6, so the only thing you will need to do is to configure your VPS by modifying its netplan configuration. To start, you will need to find your allocated subnet /64, and most hosting providers have the allocated IPs and subnets displayed on the VPS service page or provided on the initial VPS activation email. Once you have found the subnet, you will also need to know the gateway and, in most cases, be on the first /128 of the subnet. For example, most of our subnets start off as:

2a07:85XX::1

Now that you have this information you can edit your netplan configuration file. Netplan reads the configuration files from: 

/etc/netplan/

Our Ubuntu 22.04 templates already have DHCP configuration for IPv4 in 00-interfaces.yaml so you can start adding the following configuration parameters:

network:
    version: 2
    ethernets:
      ens3:
        dhcp4: true
        dhcp6: no
        addresses:
            - 2a07:85XX:0:XXX::2/64
        accept-ra: true
        nameservers:
            addresses:
                - 1.1.1.1
                - 8.8.8.8
                - 2606:4700:4700::1111
                - 2001:4860:4860::8888
        routes:
            - to: default
              via: 2a07:85XX::1
              metric: 1
              on-link: true

Now we need to run netplan apply so the changes we made to the file can be applied.

Once this is done, we need to make our IP reachable around the globe, for that we will need to advertise your IPv6 address on our network with the neighbour solicitation protocol, this can be done by running a simple ping command:

ping -6 black.host

Now you have a working IPv6 address.

Make sure that you have the latest version of ping utility: apt install iputils-ping

Looking for IPv6 ready VPS servers?

How to add additional IPv6 addresses?

If you wish to add more IPv6 addresses, you need to add each additional IP under the first IP address that we previously added, like in the example below:

...
            addresses:
                - 2a07:85XX:0:XXX::4/64
                - 2a07:85XX:0:XXX::6/64
                - 2a07:85XX:0:XXX::8/64
...

Once you have edited the file you need to apply the changes again, and then announce the added IPs using the ping command while specifying the outgoing interface and IP address as in the following example:

ping -6 -I 2a07:85XX:0:XXX::4 black.host

Removing an additional IPv6 address

The removal of an IPv6 address is quite simple, you just need to remove the IP from the configuration file and apply the changes using the same command: netplan apply.

Lastly, you can check out our guide if you’re having trouble finding your IP address.

Was this article helpful?