0

Exactly what is the process on bringing up an interface in Ubuntu 20.04?

i.e Which process manages this? (Is it systemd-networkd?) And what configuration data does it base this on?

Note: I'm not asking about netplan configuration, netplan is merely an abstraction layer that converts a netplan configuration into a configuration suitable for the specific backend in use - I'm more interested in the underlying functionality of that specific backend, and the process that it goes through.

(Edited to refocus the question to make it clear that I'm interested in what happens underneath the netplan config abstraction layer).

Ben791
  • 3
  • 2
  • I had previously read that link, and it didn't answer the question, hence seeking answers here. It's a mixture of generic linux networking basics (i.e. ip addr, ethtool, /etc/hosts etc) with some netplan snippets. – Ben791 Jun 21 '22 at 12:45
  • I am aware of netplan, but that's not quite what I was looknig for, I may need to reword the question. As an example, I have one system, where there is no netplan config at all, but the interface still comes up and works fine. Why? What process drives this? I suspect the root of the answer lies with systemd-networkd and systemd link, as that is where the network device bring up process seems to start, it's just taking some digging to bring the information together. – Ben791 Jun 21 '22 at 12:57
  • So this is not a hypothetical question about network configs -- you have a real-world server that is mysteriously configured that you are trying to troubleshoot. Please [edit your question](https://askubuntu.com/posts/1415058/edit) to clarify your question and add your troubleshooting information. – user535733 Jun 21 '22 at 13:02
  • I'm not particularly bothered about troubleshooting that particular system, especially since it's working fine. But it did inspire the question seeking to understand the underlying process. – Ben791 Jun 21 '22 at 13:08
  • 2
    `/etc/network/interfaces` is deprecated in Ubuntu server 17.10 et seq. Changes there will likely not be respected. Please see: https://askubuntu.com/questions/976464/why-is-the-network-configuration-i-set-in-etc-network-interfaces-ignored-on-ubu/976497#976497 Welcome to Ask Ubuntu. – chili555 Jun 21 '22 at 13:11

2 Answers2

1

Early during the boot process the netplan-generate binary is run as a systemd generator. The binary can be seen (symlinked) at /lib/systemd/system-generators/netplan.

The netplan-generate binary uses the netplan configuration to create configuration for either systemd-networkd or NetworkManager. E.g. for systemd-networkd a file is created at /run/systemd/network/10-netplan-SOMETHING.network.

Later in the boot process, systemd starts the service for systemd-networkd.service or NetworkManager.service. The service configures the network based on its configuration (which was just created by netplan).

Andrew Lowther
  • 5,811
  • 1
  • 15
  • 23
0

When the system boots and kernel executes /sbin/init for PID 1 it will actually execute /lib/systemd/systemd via symbolic link. See man 1 systemd for details.

During early startup process of systemd, all generators will be executed which may automatically generate new config files before all config files are loaded. See man 7 systemd.generator for details about this process.

The systemd (PID 1) will then look for default.target which is by default a symlink from /lib/systemd/system/default.target to graphical.target. (You're supposed to query this with systemctl get-default and set a new target with systemctl set-default.)

Once the default target is known, systemd (PID 1) will then recursively look for dependencies for this target.

If you want to know how some specific target or service was started, try e.g. systemd-analyze critical-chain network.target or even systemd-analyze dump. The netplan is initialized via generator /lib/systemd/system-generators/netplan and it contains hardcoded information about NetworkManager, too.

I'm not entirely sure how systemd boots with a system with filesystem root / on a software RAID device (e.g. boot from RAID 5 md device in /dev/md0). I would assume initrd is used to build the RAID array but I couldn't find details about how this works in practice. Obviously, how exactly the root filesystem is located and mounted is an implementation detail that will happen before trying to read the configuration files or bring the network up so it's not important for the original question.

Mikko Rantalainen
  • 3,200
  • 1
  • 24
  • 36