Networking on Linux can get confusing because there are many different tools to manage it. Tools like ifupdown, NetworkManager, and systemd-networkd can all be used — but mixing them can create conflicts.
since i am setting up debian 12 as my base OS for my homelab cause ubuntu is a bloat, we will clean up the networking setup on Debian and configure it properly using systemd-networkd for managing the network and systemd-resolved for DNS. This keeps everything simple and easy to troubleshoot.
Understanding How Different Systems Work
Before we get started, let’s clear up how different distros handle networking:
Ubuntu Server & Ubuntu AMI (Cloud)
- Uses netplan with systemd-netwrokd, Netplan generates the required config in
/etc/netplan/50_cloudinit.yaml.which can be used by systemd-networkd.
Most Linux Desktop
- Uses NetworkManager by default.
Debian
-
Offers options like:
-
ifupdown (older method)
-
NetworkManager
-
systemd-networkd (modern, lightweight)
-
We will go with systemd-networkd because it’s simple, clean, and good for servers or homelabs.
Step 1: Install Required Tools
Most likely, systemd-networkd is already installed on Debian, but to be sure:
sudo apt updatesudo apt install systemd-networkd systemd-resolved -yStep 2: Remove Unnecessary Tools
First, let’s get rid of any tools we don’t need:
sudo apt remove --purge ifupdown network-manager net-tools -ysudo apt autoremove --purge -ycheck if any leftover packages remain:
dpkg -l | grep -E 'ifupdown|network-manager'If you see anything, purge it.
Step 3: Enable systemd-networkd and systemd-resolved
sudo systemctl enable systemd-networkd --nowsudo systemctl enable systemd-resolved --nowCheck if they’re running:
systemctl status systemd-networkdsystemctl status systemd-resolvedTip: To properly use resolvectl, make sure /etc/resolv.conf points to systemd’s resolver:
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.confStep 4: Configure the Network
All configs for systemd-networkd live in /etc/systemd/network/.
4.1 DHCP Example (Automatic IP)
Create a file like 10-ethernet.network:
sudo nvim /etc/systemd/network/10-ethernet.network[Match]Name=enp1s0f1 # Change this to your interface name
[Network]DHCP=yes4.2 Static IP Example
[Match]Name=enp1s0f1
[Network]Address=192.168.1.50/24Gateway=192.168.1.1DNS=1.1.1.1After creating the config, reload:
sudo systemctl restart systemd-networkdStep 5: Basic Troubleshooting & Commands
5.1 Check Link Status
networkctl status enp1s0f15.2 Show IP Addresses
ip a5.3 Show Routes
ip route show5.4 DNS Status
resolvectl status5.5 Test Connectivity
ping 8.8.8.8ping google.comManaging DNS with systemd-resolved on Debian
Since we are now using systemd-resolved, our /etc/resolv.conf is a symlink managed by systemd. So, we don’t edit it manually. Instead, we manage DNS settings properly using tools and configuration files.
✅ Temporary DNS Change
This change is temporary and will reset After a system reboot or After restarting systemd-networkd
Command:
resolvectl dns <interface> <dns-address>Example:
resolvectl dns enp1s0f1 1.1.1.1To Verify:
resolvectl status✅ Permanent DNS Change
To set DNS permanently, edit your .network configuration file inside /etc/systemd/network/xyz.network
Example of Static IP + DNS:
[Match]Name=enp1s0f1
[Network]Address=192.168.1.50/24Gateway=192.168.1.1DNS=1.1.1.1Apply the changes:
sudo systemctl restart systemd-networkd
✅ Using DHCP but Custom DNS (Ignore Router DNS)
Even when using DHCP for automatic IP configuration, you can override the DNS provided by your router.
[Match]Name=enp1s0f1
[Network]DHCP=yesDNS=1.1.1.1Apply the changes: sudo systemctl restart systemd-networkd
so now to manage DNS, temporary way is using resolvectl dns <interface_name> 1.1.1.1 , but to make it permanent we can simply edit our network file
/etc/systemd/network/10-wired.networkfile and define dns or other paramethers directly and simply restarat systemd-networkd