systemd-networkd refuses to apply route with gateway out of the NIC's subnet

Bug #2073869 reported by Alberto Contreras
16
This bug affects 3 people
Affects Status Importance Assigned to Milestone
cloud-init (Ubuntu)
Invalid
Undecided
Unassigned
Focal
Confirmed
Undecided
Unassigned
netplan.io (Ubuntu)
Invalid
Undecided
Unassigned
Focal
Confirmed
Undecided
Unassigned
systemd (Ubuntu)
Confirmed
Undecided
Unassigned
Focal
Confirmed
Undecided
Unassigned

Bug Description

The version of systemd-networkd on Ubuntu Focal refuses to configure a route due to the fact that the address of the gateway is outside of the subnet of the NIC. The onlink option is required. This does not happen on Jammy and Noble.

Steps to reproduce:

```
# ip a
2: ens2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether de:00:00:62:c5:e9 brd ff:ff:ff:ff:ff:ff
    inet 212.47.xxx.xxx/32 scope global dynamic ens2
       valid_lft 800sec preferred_lft 800sec
    inet6 2001:xxx:xxx:xxxx:xxxx:xx:xxxx:c5e9/64 scope global
       valid_lft forever preferred_lft forever
    inet6 fe80::dc00:ff:fe62:c5e9/64 scope link
       valid_lft forever preferred_lft forever

# cat /etc/netplan/50-cloud-init.yaml
version: 2
ethernets:
    ens2:
        addresses:
        - 2001:xxx:xxx:xxxx:xxxx:xx:xxxx:c5e9/64
        dhcp4: true
        routes:
        - to: 169.254.42.42/32
            via: 62.210.0.1
        - to: ::/0
            via: fe80::dc00:ff:fe62:c5ea

# netplan apply

# journalctl -b -u systemd-networkd
...
Jul 18 10:05:59 focal systemd-networkd[668]: ens2: Could not set route: Nexthop has invalid gateway. Network is unreachable
...
```

Is this something that netplan fixes and presents it in a better way to networkd in newer versions? Or is this something that networkd improves in newer versions?

cloud-init's upstream bug: https://github.com/canonical/cloud-init/issues/5523

Changed in cloud-init (Ubuntu):
status: New → Invalid
Revision history for this message
Lukas Märdian (slyon) wrote :

This sounds like it needs a backported feature for systemd-networkd in Focal, i.e. something that got fixed in networkd.

Did you try adding the "on-link: true" setting to your static routes in the Netplan configuration? That might be able to work around the issue.

Changed in netplan.io (Ubuntu):
status: New → Invalid
Revision history for this message
Alberto Contreras (aciba) wrote :

Yes, Lukas, adding "on-link: true" to the static routes in the Netplan configuration fixes the issue.

Revision history for this message
Louis Bouchard (louis) wrote :

Hello Lukas,

I am the person who raised the issue with the cloud-init folks about this difference.

I would not call it a fix, but rather a workaround for a configuration that behaves differently with systemd on focal version.

Now whether it is a simple issue to be fixed on systemd is another story. The "on-link: true" will be used for our cloud-init issue but it would still be nice to have the same behavior on focal.

TIA,

...Louis

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in cloud-init (Ubuntu Focal):
status: New → Confirmed
Changed in netplan.io (Ubuntu Focal):
status: New → Confirmed
Changed in systemd (Ubuntu Focal):
status: New → Confirmed
Changed in systemd (Ubuntu):
status: New → Confirmed
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.