Marcio Cunha

Configuring Name Resolution and DNS on Ubuntu Server

Learn how to structure domain name resolution on Ubuntu Server using modern tools like Systemd-resolved and BIND9. Understand the practical impact of DNS on infrastructure and prevent common connectivity failures.

Marcio Cunha12 min
Also available in:EspañolPortuguês
Summary
  • Systemd-resolved manages local DNS query routing through efficient stub configuration files.
  • Permanent DNS server changes require careful editing of the Netplan configuration file.
  • Using BIND9 transforms Ubuntu Server into a robust authoritative resolver for enterprise environments.
  • Utilities like dig and resolvectl simplify the diagnosis of propagation failures and network latency.
  • Strategic selection between public and local resolvers ensures greater privacy and traffic control.

The Critical Role of DNS in Server Architecture

DNS, or Domain Name System, acts as the phonebook of the internet. In practice, it translates human-readable names like marciocunha.net into numerical IP addresses that computers use to talk to each other. When setting up an Ubuntu Server, ensuring this translation happens quickly and flawlessly is the first step toward any stable infrastructure. Without reliable name resolution, package updates fail, applications cannot find remote databases, and internal services simply stop responding.

Historically, managing DNS on Linux meant editing static plain-text files. Today, Ubuntu's modern ecosystem brings fresh tools designed to handle dynamic networks, cloud environments, and mobile connections. Understanding how these gears work saves hours of frustration when diagnosing issues that look like network failures but are actually address translation bottlenecks. Next, we will explore how Ubuntu handles this and how to take full control of the process.

Understanding Systemd-resolved and the Role of Netplan

In recent versions of Ubuntu Server, network management has been centralized through Netplan, a unified interface for configuring network interfaces. Under the hood, Netplan delegates the task of handling DNS server addresses to an integrated service called Systemd-resolved. This service acts as a local caching resolver, meaning it remembers recent responses to speed up future queries while easing external traffic.

In practice, Systemd-resolved creates a special bridge file known as a stub resolver at /run/systemd/resolve/stub-resolv.conf. This file points to the local address 127.0.0.53, intelligently routing operating system traffic. To permanently change the default DNS servers of your Ubuntu Server, you must modify the Netplan configuration file located in the /etc/netplan/ folder, usually carrying a .yaml extension.

Implementing Static Configurations in Netplan

To configure custom DNS addresses, such as public servers from Google or Cloudflare, we need to edit the Netplan YAML file using a text editor of your choice. The configuration block must clearly specify the network interface, static IP addresses, and the section dedicated to name servers. Care with space indentation is crucial here, as formatting errors prevent Ubuntu from applying the new network rules during startup.

Below is a practical configuration example using Netplan to define static IP addresses and primary/secondary DNS servers on an Ubuntu Server.

network:  version: 2  renderer: networkd  ethernets:    eth0:      addresses:        - 192.168.1.50/24      routes:        - to: default          via: 192.168.1.1      nameservers:        addresses:          - 1.1.1.1          - 8.8.8.8

After saving the file, the command sudo netplan apply validates the syntax and applies the changes instantly. If there is any error in the file structure, Netplan usually reverts the change automatically after a few seconds, preventing you from losing remote SSH access to the machine due to a configuration failure.

Validating and Troubleshooting Queries with Native Tools

Once the network is configured, the next essential step is to test whether name resolution is responding as expected. The traditional nslookup command remains useful, but the modern recommended tool in the systemd ecosystem is resolvectl. It allows you to inspect the resolver's current state, verify which DNS servers are active for each network interface, and analyze the local cache in real time.

Another indispensable utility for systems engineers is the dnsutils package, which provides the dig command. dig offers a transparent and detailed view of the entire query process, showing response times, authority records, and the path taken to find the desired IP. Running a simple command like dig marciocunha.net helps identify immediately whether the issue lies in your machine, the local router, or your internet service provider.

Implementing a Local DNS Server with BIND9

In enterprise environments or networks requiring high customization, configuring just the DNS client on Ubuntu Server may not be enough. In such scenarios, we can turn Ubuntu itself into an authoritative and local caching DNS server using BIND9, the most widely used name management software in the corporate world. It allows you purgatory internal domain names for local network machines that do not appear on the public internet.

BIND9 installation is done directly through Ubuntu's standard package manager with the command sudo apt install bind9. Configuration files are stored in the /etc/bind/ directory, where the named.conf.options file defines general behavior, such as query forwarding policies to the internet and security restrictions to prevent your machine from being used in traffic amplification attacks by cybercriminals.

Final Considerations on Stability and Network Monitoring

Keeping name resolution running smoothly is an ongoing task that requires attention to redundancy and proactive monitoring. Never rely on a single external DNS server; always configure at least one primary and one secondary server from different providers to ensure resilience in case of infrastructure outages. Additionally, keep system packages updated to receive security patches and performance improvements in Ubuntu's networking subsystem.

In short, mastering the DNS ecosystem on Ubuntu Server — from basic Netplan adjustments to deploying a dedicated resolver with BIND9 — ensures total autonomy and security for your infrastructure. With a solid foundation of name resolution, your applications run without interruption and your team gains agility to diagnose and resolve any connectivity anomaly before it impacts end users.