Score:2

netplan does not implement the route to gateway, in Ubuntu 22.04

cl flag

sorry if this is trivial ... but I do not seem to be able to get netplan to set the proper route to the default gateway. I have to manually set it using 'sudo route add default gw [...]' to enable the server to reach the internet.

This is my current netplan configuration (in /etc/netplan/00-installer-config.yaml):


network:
  version: 2
  renderer: networkd  
  ethernets:
    eno1:
      dhcp4: no
    eno2:
      dhcp4: no
    enp33s0f0:
      dhcp4: no
    enp33s0f1:
      dhcp4: no
    ens1f0:
      addresses:
        - [xxx].[yy].[zz].124/29
      routes:
        - to: default
          via: [xxx].[yy].[zz].121
      nameservers:
        addresses: [redacted]
      dhcp4: no
      dhcp6: no
    ens1f1:
      dhcp4: no


This sets the IP-number correctly, and I can connect from a neighboring server. However, 'route -n' only shows this:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
[xxx].[yy].[zz].120   0.0.0.0         255.255.255.248 U     0      0        0 ens1f0

... meaning there is no route to the actual gateway. I have to manually set it using the 'route' command, like so:

sudo route add default gw [xxx].[yy].[zz].121 ens1f0

... then everything is fine, including DNS; but this does not survive reboot. Any idea what I am doing wrong? I have tried using the 'on-link: true' setting, but that did not work either.

Thank you very much for any help / insights !

Score:0
is flag

don't have enough points to comment. I had the same problem, thinking some netplan or ubuntu system issue, turned out that I had a typo on gateway being 192.68.1.1 instead of 192.168.1.1 in Yaml definition. Didn't find out until I checked /run/systemd/network/10-netplan-ens8.network

Score:0
ua flag

I just tested your exact configuration file on a fully patched ubuntu 22.04 server and only adjusted the interface name and IP addresses and this is working perfectly.

Perhaps a silly question but did you do a: "netplan apply" after your configuration changes?

CvM_curious avatar
cl flag
Dear proxx, yes I did. Before "netplan apply", this is what "ip route" reports (it includes the route that I had to add manually): default via [xxx].[yy].[zz].121 dev ens1f0 [xxx].[yy].[zz].120/29 dev ens1f0 proto kernel scope link src [xxx].[yy].[zz].124 after running "sudo netplan apply", the first line is removed: [xxx].[yy].[zz].120/29 dev ens1f0 proto kernel scope link src [xxx].[yy].[zz].124
proxx avatar
ua flag
YAML uses true or false instead of no/yes. Really the only thing looking funny, also a wild trailing space but that should not cause issues. yamllint complained about it and its right!
CvM_curious avatar
cl flag
one more observation: whenever I run "netplan apply", about two seconds later I see a bunch of lines like this in the syslog. Could this be an issue ? Dec 16 14:20:41 sirius ModemManager[2362]: <info> [base-manager] couldn't check support for device '/sys/devices/pci0000:20/0000:20:03.1/0000:21:00.0': not supported by any plugin Dec 16 14:20:41 [xxx] ModemManager[2362]: <info> [base-manager] couldn't check support for device '/sys/devices/pci0000:20/0000:20:03.1/0000:21:00.1': not supported by any plugin
proxx avatar
ua flag
That is suspicious but you are not using a modem right? Did you try setting the values to true/false ?
CvM_curious avatar
cl flag
no, I'm not using a modem ... standard ethernet port/cabling. Also, I have now set the values to true/false, and removed the trailing spaces. Still no avail ... alas, for now I've just created a crontab entry for root: @reboot sudo route add default gw ... that does what I need. Still weird: the netplan mechanisms clearly is trying to do something: it manipulates the iptables and kicks out my manual route. Just cannot figure out why it would not implement the gateway as instructed ... sigh.
proxx avatar
ua flag
Too bad! Hopefully someone else here can come up with a possible reason. Have a nice day!
Cyrus Raoufi avatar
cd flag
Guys, I have the exact same problem!
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.