Skip to content
Log In Sign Up info@muvcloud.com

What the File Holds

nameserver 192.0.2.53
nameserver 198.51.100.53
search example.com
options timeout:2 attempts:3 rotate
  • nameserver: a DNS server to ask, tried in the order listed. The C library reads at most three.
  • search: domains appended to short names, so db is looked up as db.example.com.
  • options: settings for timeouts, retries, and order, described further down.

Who Writes It Today

Start by checking whether the file is a link:

ls -l /etc/resolv.conf
  • systemd-resolved: on Ubuntu Server the file is a link to a file under /run/systemd/resolve/ and lists nameserver 127.0.0.53, a local stub that forwards queries to the real servers.
  • NetworkManager: on AlmaLinux and Rocky Linux it is a plain file whose first line says NetworkManager generated it.
  • cloud-init and netplan: on cloud images, cloud-init writes the network configuration at first boot, and netplan passes the DNS servers on. See what is cloud-init.
  • ifupdown: Debian systems that use it often keep a plain file, which a DHCP client can rewrite.

See the Servers Really in Use

resolvectl status
nmcli device show | grep DNS

With the stub, resolv.conf shows only 127.0.0.53. resolvectl status shows the real upstream servers per interface. The second command is for NetworkManager systems.

Set DNS Servers with Netplan

On Ubuntu, add the servers to the interface in your file under /etc/netplan/:

network:
  version: 2
  ethernets:
    eth0:
      nameservers:
        addresses: [192.0.2.53, 198.51.100.53]
        search: [example.com]

Apply with sudo netplan try, which rolls back unless you confirm. Use your real interface name. The full file is in how to configure a static IP with netplan.

Set DNS Servers with nmcli

nmcli connection show
sudo nmcli connection modify "System eth0" ipv4.dns "192.0.2.53 198.51.100.53" ipv4.ignore-auto-dns yes
sudo nmcli connection up "System eth0"

Reactivating the connection can drop an SSH session for a moment, so keep the console in your provider's control panel at hand. More in how to set a static IP with nmcli.

Set DNS Servers in resolved.conf

For a global setting in systemd-resolved, create a drop-in file such as /etc/systemd/resolved.conf.d/dns.conf:

[Resolve]
DNS=192.0.2.53 198.51.100.53

Then run sudo systemctl restart systemd-resolved. Servers set per interface by netplan or DHCP stay in place next to the global ones.

Timeout, Attempts, and Rotate

OptionEffect
timeout:nSeconds before the next server
attempts:nRounds through the list
rotateSpreads queries over servers

With the 127.0.0.53 stub there is only one entry, so these options matter little; systemd-resolved handles retries itself.

Editing the File by Hand

A wrong entry breaks name resolution for updates and applications, although SSH to the IP address keeps working. If you edit it for a quick test, copy it first with sudo cp /etc/resolv.conf /root/resolv.conf.bak, and do not replace a link with a plain file while a service still manages it. Make the lasting change in the owning tool.

Test the Result

dig example.com
resolvectl query example.com
getent hosts example.com

dig asks the server listed in resolv.conf directly, resolvectl query asks systemd-resolved where it runs, and getent goes the way applications do, including /etc/hosts. Details are in the dig command guide. If lookups fail, see temporary failure in name resolution; for stale answers, flush the DNS cache.

Updated:

Linux VPS with Full Root Access

MUVCloud cloud servers run on KVM with Enterprise NVMe SSD storage and full root access, in Turkey, the Netherlands, and the USA.

Cloud VPS Plans Starting at2.99 $/mo Cheap Linux VPS

No Limits on Service or Support

You are not on your own as your projects grow. Our support engineers are ready 24/7, on several channels, whenever you need them.

Support specialist
  • 100% customer satisfaction goal
  • Our own hardware
  • 24/7 ticket and email support
  • 4 countries with locations