Why a Local Search Domain Matters
In a home network you often want to reach devices by simple names—printer, raspberrypi, nas—instead of remembering IP addresses. A local search domain lets the resolver append a suffix automatically, turning printer into printer.home.local. systemd‑resolved can supply that suffix for the host itself, and, when coupled with a lightweight DNS forwarder, can expose the same domain to all clients.
Prerequisites
| Item | Why it matters | Typical command |
|---|---|---|
| systemd‑resolved enabled | It supplies the stub resolver on 127.0.0.53 | systemctl enable --now systemd-resolved |
| systemd‑networkd or another network manager | Needed to push the domain to clients via DHCP | systemctl enable --now systemd-networkd |
| Optional: dnsmasq or bind | To serve the domain to other hosts | apt install dnsmasq (Debian/Ubuntu) |
| Firewall configured | To restrict DNS traffic | ufw allow 53 (or firewalld rules) |
All examples assume a Debian‑based system; adjust package names for your distro.
Configuring systemd‑resolved
systemd‑resolved is split into two parts: the stub resolver (listening on 127.0.0.53) and the DNS client that talks to upstream servers. The configuration lives in /etc/systemd/resolved.conf and per‑interface files in /etc/systemd/network/.
Global Settings
Edit /etc/systemd/resolved.conf:
[Resolve]
# Append this suffix when no domain is supplied
Domains=home.local
# Enable DNSSEC validation for safety
DNSSEC=yes
# Use the built‑in stub resolver
# (the default is already enabled)
After saving, reload:
systemctl restart systemd-resolved
Verify with:
systemd-resolve --status | grep -A4 "Current DNS Server"
You should see home.local listed under “Domains”.
Per‑Interface Settings
If you want the domain only on a specific interface (e.g., eth0), create /etc/systemd/network/20-home.network:
[Match]
Name=eth0
[Network]
Domains=home.local
LLMNR=yes
MulticastDNS=yes
Reload networkd:
systemctl restart systemd-networkd
Now eth0 will advertise home.local to DHCP clients.
Serving the Domain to the Network
systemd‑resolved alone cannot answer queries for printer.home.local from other machines. You need a DNS server that can host the zone. Two common lightweight options are dnsmasq and bind. Below we show how to wire dnsmasq to systemd‑resolved.
Using dnsmasq as a Forwarder
Install dnsmasq:
apt install dnsmasq
Create /etc/dnsmasq.d/10-local.conf:
# Forward all queries to systemd-resolved
server=127.0.0.53
# Define the local zone
address=/home.local/192.168.1.1
# Optionally add static hosts
address=/printer.home.local/192.168.1.10
address=/nas.home.local/192.168.1.20
Restart dnsmasq:
systemctl restart dnsmasq
Now any client pointing its DNS to the router (or to the host running dnsmasq) will resolve printer.home.local to 192.168.1.10.
Using systemd‑resolved as a Stub Only
If you only need the domain locally (e.g., for a single workstation), you can skip dnsmasq entirely. Add the host to /etc/hosts:
192.168.1.10 printer.home.local
systemd‑resolved will consult /etc/hosts before querying upstream. This is the simplest, but it does not help other devices.
DHCP and Search Domain Propagation
When you run a DHCP server (dnsmasq, for example), you can push the search domain to clients so that they automatically append home.local. Edit your dnsmasq config:
dhcp-option=15,home.local
Option 15 is the DHCP option for the domain name. Restart dnsmasq and the clients will receive the search suffix in their resolv.conf. In practice this is how most routers hand out the local domain.
If you use another DHCP daemon, look up the equivalent option. The key point: without the DHCP push, clients will still need to type the full name or add the domain manually.
TAGS
dns systemd-resolved localnetwork
See also
- List the IPs that failed SSH logins in the past day using awk, sort, and uniq
- Pulling a Single File from a Borg Backup Without Unpacking the Whole Archive
- Stop systemd‑journald from filling your Raspberry Pi’s 8 GB SD card with logs – how to cap its size
- Send a Telegram Alert When Your Home Server’s /home Reaches 90% Usage With a Tiny systemd Service and curl
- Stop the “REMOTE HOST IDENTIFICATION HAS CHANGED!” error by cleaning ~/.ssh/known_hosts.