Ubuntu 20.04 NetworkManager ignoring eth0 configuration? Netplan configuration abandoned?

1.1k views Asked by At

Until sometime last night, my UBUNTU 20.04 system was working fine with this configuration file at /etc/netplan/01-network-manager-all.yaml

# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    eth0:
      dhcp4: no
      addresses:
        - 192.168.1.6/24
      gateway4: 192.168.1.254
      nameservers:
        addresses: [192.168.1.2]

This has been working great for a couple of years, but sometime during the evening, connection to 192.168.1.6 was lost from other servers (I know because I had ssh connections that were dropped during the night).

Upon investigation I found that the (normally headless) server had a new IP address (.92 rather than .6), and apparently this configuration file is no longer applicable.

I found that network-manager is in the /etc/init.d/ directory which seems to mean that, for whatever reason, the system is now ignoring that previous configuration. It's a mystery to me why this would suddenly change.

Anyway, I found how to configure NetworkManager for the result I want, and came up with this, which I placed into (new file) /etc/NetworkManager/conf.d/ethernet.conf:

[802-3-ethernet]
auto-negotiate=true
mac-address=b4:2e:99:a2:58:77

[connection]
id=Wired connection 1
uuid=06563f32-7cd9-3ee1-ac71-e5bb775a4840
type=802-3-ethernet
timestamp=0

[ipv6]
method=ignore

[ipv4]
method=manual
dns=192.168.1.2
address1=192.168.1.6/24,192.168.1.254

(I got the uuid value from 'nmcli conn show' and I got the mac addr from 'ip a show eth0')

dennis@velmicro:/etc/NetworkManager   01/10 10:01:12
> nmcli conn show
NAME                 UUID                                  TYPE      DEVICE 
Wired connection 1   06563f32-7cd9-3ee1-ac71-e5bb775a4840  ethernet  eth0   
ls2021.lovelady.com  a4fa8d23-a06d-4955-bfd9-5d7de76584c2  wifi      wlan0  
dennis@velmicro:/etc/NetworkManager   01/10 10:01:30
> ip a show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether b4:2e:99:a2:58:77 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.92/24 brd 192.168.1.255 scope global dynamic noprefixroute eth0
       valid_lft 84428sec preferred_lft 84428sec

Here's what /etc/NetworkManager/NetworkManager.conf looks like:

[main]
plugins=ifupdown,keyfile

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

[keyfile]
unmanaged-devices=*,except:type:wifi,except:type:wwan,except:type:ethernet

Restarting NetworkManager, and even a complete reboot seems to produce no errors and yet the configuration is apparently ignored: the 192.168.1.92 address persists.

What am I missing to make this system static IP to the address I need?

Bonus points: How would I determine what caused the sudden (apparent) switch to NetworkManager from netplan?

1

There are 1 answers

0
Dennis On BEST ANSWER

The following commands, entered at the command line as user root, solved this problem:

nmcli con modify 06563f32-7cd9-3ee1-ac71-e5bb775a4840 ipv4.address 192.168.1.6/24
nmcli con modify 06563f32-7cd9-3ee1-ac71-e5bb775a4840 ipv4.gateway 192.168.1.254
nmcli con modify 06563f32-7cd9-3ee1-ac71-e5bb775a4840 ipv4.dns "192.168.1.2"
nmcli con modify 06563f32-7cd9-3ee1-ac71-e5bb775a4840 ipv4.method manual
nmcli con modify 06563f32-7cd9-3ee1-ac71-e5bb775a4840 ipv4.dns-search "lovelady.com"
nmcli con modify 06563f32-7cd9-3ee1-ac71-e5bb775a4840 ipv6.method disabled
nmcli connection up 06563f32-7cd9-3ee1-ac71-e5bb775a4840

After executing those commands, the following configuration could be found in /etc/NetworkManager/system-connections/Wired\ connection\ 1.nmconnection (it was created for me)

[connection]
id=Wired connection 1
uuid=06563f32-7cd9-3ee1-ac71-e5bb775a4840
type=ethernet
autoconnect-priority=-999
interface-name=eth0
permissions=
timestamp=1673626973

[ethernet]
mac-address-blacklist=

[ipv4]
address1=192.168.1.6/24,192.168.1.254
dns=192.168.1.2;
dns-search=lovelady.com;
method=manual

[ipv6]
method=disabled

[proxy]

The placement of a device configuration into the /etc/NetworkManager/conf.d structure was a mistake. No device configurations should be placed into that directory.

Command journalctl -u NetworkManager.service (executable by any user) ultimately helped reveal what was going on, and why the configuration file I created did not have the desired effect.

All device configurations should go under /etc/NetworkManager/system-connections/ and ideally should be created via a sequence of nmcli commands as above.

This device is now (again) configured as I like. Note that the former configuration file (/etc/netplan/01-network-manager-all.yaml) is no longer used by the system, for an unknown reason. ls -lu /etc/netplan/01* reveals that it has not been read in several days, despite a series of reboots.