Cobra Forum

Linux => Networking & Wireless => Topic started by: kalpana on Oct 19, 2023, 04:41 AM

Title: network interface gets a wrong route
Post by: kalpana on Oct 19, 2023, 04:41 AM
Running an up-to-date headless Ubuntu server I'm puzzled configuring my networking. My network interface keeps getting a wrong route assigned and therefore can't access internet after a reboot. I'll see:
Code:
$ ip route
default via 192.168.2.254 dev eno1 src 10.0.0.9 metric 202
10.0.0.0/24 dev eno1 proto dhcp scope link src 10.0.0.9 metric 202
192.168.2.254 dev eno1 scope link src 10.0.0.9 metric 202

I've been manually removing this erroneous default route (192.168.2.254) and adding the right one (10.0.0.1), which fixes it until the next reboot.
Code:
$ sudo route del default
$ sudo ip route add default via 10.0.0.1
$ ip route
default via 10.0.0.1 dev eno1
10.0.0.0/24 dev eno1 proto dhcp scope link src 10.0.0.9 metric 202
192.168.2.254 dev eno1 scope link src 10.0.0.9 metric 202

But I want to fix it properly. So I'm using netplan to assign a static ip:
Code:

$ ls /etc/netplan/
99_config.yaml
$ cat /etc/netplan/99_config.yaml

network:
  version: 2
  ethernets:
    eno1:
      dhcp4: no
      dhcp6: no
      addresses:
        - 10.0.0.8/24
      routes:
        - to: default
          via: 10.0.0.1
      nameservers:
          addresses: [10.0.0.1]

And I've removed /etc/network/interfaces to eliminate the possibility that the old ifupdown package does anything. I've actually gone as far as removing the package. Also, I don't have any NetworkManager config files.
Code:
$ ls /etc/network/interfaces*
ls: cannot access '/etc/network/interfaces*': No such file or directory
$ systemctl status NetworkManager
Unit NetworkManager.service could not be found.
$ ls /etc/NetworkManager/
ls: cannot access '/etc/NetworkManager/': No such file or directory
$ sudo apt remove ifupdown
$ apt policy ifupdown
ifupdown:
  Installed: (none)

But still get this mysterious default route to 192.168.2.254 after a reboot. No other machines on my network have this problem. Where can this come from when I've specified a static ip in netplan? Any other config files where this erroneous route could be set?

I'm running version 20.04.6 LTS.
Code:

$ lsb_release -a
No LSB modules are available.
Distributor ID:    Ubuntu
Description:    Ubuntu 20.04.6 LTS
Release:    20.04
Codename:    focal