Systemd’s Networkd: Unable to add ipv6 default route

ipv6netplanroutingsubnetsystemd-networkd

I am having a hell of a time getting IPv6 address connectivity set up on my new VPS. I thought I knew what I was doing but apparently networkd disagrees, I keep getting issues when trying to add a default route.

Here is the networking information provided to me by my ISP:

Subnet      2001:19f0:6:2::/64
Gateway     2001:19f0:6::1
Nameserver  2001:4860:4860::8888
Nameserver  2001:4860:4860::8844

Interface:       ens3
OS:              Ubuntu 18.04.02
Systemd version: 237

Current Setup

I can easily set up my IP address and add a route to the gateway with the following systemd file:

[Match]
Name=ens3

[Network]
Address=209.222.17.197/26
Gateway=209.222.17.193
DNS=8.8.8.8

[Network]
Address=2001:19f0:6:2::1337/64

[Route]
Destination=2001:19f0:6::1

I get no errors in journalctl, I can successfully ping 2001:19f0:6::1, but of course I don't have a default gateway or internet access. I can easily use 2001:19f0:6::1 as my default gateway with the following command:
sudo ip -6 route add default via 2001:19f0:6::1

This gives me full ipv6 routing, I can ping ipv6.google.com.

The Problem

I can't seem to get the default gateway set up in networkd, I've spent so many hours trying different combinations of options I think this might be a bug. For example, if I amend my configuration to look like this:

[Match]
Name=ens3

[Network]
Address=209.222.17.197/26
Gateway=209.222.17.193
DNS=8.8.8.8

[Network]
Address=2001:19f0:6:2::1337/64

[Route]
Destination=2001:19f0:6::1

[Route]
Gateway=2001:19f0:6::1
GatewayOnlink=true

I get the following error in the journalctl log:

May 27 19:31:46 public-NY systemd-networkd[2452]: ens3: Could not set route: No route to host

I always see that damn error "no route to host", if there's no route to 2001:19f0:6::1 then why the hell can I ping it?!

I'm fed up with this issue, but I'd like to use netplan and therefore systemd-networkd for my networking. Am I just doing something stupid or is something as critical as networkd really this broken?

Best Answer

It's probably the GatewayOnLink that's causing the problem, because as far as I can see, that gateway is not on link. Your on-link subnet is 2001:19f0:6:2::/64, while the gateway address is not in that subnet -- the /64 that it is in is 2001:19f0:6:0::/64 (extra:0` added for clarity).

Now, how you can manage to ping that gateway address I couldn't tell you -- most likely it's being picked up via RA, which is odd, but not unknown, in a hosting environment -- but in any event, it's not an on-link route, and so therefore networkd is, quite rightly, telling you there is no route to that host using the parameters you have given.