NixOS on Hetzner cloud servers: IPv6

This is my networking setup on Hetzner Cloud:

# Networking
networking.defaultGateway6 = { address = "fe80::1"; interface = "eth0"; };
networking.interfaces.eth0.ipv6.addresses = [ { address = "${cfg.ipv6}"; prefixLength = 64; } ];

cfg.ipv6 is the assigned IPv6 address (...::2, not ...::1)

EDIT: Actually it seems to be ...::2 for ARM servers and ...::1 for x86 servers

You have the whole subnet, which is a /64, which means the last 64 bits are free for you to pick from. Everything in there will work.

I would recommend using the networkd configuration as described in the wiki:

https://wiki.nixos.org/wiki/Install_NixOS_on_Hetzner_Cloud#Network_configuration

Hm at least when I tried back then it did not work with ::1, but that may also be a configuration issue on my end

I am a little confused here. It says…

replace this subnet with the one assigned to your instance

…but the IPv4 and the IPv6/subnet are assigned dynamically.
This cannot really go into the configuration.

What am I missing?

The addresses/subnets are printed very prominently in the server view as well on its networking tab in the cloud console. They are statically allocated, but can certainly be configured dynamically (DHCP, maybe even RA, I don’t know).

Yeah, that’s a given - but that does not fly for any automation.
But I eventually figured it out. They configure the machines via cloud-init.

1 Like

Check ip -6 neigh, most likely the firewall is blocking neighbor discovery.

The IPv6 block can be obtained via their metadata server.

curl -fsS http://169.254.169.254/hetzner/v1/metadata/network-config | sed -En 's|.*address: (2a01.*)|\1|p'

This seems to be enough for me

          services.cloud-init = {
            enable = true;
            network.enable = true;
            settings = {
              datasource_list = [
                "Hetzner"
                "None"
              ];
              disable_root = false;
              users = [ ];
            };
          };

from dd-install/dd-nixos/flake.nix at ef9b13051cfca6dc3ed784f0c4009803bf94633e · tcurdt/dd-install · GitHub