Linux Networking

Change DNS servers on Linux

Point Linux at reliable resolvers and confirm systemd-resolved is not fighting you.

11 min read Beginner Updated 9 Jun 2026

Step-by-step guide

Work through each section in order. Stop when your issue is resolved — you do not need every step for every situation.

Warning

Use a sudo-capable account, keep shell history for audit, and back up critical paths before changing boot, SSH, or package state.

What you will achieve

Point Linux at reliable resolvers and confirm systemd-resolved is not fighting you.

1) Set DNS with NetworkManager (desktop)

nmcli connection show
nmcli connection modify "Wired connection 1" ipv4.dns "1.1.1.1 9.9.9.9" ipv4.ignore-auto-dns yes
nmcli connection up "Wired connection 1"

2) Or set resolved fallback DNS (server)

sudo nano /etc/systemd/resolved.conf
sudo systemctl restart systemd-resolved

3) Validate resolver

resolvectl status
getent hosts example.com

Related guides

dns linux systemd-resolved