How to Setup IPv6 on Ubuntu 20.04 With Netplan
The instructions below can be applied to any general networking setup where you’re trying to setup default routing. However, this how-to article is customized for configuring IPv6 on our Unmetered VPS platform. With each VPS, we assign an /64 IPv6 subnet, which means you can configure 264. Or to be more precise, 18,446,744,073,709,551,616 addresses on your VPS. There are several ways to enable IPv6 on your Ubuntu 20.04 VPS. One of the most reliable methods is using systemd or netplan.
Netplan is a powerful network configuration abstraction tool built into Ubuntu since version 17. It’s quite handy, especially if you’re a fan of software-defined networking. It uses the YAML language to define your network setup and can control NetworkManager and systemd-networkd backends.
Enabling IPv6 on Ubuntu 20.04
To start, you will need to find the allocated IPv6 subnet. You can easily find this in the “Assigned IPs” section in your VPS welcome email. Or you can check the service details in our client area.
Your allocated IPv6 subnet should look something like this:
2a07:85XX:0:XXX::/64 and from it, you can easily extrapolate the default gateway for your allocated subnet. The gateway is always on the first /128 of the subnet, e.g.:
Once you have this information, you can create your netplan configuration file. Netplan reads the network configuration files from:
/etc/netplan/*.yaml, so you can create the file under any name as long as it ends with the .yaml extension. If you have multiple configuration files dependent on each other, it is wise to implement numbered naming so you can control the loading sequence. For instance, 01-netcfg.yaml 10-backup-network.yaml
Our Ubuntu 20.04 templates already have DHCP configuration for IPv4 in
01-netcfg.yaml, so you can extend it with the following configuration parameters:
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: yes dhcp6: no addresses: - 2a07:85XX:0:XXX::2/64 gateway6: 2a07:85XX::1 nameservers: addresses: - 22.214.171.124 - 126.96.36.199 - 2606:4700:4700::1111 - 2001:4860:4860::8888 routes: - to: 2a07:85XX::1 scope: link
In order to apply the changes, you will need to run
netplan apply and that’s it. Your VPS is now IPv6 ready.
Looking for IPv6 ready VPS servers?
You can verify if the netplan configuration was applied successfully by checking the server syslog or by checking the IPv6 routes e.g.:
root@ubuntu20:~# ip -6 route show 2a07:85XX::1 dev eth0 proto static metric 1024 pref medium 2a07:85XX:0:XXX::/64 dev eth0 proto kernel metric 256 pref medium default via 2a07:85XX::1 dev eth0 proto static metric 1024 onlink pref medium
All that is left to do is to make your allocated IP reachable from all over the internet. And for that, you will need to advertise your IPv6 address on our network with the neighbor solicitation protocol. You can do this by running a simple ping command:
ping -6 black.host
Adding Additional IPv6 Addresses
Once you’ve successfully configured IPv6 on your server, you can add additional addresses under your configuration file’s address key. The addresses can be added as an additional list item in the current format or as an object sequence containing all addresses. Here is an example:
... addresses: - 2a07:85XX:0:XXX::2/64 - 2a07:85XX:0:XXX::3/64 - 2a07:85XX:0:XXX::4/64 ...
Once modifying the netplan configuration, you need to apply the changes and then announce the added IPs using the ping command while specifying the outgoing interface/IP address e.g.:
ping -6 -I 2a07:85XX:0:XXX::3 black.host
Removing Additional IPv6 Address
Removing an additional IPv6 address is quite intuitive. All you need to do is to remove the desired IP from the netplan configuration file and apply the netplan configuration using: