Sub topic 12
Check and Configure Networking and DNS
Prerequisites and the working model
This chapter assumes you can use sudo, read command output, and distinguish an interface, an IP address, and a hostname. It also assumes the server has already completed installation and can be accessed locally or through a console.
Linux networking has separate layers:
- An interface, such as
ens3, connects the system to a network. - An IP address identifies the system on that network.
- A route tells the kernel where to send packets. The default route is used for destinations outside the local network.
- DNS, the Domain Name System, translates names such as
packages.example.cominto IP addresses.
A server can have working network connectivity while DNS is broken. Test these layers separately.
Inspect the current configuration
Start with read-only commands:
ip -br addr
ip route
ip route get 1.1.1.1
resolvectl status
getent hosts example.comip -br addr shows interfaces and addresses. ip route should show a default route. resolvectl status shows the DNS servers selected for each interface. getent hosts tests name resolution through the system's configured resolver.
| Check | Healthy result | Likely problem if missing |
|---|---|---|
| Interface and address | An expected interface is `UP` with an address | Link, DHCP, or cloud-network issue |
| Default route | A route begins with `default via` | The server cannot reach other networks |
| DNS resolver | One or more reachable DNS servers are listed | Resolver configuration issue |
| Name lookup | An address is returned for the name | DNS or firewall issue |
Configure DNS with the network manager
Do not edit /etc/resolv.conf blindly. On many distributions it is a symlink managed by NetworkManager or systemd-resolved, so manual edits may disappear.
First identify the active connection:
nmcli connection show --activeFor a NetworkManager connection, replace the connection name and DNS addresses with values approved for your environment:
sudo nmcli connection modify "Wired connection 1" \
ipv4.dns "192.0.2.53 192.0.2.54" \
ipv4.ignore-auto-dns yes
sudo nmcli connection up "Wired connection 1"
resolvectl status
getent hosts example.comUse the DNS servers supplied by your hosting provider or organization. The addresses above are documentation examples, not usable resolvers.
Common errors and diagnosis
A successful ping to an IP address does not prove DNS works. Conversely, blocked ICMP traffic does not always mean the network is down. Check the default route, query DNS directly with resolvectl query, and inspect the service logs if NetworkManager controls the connection.
Exercise
The server can reach 1.1.1.1, but getent hosts example.com returns nothing. Which layer should you investigate first, and which command displays its configuration?
Show answer
Investigate DNS first. Run resolvectl status and then resolvectl query example.com; the route and interface are already showing basic connectivity.