Score:0

Ubuntu 20.04 adding localhost routes with systemd-networkd

in flag

In order to support proxy-arp (sysctl net.ipv4.conf.all.proxy_arp = 1), I need to add host routes for specific IP addresses on my lan pointing to localhost. However, this capability doesn't seem to work with systemd.networkd.

Trying to do so with systemd.networkd fails:

[Match]
Name=lo

[Network]
DHCP=no

[Address]
Address=127.0.0.1/8
Address=::1/128

[Route]
Gateway=127.0.0.1
Destination=172.16.1.74/32
GatewayOnLink=yes

Systemd-networkd produced this error (I've tried with and without the GatewayOnLink line)

lo: Could not set route: Nexthop has invalid gateway. Invalid argument
lo: Failed

I've successfully added routes to non-loopback addresses on other interfaces, it is apparently just this loopback route which is not working:

[Route]
Gateway=172.16.1.15
Destination=172.16.2.0/24

Adding the route manually works great: ip route add 172.16.1.74 via 127.0.0.1

Netplan allowed this back when we were using netplan:

network:
  ethernets:
    lo:
      dhcp4: false
      addresses: [127.0.0.1/8, 0::1/128]
      routes:
        - to: 172.16.1.74/32
          via: 127.0.0.1

Any ideas on how to get systemd-networkd to just do what I asked? I've looked at https://serverfault.com/questions/953198/why-nexthop-has-invalid-gateway-when-it-seems-to-be-defined https://serverfault.com/questions/667319/systemd-networkd-and-direct-routes and https://unix.stackexchange.com/questions/495016/how-to-add-a-static-route-in-systemd-networkd but nothing seems to help.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.