0

This is ubuntu 20.04.

I stopped and disabled systemd-networkd. Then enabled NetworkManager. But after reboot both services come up. Keeps happening like that. I want to manage my server using nmcli, but not sure how to get it to work (and stop networkd)

  349  systemctl stop systemd-networkd
  350  nmcli dev status
  351  systemctl restart network-manager
  352  systemctl status network-manager
  364  systemctl status systemd-networkd
  365  systemctl disable systemd-networkd
  366  systemctl status NetworkManager
  367  systemctl enable NetworkManager

---after reboot----

# ls -ltr /run/network/
total 4
-rw-r--r-- 1 root root 88 Feb  3 21:50 dynamic-interfaces

# nmcli dev status
DEVICE      TYPE      STATE      CONNECTION
eno1        ethernet  unmanaged  --
eno2        ethernet  unmanaged  --
eno3        ethernet  unmanaged  --
eno4        ethernet  unmanaged  --
enp129s0f0  ethernet  unmanaged  --
enp129s0f1  ethernet  unmanaged  --
enp131s0f0  ethernet  unmanaged  --
enp131s0f1  ethernet  unmanaged  --
enp3s0f0    ethernet  unmanaged  --
enp3s0f1    ethernet  unmanaged  --
idrac       ethernet  unmanaged  --
lo          loopback  unmanaged  --

I am able to login to host via ssh from network on eno1... right now using DHCP, but want to make it static later on.

# ip a s
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
    inet x.x.x.x/24 brd x.x.x.x scope global dynamic eno1
       valid_lft 28733sec preferred_lft 28733sec
3: eno2: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
4: eno3: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
5: eno4: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
6: enp3s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
7: enp129s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
8: enp3s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
9: enp129s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
10: enp131s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether  x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff
11: enp131s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x  brd ff:ff:ff:ff:ff:ff
12: idrac: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether x:x:x:x:x:x brd ff:ff:ff:ff:ff:ff

    


    root@myhost:~#
    root@myhost:~# systemctl status systemd-networkd
    ● systemd-networkd.service - Network Service
         Loaded: loaded (/lib/systemd/system/systemd-networkd.service; enabled-runtime; vendor preset: enabled)
         Active: active (running) since Fri 2023-02-03 21:51:06 UTC; 8min ago
           Docs: man:systemd-networkd.service(8)
       Main PID: 1611 (systemd-network)
         Status: "Processing requests..."
          Tasks: 1 (limit: 309305)
         Memory: 4.1M
         CGroup: /system.slice/systemd-networkd.service
                 └─1611 /lib/systemd/systemd-networkd
    
    Feb 03 21:51:06 myhost systemd[1]: Starting Network Service...
    Feb 03 21:51:06 myhost systemd-networkd[1611]: Enumeration completed
    Feb 03 21:51:06 myhost systemd[1]: Started Network Service.
    Feb 03 21:51:06 myhost systemd-networkd[1611]: eno1: Link UP
    Feb 03 21:51:07 myhost systemd-networkd[1611]: eno1: Gained carrier
    Feb 03 21:51:07 myhost systemd-networkd[1611]: eno1: DHCPv4 address x.x.x.x/24 via x.x.x.x
    root@myhost:~#
    
    
    root@myhost:~# systemctl status NetworkManager
    ● NetworkManager.service - Network Manager
         Loaded: loaded (/lib/systemd/system/NetworkManager.service; enabled; vendor preset: enabled)
         Active: active (running) since Fri 2023-02-03 21:51:10 UTC; 8min ago
           Docs: man:NetworkManager(8)
       Main PID: 1639 (NetworkManager)
          Tasks: 3 (limit: 309305)
         Memory: 14.9M
         CGroup: /system.slice/NetworkManager.service
                 └─1639 /usr/sbin/NetworkManager --no-daemon
    
    Feb 03 21:51:10 myhost NetworkManager[1639]: <info>  [1675461070.5034] manager: (enp3s0f1): new Ethernet device (/or>
    Feb 03 21:51:10 myhost NetworkManager[1639]: <info>  [1675461070.5050] manager: (idrac): new Ethernet device (/org/f>
    Feb 03 21:51:10 myhost NetworkManager[1639]: <warn>  [1675461070.5286] Error: failed to open /run/network/ifstate
    Feb 03 21:51:10 myhost NetworkManager[1639]: <info>  [1675461070.5634] manager: startup complete
    Feb 03 21:51:10 myhost NetworkManager[1639]: <info>  [1675461070.8076] modem-manager: ModemManager not available
    Feb 03 21:51:10 myhost NetworkManager[1639]: <info>  [1675461070.8842] modem-manager: ModemManager now available
    Feb 03 21:52:43 myhost NetworkManager[1639]: <info>  [1675461163.2859] manager: rfkill: Wi-Fi hardware radio set dis>
    Feb 03 21:52:43 myhost NetworkManager[1639]: <info>  [1675461163.2862] audit: op="radio-control" arg="wireless-enabl>
    Feb 03 21:58:03 myhost NetworkManager[1639]: <info>  [1675461483.8856] manager: rfkill: WWAN hardware radio set disa>
    Feb 03 21:58:03 myhost NetworkManager[1639]: <info>  [1675461483.8858] audit: op="radio-control" arg="wwan-enabled" >
    root@myhost:~#

since then I have done this:

modified this file as best as i understood so far:

# cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'  (<----from cloud-init of live dvd install....)
network:
  ethernets:
    eno1:
      addresses: [x.x.x.x/24]
      gateway4: x.x.x.x
      nameservers:
        addresses: [xx.x.x.x]
  version: 2

# netplan apply
# nmcli c s

# nmcli d s
DEVICE      TYPE      STATE      CONNECTION
eno1        ethernet  unmanaged  --
eno2        ethernet  unmanaged  --
eno3        ethernet  unmanaged  --
eno4        ethernet  unmanaged  --
enp129s0f0  ethernet  unmanaged  --
enp129s0f1  ethernet  unmanaged  --
enp131s0f0  ethernet  unmanaged  --
enp131s0f1  ethernet  unmanaged  --
enp3s0f0    ethernet  unmanaged  --
enp3s0f1    ethernet  unmanaged  --
idrac       ethernet  unmanaged  --
lo          loopback  unmanaged  --
#

ip addr is now static, but nmcli still not managing it... and my routing table seem to be changed.

2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 24:6e:96:06:f2:f8 brd ff:ff:ff:ff:ff:ff
    inet x.x.x.x/24 brd x.x.x.x scope global eno1
       valid_lft forever preferred_lft forever

if i stop systemd-networkd and then run netplan apply i get error:

# systemctl stop systemd-networkd
# netplan apply
Failed to reload network settings: No such file or directory
Falling back to a hard restart of systemd-networkd.service

then i tried your suggestion:

# systemctl stop systemd-networkd
# systemctl disable systemd-networkd
# systemctl mask systemd-networkd
Created symlink /etc/systemd/system/systemd-networkd.service → /dev/null.
# systemctl restart NetworkManager

Now it is totally mad:

# netplan apply
Failed to reload network settings: No such file or directory
Falling back to a hard restart of systemd-networkd.service
Failed to restart systemd-networkd.service: Unit systemd-networkd.service is masked.
Traceback (most recent call last):
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 265, in command_apply
    utils.networkctl_reload()
  File "/usr/share/netplan/netplan/cli/utils.py", line 103, in networkctl_reload
    subprocess.check_call(['networkctl', 'reload'])
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['networkctl', 'reload']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/sbin/netplan", line 23, in <module>
    netplan.main()
  File "/usr/share/netplan/netplan/cli/core.py", line 50, in main
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 247, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 61, in run
    self.run_command()
  File "/usr/share/netplan/netplan/cli/utils.py", line 247, in run_command
    self.func()
  File "/usr/share/netplan/netplan/cli/commands/apply.py", line 275, in command_apply
    utils.systemctl('restart', ['systemd-networkd.service'], sync=True)
  File "/usr/share/netplan/netplan/cli/utils.py", line 89, in systemctl
    subprocess.check_call(command)
  File "/usr/lib/python3.8/subprocess.py", line 364, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['systemctl', 'restart', 'systemd-networkd.service']' returned non-zero exit status 1.

I am trying to do away with everything except nmcli / NetworkManager. This is becoming too convoluted.

2
  • /etc/netplan# ls -ltr total 4 -rw-r--r-- 1 root root 115 Feb 2 16:02 00-installer-config.yaml # cat 00-installer-config.yaml # This is the network config written by 'subiquity' network: ethernets: eno1: dhcp4: true version: 2
    – rajeev
    Feb 3, 2023 at 22:16
  • For my curiosity: why do you prefer NM to systemd for your server? Feb 4, 2023 at 2:07

3 Answers 3

0

As a rule running

systemctl disable foo.service

only undoes the [Install] section of the unit file. It could still be brought into execution by wants or dependencies of other systemd units.
If you want to prevent the service from ever running you want to run

systemctl mask foo.service

which will override the unit file with a symlink to /dev/null in /etc so it can't be run.

0

I added renderer directive in netplan config and it resolved the issue. now i can (i did) masked networkd. and restart NetworkManager. everything is under nm now.

0

As you mentioned yourself, the solution was to add the renderer to the netplan config file. The reason why is because the default renderer used by netplan is systemd-networkd, as per following documentation: https://netplan.io/reference

Distribution installers, cloud instantiation, image builds for particular devices, or any other way to deploy an operating system put its desired network configuration into YAML configuration file(s). During early boot, the netplan "network renderer" runs which reads /{lib,etc,run}/netplan/*.yaml and writes configuration to /run to hand off control of devices to the specified networking daemon.

  • Configured devices get handled by systemd-networkd by default, unless explicitly marked as managed by a specific renderer (NetworkManager)

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .