Skip to main content

Hetzner Cloud - IPv6 Setup on Ubuntu 22.04

Hello,

I ordered a VPS Cloud from Hetzner, and it's true that once delivered, you need to configure IPv6.

For my setup, I'm using a CX22 - Cloud, running Ubuntu 22.04.

Start by updating your Cloud server:

apt update && apt upgrade -y

Next, navigate to the 50-cloud-init.yaml file located in netplan:

nano /etc/netplan/50-cloud-init.yaml

Here is the default configuration:

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        eth0:
            addresses:
            - 2a01:XXX:XXX:XXX::1/64
            dhcp4: true
            match:
                macaddress: 96:XX:XX:XX:XX:XX
            nameservers:
                addresses:
                - 2a01:XXX:XXXX::add:1
                - 2a01:XXX:XXXX::add:2
            routes:
            -   on-link: true
                to: default
                via: fe80::1
            set-name: eth0

You can make a backup copy:

cp /etc/netplan/50-cloud-init.yaml /etc/netplan/50-cloud-init.yaml.bck

Now, on line 11, change 2a01:XXX:XXX:XXX::1/64 to 2a01:XXX:XXX:XXX::24/64. For this example, I changed it to ::24.

# This file is generated from information provided by the datasource.  Changes
# to it will not persist across an instance reboot.  To disable cloud-init's
# network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        eth0:
            addresses:
            - 2a01:XXX:XXX:XXX::24/64 # change ::1 to ::24 here
            dhcp4: true
            match:
                macaddress: 96:XX:XX:XX:XX:XX
            nameservers:
                addresses:
                - 2a01:XXX:XXXX::add:1
                - 2a01:XXX:XXXX::add:2
            routes:
            -   on-link: true
                to: default
                via: fe80::1
            set-name: eth0

Save the changes and run the following command:

netplan try

If you see this message:

** (process:16923): WARNING **: 02:56:51.010: Permissions for /etc/netplan/50-cloud-init.yaml are too open. Netplan configuration should NOT be accessible by others.

Press Enter, then run this command to fix the permissions issue:

sudo chmod 600 /etc/netplan/50-cloud-init.yaml

Then, rerun the command:

netplan try

Finally, apply the changes with the following command:

netplan apply

To verify everything is working, try these commands:

curl -6 https://ip.hetzner.com
ping -6 google.com
ip a

MobaXterm