Your internet speed is often affected by the DNS server you’re using. Luckily, it’s easy to change your current DNS server on Linux.
DNS servers are one of the most basic yet crucial parts of the internet infrastructure. Whenever you type a domain name into your browser, a DNS server translates that name into an IP (Internet Protocol) address. Your browser then uses that address to locate and connect to the site you want to visit.
Although your internet service provider automatically sets your DNS servers when you connect to the internet, their servers might not be the best choice for your needs. Here's how you can change your DNS server on Linux.
Because DNS servers (sometimes called name servers) are such a basic part of internet communication, their configuration and performance can have a big impact on your internet experience.
Slow DNS servers will cause delays every time you try to connect to a site. Misconfigured DNS servers can send you to sites you didn’t intend to visit. Your internet service provider, government, or another entity can also configure DNS servers to block you from visiting specific sites.
Changing the DNS servers that you are using can resolve all of these potential problems.
There are several trusted organizations that run free public DNS servers. If you’re having trouble with your ISP's default name servers, they are worth investigating.
The quickest, easiest way to see your current DNS server(s) is to open a terminal and enter the following at the command line:
The resulting output will show your current network connections along with the DNS servers being used by each. In most cases, you will only have one connection in use, and other entries will not show DNS information.
Don’t let all the network lingo intimidate you. Changing your DNS server is fast and easy with any version of Linux. We’ll show you how to change your settings in the two major desktop environments, GNOME and Plasma (KDE), and at a terminal.
To switch to a new DNS server in GNOME, open the system settings app and click on Wi-Fi at the top left. If connected through an Ethernet cable, click on Network instead. The steps to change the DNS server will be the same in both cases.
This will show you a list of all available network connections. The network you are connected to should show up at the top of the list and will display the word Connected. To the right of the network name, you will see a gear icon. Go ahead and click that.
In the dialog box that opens, click on the tab labeled IPv4. In the middle of the dialog box, you will see space to enter your preferred DNS servers. Just above the box is a toggle switch that says Automatic. Simply toggle the automatic setting to off, and enter your new DNS servers in the space provided, separated by a comma.
In most cases, your chosen DNS service will provide IP addresses for two servers. You should enter them both. If your provider offers more, you should enter at least two of them, but you're free to include as many as you want, separated by commas.
With your new DNS server addresses configured, just click on Apply on the top right and your settings will be saved. That’s it! You’re done! You can run the resolvectl status command again to verify that the changes have taken effect.
Changing DNS settings in Plasma is very similar to the method outlined above. Open the system settings app and go to the Network section.
Under Network, click on Connections and then select your current connection from the list. From there, click on the tab on the right labeled IPv4 to open advanced settings.
Here, you want to change the top two input fields. The first, labeled Method, will say Automatic by default. Click on the drop-down menu and switch this setting to Automatic (Only Addresses). Now, enter your DNS server IP addresses in the second field, separated by commas. You should enter at least two servers, but you can enter more if you like.
Finally, click on Apply on the bottom right and your system will start using the new DNS servers. Congratulations! You’re all done.
If you’re using another desktop environment, you should be able to find similar settings. If you can’t find a way to change the DNS through your graphical interface, you can always change your DNS servers at the command line.
First, open your terminal and enter the resolvectl status command. In the output, the connection you are using should be the only one showing DNS server information.
In the next command, you’ll need to use the interface identifier (shown in parenthesis) for that network connection.
Then enter the following command:
Notice that at the command line, you will enter the interface identifier (without the angle brackets or parentheses) and two or more DNS server addresses separated by spaces. The changes should take effect as soon as you hit Enter.
If you like, you can run the resolvectl status command again to verify the new DNS server addresses.
Now that you know how to change the DNS servers on your Linux system, you might want to test and compare to find the fastest DNS server for your connection.
By taking control of the DNS servers your system uses, you can be sure that you won’t run into sneaky redirects or blocked sites planted by your internet service provider.
If, however, you believe that your current internet service is censoring what you see, there are other tools, such as Tor, that can help you get around more complex traffic-blocking methods.
JT is a tech industry veteran with more than 25 years of experience. From tech support to programming and system administration, he has done it all. He particularly enjoys teaching new users the freedom and power of Linux.