Systemd-networkd: static IP device not able to reach non-local addresses

@neuberfran @dellgreen I know that this is an old topic, but I hope I can reach you this way. We are facing the same issue using systemd-networkd.

We have a static IP where we can reach other machines that are in the same network. We are not able to reach addresses that should be reachable using the gateway.

What we found out so far is that if we request the route for an external IP is it missing the source address.

I’m curious if you found a solution to get static IP addresses working or are willing to investigate this further.

If you could paste your systemd-networkd config file for your interface, that would be great

Also if you can paste the output of

networkctl status

Our network config is as below.

$ cat /usr/lib/systemd/network/10-lan.network 
[Match]
Name=eth0

[Network]
Address=169.254.1.2/16
DNS=169.254.1.1
Gateway=169.254.1.1

The output of ping

$ ip route get 8.8.8.8
8.8.8.8 via 169.254.1.1 dev eth0 
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
^C
--- 8.8.8.8 ping statistics ---
9 packets transmitted, 0 packets received, 100% packet loss
$ ping -I 169.254.1.2 8.8.8.8
PING 8.8.8.8 (8.8.8.8) from 169.254.1.2: 56 data bytes
64 bytes from 8.8.8.8: seq=0 ttl=116 time=12.576 ms
64 bytes from 8.8.8.8: seq=1 ttl=116 time=8.341 ms
64 bytes from 8.8.8.8: seq=2 ttl=116 time=9.124 ms

As you can see when we specify source address it is working.
The source is also missing when requesting a route using ip route get.

8.8.8.8 via 169.254.1.1 dev eth0 

And the output of

networkctl

Networkctl status:

$ networkctl status
*        State: degraded           
  Online state: online             
       Address: 169.254.1.2 on eth0
       Gateway: 169.254.1.1 on eth0
           DNS: 169.254.1.1

Aug 08 09:10:09 sonor11AEDA systemd-networkd[169]: lo: Gained carrier
Aug 08 09:10:09 sonor11AEDA systemd-networkd[169]: Enumeration completed
Aug 08 09:10:09 sonor11AEDA systemd[1]: Started Network Configuration.
Aug 08 09:10:09 sonor11AEDA systemd-networkd[169]: eth0: Configuring with /usr/lib/systemd/network/10-lan.network.
Aug 08 09:10:09 sonor11AEDA systemd-networkd[169]: eth0: Link UP
Aug 08 09:10:09 sonor11AEDA systemd[1]: Starting Wait for Network to be Configured...
Aug 08 09:10:09 sonor11AEDA systemd-networkd[169]: eth0: Gained carrier
Aug 08 09:10:16 sonor11AEDA systemd[1]: Finished Wait for Network to be Configured.
Aug 08 09:10:29 sonor11AEDA systemd[1]: Reloading Network Configuration...
Aug 08 09:10:29 sonor11AEDA systemd[1]: Reloaded Network Configuration.

networkctl:


$ networkctl 
IDX LINK TYPE     OPERATIONAL SETUP     
  1 lo   loopback carrier     unmanaged
  2 eth0 ether    degraded    configured
  3 usb0 gadget   off         unmanaged
  4 sit0 sit      off         unmanaged

4 links listed.

First change to private routable ipv4 address range and not the self-assigned (link-local) IP range.

https://www.rfc-editor.org/rfc/rfc3927

We have tried it with a non link-local address as you asked and it works as expected.

The thing is that we want to use autoipd to build a network with multiple devices. One of those devices is a gateway which the other devices should use to reach the internet. We wanted to switch from autoipd to static since those systems can be big and have issues to find a new address when rebooting. This we also used in the past and it was working.

The strange thing is that when we configure the network from the command-line it’s working fine:


ip address flush dev eth0
ip route flush dev eth0
ip address add 169.254.1.2/16 brd + dev eth0
ip route add 169.254.1.1 dev eth0
ip route add default via 169.254.1.1 dev eth0

So it looks like it has to do with something in systemd-networkd. And that we could not keep the scenario and we have to find an other way to work around our problem.

In the link local setup, run the ‘route’ command to see if systemd is actually adding a gateway route to the kernels ip routing table. It’s probably not as its link local, which would explain why it probably works as you are explicitly adding a route entry yourself as per your last test

I believe you can add explicit routes in the systemd config file

After some fiddling around it seems that it’s a change in systemd-networkd. The older versions are adding the routes that we would expect.

Thanks for helping out!

For people looking for a solution:
We decide to use LinkLocal during the device discovery. After that based on some logic we switch to static IP address in the private network range. With this logic, we also define a gateway in the system that can be used by the other devices.
This way we comply with the RFC and can use new versions of systemd-networkd.

1 Like

Glad to hear it worked out @bobhobelman. Are you okay to mark the last post as solution?

Greetz,
Josef