Sub topic 5
Installing the Software and Freeing Port 53
This chapter assumes that you can use a Linux shell, install packages, manage systemd services, and check firewall rules. It also assumes that you know the difference between an IP address and a port.
DNS servers normally listen on port 53. They may use UDP for most queries and TCP for larger replies, zone transfers, and some DNSSEC responses. Only one process can normally bind to the same IP address and port, so an existing DNS listener can prevent BIND or Unbound from starting.
Find the current DNS listener
Check port 53 before installing or starting another DNS service:
sudo ss -lntup | grep ':53 'The output identifies the process and the local address. On many systems, systemd-resolved listens on 127.0.0.53:53. This is a local stub resolver. Applications send queries to it, and it forwards those queries to configured upstream servers.
You have two common choices:
- Keep the existing stub resolver and configure BIND or Unbound to listen on another address, such as the server's LAN address.
- Stop the stub resolver and let BIND or Unbound own port 53.
The second choice is common for a dedicated DNS server. Do not stop a resolver on a general-purpose host until you have planned how local applications will resolve names.
Install BIND or Unbound
BIND provides authoritative DNS service, recursion, forwarding, and zone transfers. Unbound is primarily a caching, forwarding, and validating resolver. Install only the service roles you need.
# Debian and Ubuntu
sudo apt install bind9 bind9-utils dnsutils
sudo apt install unbound
# RHEL, Rocky, Alma, and Fedora
sudo dnf install bind bind-utils
sudo dnf install unboundThe package names differ between distributions. dnsutils or bind-utils provides dig, which you will use to test DNS.
After installation, inspect the service without assuming that it is ready to serve clients:
sudo systemctl status bind9
sudo systemctl status named
sudo systemctl status unboundBIND is usually called bind9 on Debian-based systems and named on RHEL-based systems.
Resolve the port conflict
If you choose to replace systemd-resolved, stop it and prevent it from starting automatically:
sudo systemctl disable --now systemd-resolvedThen configure /etc/resolv.conf to point to the resolver that will replace it. The exact method depends on whether the file is managed by NetworkManager, netplan, or another network service. Check the file and its symlink before editing it.
If you keep systemd-resolved, configure the DNS daemon's listen-on or interface settings so that it does not claim the same address. Restart the service after changing its configuration, then verify the listener again.
flowchart TD
A[Check port 53] --> B{Existing listener?}
B -->|No| C[Install and start DNS service]
B -->|Yes| D{Keep existing resolver?}
D -->|Yes| E[Use a different listen address]
D -->|No| F[Stop and disable existing resolver]
E --> C
F --> C
C --> G[Check port 53 again]Start the selected service
Enable only the daemon you intend to run:
sudo systemctl enable --now unbound
# Or, on Debian and Ubuntu:
sudo systemctl enable --now bind9
# On RHEL-family systems:
sudo systemctl enable --now namedIf startup fails, inspect the service log before changing more settings:
sudo journalctl -u unbound -b --no-pager
sudo journalctl -u bind9 -b --no-pager
sudo journalctl -u named -b --no-pagerExercise
What should you check before starting BIND or Unbound, and what does a listener on 127.0.0.53:53 usually indicate?
Show answer
Run sudo ss -lntup | grep ':53 '. A listener on 127.0.0.53:53 usually indicates the systemd-resolved local stub resolver.