Číst česky →

How to configure IPv6 on your VPS

3 min read Hukot net Linux Basics VPS IPv6

Contents Setup Verification

This tutorial shows how to set up an IPv6 address by hand on a VPS in the Hukot.net network, on Windows, AlmaLinux, Debian, Ubuntu and FreeBSD. The examples use these addresses:

What Address
Hukot.net network 2a02:25b0:aaaa::/48
Main IP address 2a02:25b0:aaaa:CAFE::CAFE
Secondary IP address 2a02:25b0:aaaa:CAFE::1234
Gateway 2a02:25b0:aaaa::1

Replace CAFE with the range Hukot.net assigned to you. The addresses are set with the /48 mask of the whole network, because only then is the gateway 2a02:25b0:aaaa::1 directly reachable. The secondary address is optional; it shows what to do if you want more than one IPv6 address.

On Linux and FreeBSD, run the commands as root; on Windows, in PowerShell run as administrator.

A wrong network setting can cut off your SSH or Remote Desktop connection. Before you start, make sure you can reach the server console.

Setup #

Windows
  1. Find the name of the interface you are going to configure:

    netsh interface show interface
    

    The output can look like this:

    Admin State    State          Type             Interface Name
    -------------------------------------------------------------------------
    Enabled        Connected      Dedicated        Ethernet
    
  2. Set the addresses:

    netsh interface ipv6 set global randomizeidentifiers=disabled
    netsh interface ipv6 add address "Ethernet" 2a02:25b0:aaaa:CAFE::CAFE/48
    netsh interface ipv6 add address "Ethernet" 2a02:25b0:aaaa:CAFE::1234/48
    
  3. Set the gateway:

    netsh interface ipv6 add route ::/0 "Ethernet" 2a02:25b0:aaaa::1
    
  4. Set the DNS servers:

    netsh interface ipv6 add dnsserver "Ethernet" 2001:4860:4860::8888
    netsh interface ipv6 add dnsserver "Ethernet" 2001:4860:4860::8844 index=2
    

Replace Ethernet with the interface name from the first step.

AlmaLinux / Rocky Linux
  1. Find the name of the network connection:

    nmcli connection show
    
  2. Set the addresses and the gateway, then activate the connection again:

    nmcli connection modify "<connection>" ipv6.method manual ipv6.addresses "2a02:25b0:aaaa:CAFE::CAFE/48, 2a02:25b0:aaaa:CAFE::1234/48" ipv6.gateway 2a02:25b0:aaaa::1
    nmcli connection up "<connection>"
    

Replace <connection> with the name from the first step (the NAME column, for example eth0 or System eth0). This works on AlmaLinux, Rocky Linux and RHEL 8 or newer.

Debian
  1. Find the interface name (for example eth0 or ens18):

    ip link
    
  2. Add these lines to the end of /etc/network/interfaces:

    iface eth0 inet6 static
        address 2a02:25b0:aaaa:CAFE::CAFE/48
        gateway 2a02:25b0:aaaa::1
        up ip -6 addr add 2a02:25b0:aaaa:CAFE::1234/48 dev eth0
    
  3. Restart networking:

    systemctl restart networking
    

Replace eth0 with the interface name from the first step.

Ubuntu
  1. Open the network configuration in /etc/netplan/ (usually a single file, for example 50-cloud-init.yaml).

  2. Add the IPv6 addresses to the interface's addresses list and the default route to its routes list. Keep the existing IPv4 addresses and routes:

    network:
      version: 2
      ethernets:
        eth0:
          addresses:
            - 2a02:25b0:aaaa:CAFE::CAFE/48
            - 2a02:25b0:aaaa:CAFE::1234/48
          routes:
            - to: "::/0"
              via: "2a02:25b0:aaaa::1"
    
  3. Try the configuration:

    netplan try
    

    If the connection still works, confirm with Enter. Without confirmation, netplan goes back to the previous configuration after two minutes.

FreeBSD
  1. Find the interface name (for example vtnet0 or em0):

    ifconfig
    
  2. Add these lines to /etc/rc.conf:

    ifconfig_vtnet0_ipv6="inet6 2a02:25b0:aaaa:CAFE::CAFE prefixlen 48"
    ifconfig_vtnet0_alias0="inet6 2a02:25b0:aaaa:CAFE::1234 prefixlen 48"
    ipv6_defaultrouter="2a02:25b0:aaaa::1"
    
  3. Restart networking and routing:

    service netif restart && service routing restart
    

Replace vtnet0 with the interface name from the first step.

Verification #

Check that the server reaches the internet over IPv6:

ping -6 -c 4 2001:4860:4860::8888

On Windows, use ping -6 2001:4860:4860::8888. If replies come back, IPv6 is set up.