How to Change the Default DNS Server in Ubuntu via the Terminal

Changing your DNS server in Ubuntu can significantly improve your browsing speed and privacy. While the GUI is easy, the terminal provides more permanent control.

Editing systemd-resolved

  1. Open the terminal and run sudo nano /etc/systemd/resolved.conf.
  2. Uncomment the DNS= line and add your preferred DNS (e.g., 1.1.1.1).
  3. Save and restart the service using sudo systemctl restart systemd-resolved.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.