How to change DNS on Linux?

Prev Next

Generally, NordLayer application for Linux handles DNS settings automatically and manual DNS configuration should not be needed. However, in case of troubleshooting or specific scenarios, this guide will show you how to edit, add, or remove the DNS settings on your Linux device.

To get started, a few things can be done to make DNS handling as smooth as possible:

  1. Ensuring systemd-resolved is installed and running
  2. Making sure Cloudlfare DNS is reachable

Ensuring systemd-resolved is installed and running

  1. Open the terminal with the CTRL + ALT + T combination and type in the following commands:
systemctl status systemd-resolved

This will show detailed information about the service (you can exit by pressing q).

What is more, DNS servers should be visible per interface:

resolvectl

(You can use up/down keys to navigate and exit by pressing q)

Installing systemd-resolved

systemd-resolved is automatically installed as part of systemd/resolvectl. It is activated by default on the most common Linux distributions. However, it can also be activated by entering:

sudo systemctl enable --now systemd-resolved

Making sure Cloudflare DNS is reachable

You can check whether DNS server is reachable:

ping 1.1.1.1

(You can exit by pressing CTRL + C)

It should also be possible to perform DNS requests:

dig nordlayer.com @1.1.1.1

Advanced topics

When systemd-resolve is not available

If neither systemd-resolve nor Network Manager are viable, it is recommended to install openresolv (for advanced users):

(On Ubuntu and Debian-based distributions)

sudo apt install openresolv

(On Fedora)

sudo dnf install openresolv

Choosing a different DNS server

You can use the default NordLayer DNS server, utilize ThreatBlock DNS settings or even set up custom DNS on server with a dedicated IP.

Setting DNS servers for manual VPN connection (when not using application)

When using a manual VPN connection, a DNS server can be set on the VPN interface (nlx0, tun0 or ovpn0), preferably through the System Settings or Network Manager. Alternatively, it can be set using openresolv. For example, OpenDNS uses:

  • 208.67.220.222 for the primary server
  • 208.67.220.220 for the secondary server

Note: In case you have any questions or are experiencing any issues, please feel free to contact our 24/7 customer support team.