This guide describes how to setup networking under Debian Linux on a laptop. While there are many options to choose from, Debian 12 (bookworm) uses NetworkManager and wpa_supplicant as a default. This guide installs systemd-networkd and iwd, with the goal of controlling networking form the command line, using modern components.
The official Debian documentation lists various options and serves as a starting point.
Replacing NetworkManager with systemd-networkd has been done following the official Debian docs and a great guide by Fernanto Cejas.
First, disable NetworkManager and enable systemd-networkd.
$ sudo systemctl disable --now NetworkManager
$ sudo systemctl enable --now systemd-networkd
Note: the --now
switch to enable
or disable
will also start or stop the component. Just enabling or disabling a component won't start or stop that component. I.e. --now
is a shortcut for stop
and disable
, or start
and enable
, respectively.
Next, enable systemd-resolved for name resolution. You may have to install the systemd-resolved package first.
$ sudo apt install systemd-resolved
$ sudo systemctl enable --now systemd-resolved
The systemd-resolved daemon stores resolve configuration at /run/systemd/resolve/resolv.conf
. Since many applications rely on finding that information at /etc/resolv.conf
, it is common practice to create a symlink.
$ sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
Finally, let's check the status of networking. The machine shown here has wireless networking (wlan0), a SIM card slot (wwan0), and is connected to a docking station (enx3ce1a1c25d11) and also has an ethernet port (enp0s31f6).
$ networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 enp0s31f6 ether no-carrier unmanaged
6 docker0 bridge no-carrier unmanaged
14 wlan0 wlan off unmanaged
15 wwan0 wwan off unmanaged
16 enx3ce1a1c25d11 ether routable unmanaged
Configure the wired connections (en*) to receive an IP address via DHCP. Create the config file /etc/systemd/network/en.network
. Wildcards are supported, e.g. en*
matches both enx3ce1a1c25d11
and enp0s31f6
.
$ cat /etc/systemd/network/en.network
[Match]
Name=en*
[Network]
DHCP=yes
Finally, restart systemd-networkd and check, if everything works as expected.
$ sudo systemctl restart systemd-networkd
$ networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 enp0s31f6 ether no-carrier configuring
6 docker0 bridge no-carrier unmanaged
14 wlan0 wlan off unmanaged
15 wwan0 wwan off unmanaged
16 enx3ce1a1c25d11 ether routable configured
ToDo.