How to Change Your DNS Server on Your Device?

change dns servers

In this guide, I’ll discuss several ways to change the DNS server on your device, whether you have a Windows machine, Linux or MacOS.

Why would you change your DNS server?

Well, the DNS Servers of your ISP can do the job required to serve your DNS queries, however, there are some benefits that you can get from Third-Party DNS providers like Security, faster responses, and better privacy compared to your ISP’s DNS servers.

Also, some DNS Providers support DNS-over-Https (DoH) which encrypts your DNS Query for extra security.

What are the best Third-Party DNS Providers available?

1) Google Public DNS (8.8.8.8 & 8.8.4.4 ): 

fast response and highly available DNS Servers.

2) Cloudflare DNS (1.1.1.1 & 1.0.0.1 ): 

focused on privacy, and supports DNS-over-Https (DoH)  and DNS Over TLS ( DoT ).

3) Quad9 (9.9.9.9) : 

focused on security, it provides a mechanism to block malware and suspicious websites.

4) OpenDNS (208.67.222.222 & 208.67.220.220 ): 

provides adult content blocking (parental control ) with a paid version providing advanced security for businesses.

Changing DNS Servers on Windows:

From Settings:

Open windows settings from your startup menu, the Go to “Network & Internet” >> “Advanced network settings”:

Windows Internet Settings

Now, Choose your connection whether it’s Wi-Fi or Ethernet and expand it, then on “More adapter options” click on “Edit”:

Edit Interface

The Properties tab will open, Look for the option “Internet Protocol Version 4 (TCP/IPv4)”, then double click on it:

interface properties

When it opens, toggle the option “Use the following DNS server Addresses”, then add your new DNS Server IP Addresses, then Click “OK”:

change interface dns settings

Then click again on “OK”.

Using Command Prompt:

Open Command Prompt as Administrator:

open cmd

On the Command Prompt, write the command netsh interface show interface,

Then, choose the name of the interface that you are using.

cme show network interface

Next, enter this command to setup the first static dns server:

 netsh interface ip set  dns  “<your interface name>”  static <first dns ip> 

Then, enter this command to setup the second dns server: 

netsh interface ip add dns  “<your interface name>”  <second dns ip>  index=2

add dns servers

Then clear the DNS Cache with the command ipconfig /flushdns 

flush and clear dns cache

Changing DNS Servers on Linux:

To change the DNS Settings on Linux, we need to modify the file  /etc/systemd/resolved.conf

open systemd-resolved

Once the file opened, scroll down to the section [Resolve] :

You will find the line #DNS= 

edit resolved.conf file

Uncomment the “DNS=”  line and change it to “ DNS= <first dns ip> <second dns ip>”

Same as below:

add dns servers to resolved.conf

Then, click “ctrl+o” to save it, then hit Enter, and click “ctrl+x” to Exit from the editor.

To Clear the DNS Cache on Linux:

restart the systemd-resolved service, with the command sudo systemctl restart systemd-resolved

restart systemd-resolved

Changing DNS Servers on MacOS:

To change the DNS Settings on your MacOS, open “System Preferences” in your Finder app:

open system preferences on MacOS

Go to “Network” Section:

open network on MacOS

On the left, choose your connection type that’s connected to the internet, it can be wifi or ethernet,

Than, Click on “Advanced” :

advanced settings MacOS

On the DNS tab, locate the + sign to Add DNS Servers:

DNS Settings on MacOS

Add your DNS Server IP Addresses, then click “OK”:

change DNS Servers on MacOS

Check your setting, make sure your DNS Servers appear, then click “Apply” :

Apply DNS Settings on MacOS

To clear the DNS Cache on your Mac:

Open Utilities from Your Finder app:

open Utilities on MacOS

Find and Open the “Terminal” app:

Open Terminal MacOS

On the Terminal , write the following command line, then hit Enter:

Sudo killall -HUP mDNSResponder

Clear DNS Cache on MacOS

DNS-over-HTTPS (DoH)  and DNS-over-TLS (DoT) For Extra Security:

DoH and DoT are two methods to increase the security of your DNS Queries by encrypting the DNS Queries.

Enable DNS-over-HTTPS on Windows 11:

On Settings, open the connected interface, could be WiFi or Ethernet, then expand it.

Noq, open “View additional properties”:

Windows network Interface Settings

Click on “Edit”:

Edit DNS Settings on Windows

For Preferred DNS, turn on “DNS over HTTPS”.

Do the same for “Alternate DNS”, then click “Save”:

Enable DNS over HTTPS on Windows

Enable DNS-over-TLS on Linux:

Currently, Linux Systemd-Resolved only supports DoT.

To enable it, open the file /etc/systemd/resolved.conf with the command:

sudo nano /etc/systemd/resolved/conf

Change the line DNSSEC and DNSOverTLS to YES:

DNSSEC=yes

DNSOverTLS=yes

Enable DNS over TLS on Linux

Then, click “ctrl+o” to save it, then hit Enter, and click “ctrl+x” to Exit from the editor.

restart the systemd-resolved service, with the command sudo systemctl restart systemd-resolved

Restart systemd-resolved on linux

Conclusion: 

changing your DNS server can provide significant advantages in terms of security, speed, and privacy. By switching to a third-party DNS provider, you gain options like DNS-over-HTTPS (DoH) and DNS-over-TLS (DoT), which offer encrypted DNS queries for extra protection. The steps for configuring DNS settings may differ across Windows, Linux, and MacOS, but the process is relatively straightforward on each platform. 

Related Articles