63

I am learning about Linux networking on my Kubuntu 18.04 workstation, and I see there that both NetworkManager and networkd-dispatcher are running:

oleg@eclectic:~$ sudo ps -ef | grep -i net
root        56     2  0 Oct11 ?        00:00:00 [netns]
root      1097     1  0 Oct11 ?        00:00:02 /usr/sbin/NetworkManager --no-daemon
root      1098     1  0 Oct11 ?        00:00:00 /usr/bin/python3 /usr/bin/networkd-dispatcher --run-startup-triggers
root      1250     1  0 Oct11 ?        00:00:02 /usr/sbin/inetd
root      1593  1097  0 Oct11 ?        00:00:00 /sbin/dhclient -d -q -sf /usr/lib/NetworkManager/nm-dhcp-helper...

NetworkManager seems to be configured to handle "everything" by netplan:

oleg@eclectic:~$ cat /etc/netplan/01-network-manager-all.yaml 
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager

I believe that netplan would hand everything off to networkd if NetworkManager was not installed.

There are also a bunch of files in /etc/network/, and I am not sure what is handling those. A lot of packages seem to use this directory:

oleg@eclectic:~$ dpkg -S /etc/network
avahi-daemon, ifupdown2, wpasupplicant, openvpn, postfix, netbase, avahi-autoipd, wireless-tools, clamav-freshclam: /etc/network

My initial thoughts after some Googling are that NetworkManager and networkd are both running, but netplan generates configuration such that only one is actually doing something. But I do not know how I would verify this, figure out the chain of operations, or configure it to suit my nefarious plans for dummy0.

Question: How exactly are NetworkManager, networkd, and netplan working together? In other words, as the computer boots up, which processes hand what of to what other processes? How do tools from packages like net-tools, ifupdown2, and iproute2 and directories like /etc/network/ fit into all this? And finally, how can I figure this out myself and learn the details using the command line?

Update: I am not looking for a high-level overview. Rather, I want to know how these components are interacting, conflicting, or avoiding conflict on the kernel level or similar.

0

3 Answers 3

46

systemd-networkd when its enabled honors configurations in /etc/systemd/network

Whereas NetworkManager will follow some automatic rules like it will try to connect to a wired connection if it finds one.

Both are enabled and disabled as systemd services and systemd using udev creates the device files for the network adapters. Generally you probably shouldn't have both enabled at the same time but if you do you'd need to be careful that their configurations don't conflict.

netplan before either network manager starts creates configurations for either based on its own configuration. In this way netplan is really a configuration abstraction and wheather it uses systemd-networkd or NetworkManager is part of the configuration.

iproute2 is a package of tools for configuring network interfaces at the command line. It includes link configuration similar to network managers and the old ifconfig. While net-tools, ipupdown and ifupdown2 use network configurations in /etc/network/interfaces to configure and deconfigure interfaces.

ifupdown or its other versions can be used to manage networks but its not automatic but a systemd service can be used to start it at boot.

ifupdown2 uses dependency graphs similar to what systemd does but with network interfaces. Further it acts as an abstraction to other tools like iproute2

5
  • 3
    Thank you for the compare/ contrast, but I was looking for more about how these components interact with each other, on a much deeper level. For example, what exactly happens in the kernel when both systemd and NetworkManager try to control the same interface at the same time? What do the iproute2/ ifupdown tools do in the kernel that conflicts (or avoids conflict) with networkd/ NetworkManager? What commands can I use to see which tools did what to which interfaces (on the udev/ kernel level)? Commented Oct 19, 2018 at 17:11
  • Best explanation I've seen so far as there is general confusion with many explanations claiming that netplan is either NetworkManager or systemd-networkd, but not both. Some links would have been helpful. E.g. manpages.ubuntu.com/manpages/cosmic/man5/netplan.5.html Commented Apr 1, 2019 at 7:27
  • After reading this I expect to find configuration files in /etc/systemd/network but in my Ubuntu 19.10 with systemd-networkd enabled and running, that directory is empty. However I find files in /lib/systemd/network. Is this a new config? Rogue ubuntu? An error? Commented Jan 6, 2020 at 21:05
  • 1
    @StephenBoston That's answered in unix.stackexchange.com/questions/206315/…
    – Timothy Gu
    Commented Jan 14, 2020 at 7:11
  • 1
    Looks like nobody knows what happens under the hood. I've been looking for explanation on the web for couple of days with no success.
    – 4xy
    Commented Sep 19, 2020 at 16:30
40

I won't try to answer your entire question,
but I've found a few things that helped me understand how these systems fit together.
Hope this helps someone as this was very confusing to me


1 - The old network interfaces configuration file, and it's ifup & ifdown commands:

The /etc/network/interfaces network configuration file seems to be fairly old, but is still used by ifup, ifdown and ifquery.

These seem to be the old way to bring network 'interfaces' (MAC based links) and 'connections' (IP based connections) up and down.

man 8 ifup says:

DESCRIPTION
The ifup and ifdown commands may be used to configure (or, respectively, deconfigure) network interfaces based on interface definitions in the file /etc/network/interfaces.

The important implication is this:

if an interface isn't defined in /etc/network/interfaces, then ifup/ifdown won't manage that interface.


2 - What about the old ifconfig command?

The legacy networking package named net-tools on Debian, includes the depreciated: arp, ifconfig, ipmaddr, iptunnel, iwconfig, nameif, netstat, route, and vconfig commands.

Now you want to be using the package named iproute2 instead which includes the newer ip, iw, ss, and ifrename commands.


3 - If the ip command can bring an interface up or down, why not use it rather than ifup and ifdown?

What ifup/down does, (via the ifupdown package or presumable also the Python rewrite in ifupdown2), that ip does not do, is to run legacy scripts before and after network changes. But note what man ifup says:

NOTES

The program does not configure network interfaces directly; it runs low level utilities such as ip to do its dirty work.

SEE ALSO
interfaces(5), ip(8), ifconfig(8).

So it appears that ifup/ifdown has been upgraded from using the depreciated ifconfig back-end, to now using the ip back-end, provided by the newer iproute2 package.


4 - What about NetworkManager? (2004)

From man 5 NetworkManager,

[IFUPDOWN]

This section contains ifupdown-specific options and thus only has effect when using the ifupdown plugin.

managed

If set to true, then interfaces listed in /etc/network/interfaces are managed by NetworkManager. If set to false, then any interface listed in /etc/network/interfaces will be ignored by NetworkManager. Remember that NetworkManager controls the default route, so because the interface is ignored, NetworkManager may assign the default route to some other interface.

So its unclear if NetworkManager can also run ifup/ifdown scripts, but what is clear, is that NetworkManager can stay clear of legacy interfaces (again "MAC based hardware links") that ifup/ifdown are still using. In other words, either ifup is using a hardware link, or NetworkManager, or possibly something else, but not both ifup and NetworkManager at the same time.


5 - systemd-networkd (2010)

This is newer than NetworkManager, and used for wired servers and when a GUI environment is not available.

But it appears that for wireless connections, NetworkManager is the way to go as it is more difficult to manually configure systemd-networkd.

In man 8 systemd-networkd it says,

systemd-networkd will manage network addresses and routes for any link for which it finds a .network file with an appropriate [Match] section, see systemd.network(5) (real network devices). For those links, it will flush existing network addresses and routes when bringing up the device. Any links not matched by one of the .network files will be ignored. It is also possible to explicitly tell systemd-networkd to ignore a link by using Unmanaged=yes option, see systemd.network(5).

Hope I've got this all right, but if not please let me know. Thanks.

1
  • 1
    systemd was released in 2010, but the networkd component was only added in 2014.
    – OrangeDog
    Commented Jul 13, 2023 at 15:51
4

This is a pretty detailed question. I'll break it down as much as I can:

Netplan: This is a YAML network configuration abstraction for various backends. It can generate configuration files for NetworkManager or networkd. You can use it as a unified interface to describe what network configuration you want. Then Netplan applies this configuration using either NetworkManager or networkd as the backend, depending on the system's needs. The specific backend in use is controlled by the renderer: attribute in the Netplan configuration file.

NetworkManager: This is a dynamic network control and configuration system that aims to keep network devices and connections up and active when they're available. NetworkManager is primarily targeted at desktop systems, like Kubuntu. It's suitable for managing the kinds of network setups you'd find on a typical user workstation, such as wireless networks, wired networks, and VPNs.

networkd: This is a system service that manages networks. It detects and configures network devices as they appear, and it can create network configurations dynamically as needed. networkd is typically used for server environments where simplicity and automation are preferred.

networkd-dispatcher: This is a dispatcher service for systemd-networkd connection status changes. It is comparable to the dispatcher.d functionality in NetworkManager. When a network device changes state (up, down, etc.), networkd-dispatcher will execute any scripts placed in its configuration directories, allowing you to react to network configuration changes as they happen.

/etc/network/: The files in this directory are traditional configuration files for networking in Debian-based systems, and are used by the ifup and ifdown commands. While these files can be used on a system running NetworkManager, they typically aren't, because NetworkManager manages network configuration itself and ignores these files.

To better understand how these components are working together, you need to look at the boot process:

When the system boots, networking services are started by systemd, the init system for Ubuntu. Netplan reads its YAML configuration file and generates configuration files for either NetworkManager or networkd, based on what renderer it's configured to use. NetworkManager or networkd, as appropriate, start up and read the configuration files generated by Netplan. If the network configuration changes, NetworkManager or networkd responds as appropriate, and networkd-dispatcher triggers any scripts that are set up to respond to the change. As for determining which tool is managing which interface, a good starting point is to look at the output of networkctl, a command provided by systemd that can show you the status of network links as seen by systemd-networkd.

The tools you mentioned: net-tools (deprecated), iproute2, and ifupdown2 are utilities to manipulate and configure network interfaces in Linux. They interact with the Linux kernel directly to manage network interfaces, routes, etc. They can coexist with NetworkManager and networkd, but in a system managed by NetworkManager or networkd, they would be used for diagnostics more than for configuration.

1
  • because NetworkManager manages network configuration itself and ignores these files - it's not true, by default it ignores interfaces listed in these files not these files. To make it ignore the files you have to set managed=true in config, as mentioned in Elliptical view answer.
    – Alek
    Commented Aug 11, 2023 at 12:58

You must log in to answer this question.

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