8

I'm trying to achieve the equivalent of the ip command below via networkd without success.

ip route add default via fe80::1 dev eth0

My networkd configuration looks like below and brings up the network successfully apart from the default ipv6 routing. I've tried adding and removing GatewayOnLink=yes without any success. Running the command above after startup brings up ipv6 connectivity but I would prefer to do this via networkd configuration.

/etc/systemd/network/00-eth0.network
----

[Match]
Name=eth0

[Network]
DHCP=no
DNS=8.8.8.8

[Address]
Label=static-ipv4
Address=X.X.X.X/32
Peer=Y.Y.Y.Y

[Address]
Label=static-ipv6
Address=X:X:X:X::1/64

[Route]
Gateway=fe80::1
Gateway=Y.Y.Y.Y
GatewayOnlink=yes 

This is for a Hetzner cloud server, I don't have any other IPV6 enabled machines to rule out something specific about their setup. Systemd is version 238 running on coreos.

2
  • ok, not sure how relevant it is :) Other than the ipv6 routing all the configuration in the file is being applied. Commented Mar 29, 2019 at 15:26
  • Try removing the [Address] and [Route] headings and see if that works? Commented Apr 27, 2019 at 2:14

2 Answers 2

5

You cannot have two Gateway directives in one [Route] block.

From reference: https://systemd.network/systemd.network.html#%5BRoute%5D%20Section%20Options

Specify several "[Route]" sections to configure several routes.

This is what works for me:

[Route]
Gateway=fe80::1
GatewayOnLink=yes

[Route]
Gateway=Y.Y.Y.Y
GatewayOnLink=yes

This way the first block adds a default IPv6 routing entry, equivalent to

ip -6 route add default via fe80::1 proto static

If you for whatever reason don't want the proto static part, add Proto=boot to the networkd configuration (it's the default for iproute2).

0

Not the answer I'm hoping to accept since it involves configuration outside networkd, but it does bring my IPv6 routing up reliably:

~ $ cat /etc/systemd/system/ipv6-routing.service 
[Unit]
Description=Setup ipv6 routing
After=network-online.target
Requires=network-online.target

[Service]
Type=oneshot
ExecStart=/usr/bin/ip route add default via fe80::1 dev eth0
RemainAfterExit=true

[Install]
WantedBy=multi-user.target

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.