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

**URL:** <https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560>\
**Category:** General Discussions\
**Tags:** systemd, network\
**Created:** [January 18, 2023, 2:58pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560 "2023-01-18T14:58:30Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![bobhobelman](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bobhobelman/32/1818_2.png) [@bobhobelman](https://hub.mender.io/u/bobhobelman)\
**Post date:** [January 18, 2023, 2:58pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/1 "2023-01-18T14:58:30Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [January 18, 2023, 3:27pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/2 "2023-01-18T15:27:30Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [January 18, 2023, 3:37pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/3 "2023-01-18T15:37:04Z")

</div>

Also if you can paste the output of

`networkctl status`

---

<div class="post-metadata">

**Author:** ![bobhobelman](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bobhobelman/32/1818_2.png) [@bobhobelman](https://hub.mender.io/u/bobhobelman)\
**Post date:** [January 18, 2023, 3:37pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/4 "2023-01-18T15:37:59Z")

</div>

Our network config is as below.

```auto
$ 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`

```auto
$ 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`.

```auto
8.8.8.8 via 169.254.1.1 dev eth0 

```

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [January 18, 2023, 3:38pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/5 "2023-01-18T15:38:01Z")

</div>

And the output of

`networkctl`

---

<div class="post-metadata">

**Author:** ![bobhobelman](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bobhobelman/32/1818_2.png) [@bobhobelman](https://hub.mender.io/u/bobhobelman)\
**Post date:** [January 18, 2023, 3:41pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/6 "2023-01-18T15:41:24Z")

</div>

Networkctl status:

```auto
$ 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:

```auto

$ 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.

```

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [January 18, 2023, 3:43pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/7 "2023-01-18T15:43:13Z")

</div>

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

> **[Private network](https://en.wikipedia.org/wiki/Private_network)**
>
> In Internet networking, a private network is a computer network that uses a private address space of IP addresses. These addresses are commonly used for local area networks (LANs) in residential, office, and enterprise environments. Both the IPv4 and the IPv6 specifications define private IP address ranges.  
> Private network addresses are not allocated to any specific organization. Anyone may use these addresses without approval from regional or local Internet registries. Private IP address spac...

[https://www.rfc-editor.org/rfc/rfc3927](https://www.rfc-editor.org/rfc/rfc3927)

---

<div class="post-metadata">

**Author:** ![bobhobelman](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bobhobelman/32/1818_2.png) [@bobhobelman](https://hub.mender.io/u/bobhobelman)\
**Post date:** [January 18, 2023, 4:11pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/8 "2023-01-18T16:11:02Z")

</div>

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:

```auto

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.

---

<div class="post-metadata">

**Author:** ![dellgreen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/dellgreen/32/85_2.png) [@dellgreen](https://hub.mender.io/u/dellgreen)\
**Post date:** [January 18, 2023, 4:50pm UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/9 "2023-01-18T16:50:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![bobhobelman](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bobhobelman/32/1818_2.png) [@bobhobelman](https://hub.mender.io/u/bobhobelman)\
**Post date:** [January 19, 2023, 11:04am UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/10 "2023-01-19T11:04:45Z")

</div>

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`.

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [January 19, 2023, 11:11am UTC](https://hub.mender.io/t/systemd-networkd-static-ip-device-not-able-to-reach-non-local-addresses/5560/11 "2023-01-19T11:11:47Z")

</div>

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

Greetz,  
Josef
