Setting up IPv6 on your VPS at mijn.host

Please note: mijn.host provides you with the web space and resources to use a VPS, however, we are not responsible for the configuration from the moment the VPS is delivered. Because we do not have root access to your VPS, it is your own responsibility to maintain the software and ensure that everything works properly.

 What do you need?

 

Terminology

Configuring the IPv6 address on your VPS involves several steps. This makes use of commands, and the following arguments are included in them. 

Term and explanation

Example value

Jouw_IPv6 = The IPv6 address that applies to your VPS.

2001:xxxx:xxxxx:xxxxx:xxxxx:xxxx:xxxx:yyyy

IPv6_PREFIX = The subnet of your IPv6 address, which is usually 128.

2001:xxxx:xxxxx:xxxxx::/128

IPv6_GATEWAY = Gateway of your IPv6 address.

2001:xxxx:xxxxx:xxxxx:xxxxx:xxxx:xxxx:gggg

 

Step 1: Find your IPv6 address

You can easily find the IPv6 address of your VPS in the Control Panel; once logged in, click on Virtual Private Server.

You can then see your IPv6 address there under network:

 

Step 2: Configure IPv6

All necessary information has now been gathered, log in to your VPS via SSH. Don't remember how? Then the following knowledge base article can help you on your way: https://mijn.host/kb/verbinden-met-ssh/

As explained earlier in the article, there are many ways to configure IPv6:

  • Non-permanent configuration (non-persistent)
  • Persistent configuration on Debian platforms
  • Persistent configuration on Red Hat platforms

 

Non-permanent configuration (non-persistent)

***Please note that this configuration will be removed as soon as you restart the VPS***

 Log in to your VPS via SSH. The following variable details are required:

  • Jouw_IPv6, IPv6_PREFIX, IPv6_GATEWAY
  • Network interface (only if your server does not use eth0)
ip addr add jouw_IPV6/IPV6_PREFIX dev eth0
ip -6 route add IPV6_GATEWAY dev eth0
ip -6 route add default via IPV6_GATEWAY dev eth0


Persistent configuration on Debian platforms

***Always make a backup of your configuration file before making changes***

There are two ways to configure it depending on the operating system on your server.

  • For Debian 11 and earlier, Ubuntu 16.04 and earlier, use the method based on interface files
  • For Ubuntu 17.04 and later, use the method based on the netplan configuration.

 

In some cases, such as with Debian 9, the correct method may not be the one specified above. To verify, check your system to see which one is active. For more information, see: https://netplan.io/

Please note that the exact file names may vary.

The configuration of the interface files:

The best method is to create a configuration file in the /etc/network/interfaces.d/ directory.

 nano /etc/network/interfaces.d/51-cloud-init-ipv6 

This gives you the possibility to separate the IPv6 configuration and revert it in case of errors.

 

Add the following lines to the file. Replace the generic elements (Jouw_IPv6, IPv6_PREFIX and IPv6_GATEWA

Y) and the network interface if your server does not use eth0.

auto eth0
iface eth0 inet6 static
mtu 1500
address Jouw_IPV6
netmask IPV6_PREFIX
post-up /sbin/ip -6 route add IPV6_GATEWAY dev eth0
post-up /sbin/ip -6 route add default via IPV6_GATEWAY dev eth0
pre-down /sbin/ip -6 route del default via IPV6_GATEWAY dev eth0
pre-down /sbin/ip -6 route del IPV6_GATEWAY dev eth0

Next, restart the networking service using one of the following commands:

 service networking restart 

Or

 systemctl restart networking 

If the above method does not work, you can also add the configuration to the following files:

  • /etc/network/interfaces
  • /etc/network/interfaces.d/50-cloud-init.cfg

It is recommended to create a backup of the configuration file, you can create a backup using the following command:

 cp /etc/network/interfaces /etc/network/interfaces.back 

You can revert the changes with the following commands:

rm -f /etc/network/interfaces
cp /etc/network/interfaces.back /etc/network/interfaces 


Configuration with Netplan

The network configuration files are located in the /etc/netplan/ folder. It is recommended to create a backup of the configuration files first. In this case, you copy the 50-coud-init.yaml file with the following commands:

cd /etc/netplan/
mkdir backup
cp 50-cloud-init.yaml backup/50-cloud-init.yaml

Afterwards, you can revert the changes with the following commands:

rm -f /etc/netplan/50-cloud-init.yaml
cp /etc/netplan/backup/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml

Before you make changes, create a copy of the IPv6 configuration file:

cd /etc/netplan
cp 50-cloud-init.yaml 51-cloud-init-ipv6.yaml

Next, edit the 51-cloud-init-ipv6.yaml file and add the IPv6 configuration of your server. Replace the generic elements (Jouw_IPV6, IPV6_PREFIX and IPV6_GATEWAY) and your network interface if you are not already using eth0.

 network:
version: 2
ethernets:
eth0:
dhcp6: no
match:
name: eth0
addresses:
- "YOUR_IPV6/IPv6_PREFIX"
gateway6: "IPv6_GATEWAY"
routes:
- to: "IPv6_GATEWAY"
scope: link

***Please note that the indentation must be exactly right, do not use tab but the space key to create space.***

You can now test the configuration by using the following command:

 netplan try

If it is configured correctly, you can use the following command:

 netplan apply


Persistent configuration on Red Hat and its derivatives (CentOS, AlmaLinux, etc.).

The network configuration files are located at this location: /etc/sysconfig/network-scripts/. As indicated earlier, it is recommended to make a backup of the relevant configuration file. If your network interface is eth0, then your configuration file is ifcf-eth0. You can copy the file by using the following commands:

cd /etc/sysconfig/network-scripts/
mkdir backup
cp ifcfg-eth0 backup/ifcfg-eth0

You can revert the changes with the following commands:

rm -f /etc/sysconfig/network-scripts/ifcfg-eth0
cp /etc/sysconfig/network-scripts/backup/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0

Next, edit the ifcfg-eth0 file and add the IPv6 configuration of your server. Replace the generic elements (Jouw_IPV6, IPV6_PREFIX and IPV6_GATEWAY).

IPV6INIT=yes
IPV6ADDR=YOUR_IPV6/IPV6_PREFIX
IPV6_DEFAULTGW=IPV6_GATEWAY
p>Are you using CentOS 7? Then you also need to create a routing file.

Create a file with sudo privileges that specifies the default IPv6 route:

 # touch /etc/sysconfig/network-scripts/route6-eth0

Edit the file and add the following lines, replacing the generic elements (IPV6_GATEWAY and eth0 interface) with your own details.

IPV6_GATEWAY dev eth0
default via IPV6_GATEWAY

Restart the network service to apply the new configuration:

service networking restart
systemctl restart networking


Step 3 Verify and test the connection

To verify that the new configuration works, there are different commands per operating system:

For GNU/Linux based systems with eth0:

 ip -6 addr show eth0
2: eth0:
 ifconfig eth0
eth0 Link encap:Ethernet HWaddr ab:cd:ef:gf:ij:kl
inet addr:aa.bb.cc.dd Bcast:aa.bb.cc.ee Mask:255.255.255.255
inet6 addr: 2001:xxxx:xxxx:xxxx:xxxx:xxxx:zzzz/128 Scope:Global
inet6 addr: fe80::f816:3eff:fec0:c336/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

To test the connection you can use the following command:

 ping6 proof.google.net 

If, despite the changes, IPv6 is not working on your server, it is possible in exceptional cases that you need to make additional adjustments. In such cases you can follow these steps:

 

  • Depending on your operating system, change your prefix or netmask of your IP address from /128 to /64. This ensures that your IPv6 gateway is added to your subnet.
  • You may need to restart the entire server and not just the network service. 


Still have questions? Get in touch.