Debian 11 by default appears configures the network using systemd and ifupdown. I'm interested in how systemd gets to network-online.target
.
# systemctl show network-online.target | grep -E 'After|Wants'
Wants=networking.service
After=networking.service network.target [email protected]
I can see there's a dependency on networking.service
, and the target is ordered after [email protected]
.
# systemctl show networking.service | grep ExecStart
ExecStart={ path=/sbin/ifup ; argv[]=/sbin/ifup -a --read-environment ; ignore_errors=no ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecStart={ path=/bin/sh ; argv[]=/bin/sh -c if [ -f /run/network/restart-hotplug ]; then /sbin/ifup -a --read-environment --allow=hotplug; fi ; ignore_errors=yes ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecStartEx={ path=/sbin/ifup ; argv[]=/sbin/ifup -a --read-environment ; flags= ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
ExecStartEx={ path=/bin/sh ; argv[]=/bin/sh -c if [ -f /run/network/restart-hotplug ]; then /sbin/ifup -a --read-environment --allow=hotplug; fi ; flags=ignore-failure ; start_time=[n/a] ; stop_time=[n/a] ; pid=0 ; code=(null) ; status=0/0 }
The dependency basically just runs ifup -a
.
If I check out [email protected]
, I see that its an instantiated service:
# systemctl cat [email protected]
# /lib/systemd/system/[email protected]
[Unit]
Description=ifup for %I
After=local-fs.target network-pre.target apparmor.service systemd-sysctl.service
Before=network.target shutdown.target network-online.target
Conflicts=shutdown.target
BindsTo=sys-subsystem-net-devices-%i.device
After=sys-subsystem-net-devices-%i.device
DefaultDependencies=no
IgnoreOnIsolate=yes
[Service]
# avoid stopping on shutdown via stopping system-ifup.slice
Slice=system.slice
ExecStart=/bin/sh -ec 'ifup --allow=hotplug %I; ifquery --state %I'
ExecStop=/sbin/ifdown %I
RemainAfterExit=true
TimeoutStartSec=5min
and that it is ordered after, and bound to sys-subsystem-net-devices-ens192.device
, but there's no actual file for this unit:
# systemctl show sys-subsystem-net-devices-ens192.device | grep ens192
SysFSPath=/sys/devices/pci0000:00/0000:00:16.0/0000:0b:00.0/net/ens192
Id=sys-subsystem-net-devices-ens192.device
Names=sys-subsystem-net-devices-ens192.device
[email protected]
[email protected]
# systemctl cat sys-subsystem-net-devices-ens192.device
No files found for sys-subsystem-net-devices-ens192.device.
I can see from man systemd.device
that these get created automatically via udev, but there's no mention of how they get bound to or ordered around the instantiated service.
I'm left with these two questions I can't seem to find an answer to:
- Where is the file/configuration that tells systemd to use [email protected] for the
BoundBy
andBefore
in the device unit? 2.There is no ordering betweennetworking.service
and[email protected]
; why do both exist, and why is it that the[email protected]
is the one that ultimately runsdhclient
, and notnetworking.service
?
Thanks!