ericvlog / note

6 stars 1 forks source link

How to set DNS servers on Ubuntu - IONOS #67

Open ericvlog opened 4 months ago

ericvlog commented 4 months ago
   How to set DNS servers on Ubuntu - IONOS                                                

[Digital Guide

](https://www.ionos.com/digitalguide/ "Digital Guide")

  1. IONOS
  2. Digital Guide
  3. Server
  4. Configuration
  5. Change DNS server on Ubuntu

ramcreationsShutterstock

How to change DNS servers on Ubuntu 18.04, 20.04 and 22.04

With Ubuntu, you can customize the DNS server for your computer using the command line or the GUI. Alternatively, you can modify the default server in your router settings.

Contents

  1. How to customize DNS servers in network settings
  2. How to change your DNS server using the terminal
  3. How to change your DNS server using the router
  4. Why should you consider changing your DNS server on Ubuntu?

How to customize DNS servers in network settings

Using Ubuntu with a graphical interface? Then you can use the Network Manager to modify the DNS servers.

Step 1: Launch the system Settings and select the Network menu.

Step 2: Enter the desired DNS server in the IPv4 and IPv6 pop-up in the appropriate format. To enter multiple server alternatives, separate the addresses with a comma.

Step 3: To ensure that the switch has worked, cut the server connection for a moment. After reconnecting to the internet, the new DNS server should be in use.

You can change the DNS server on Ubuntu via the GUI.

How to change your DNS server using the terminal

To set your DNS server in Ubuntu, you don’t need to rely on a graphical interface. You can simply use the command line to amend the DNS server. The resolv.conf file is used to assign DNS servers. Theoretically, you can just open the file and enter new name servers. However, because it’s managed by the system, changes are overwritten after a reboot. To prevent that from happening, do the following:

Step 1: Install the resolvconf, which lets you overwrite the system’s DNS information. Prior to installation, perform any updates as you normally would.

sudo apt update
sudo apt upgrade
sudo apt install resolvconf 

Copy

bash

Step 2: After installation, the service should be activated. You can do this using the following command:

sudo systemctl status resolvconf.service 

Copy

bash

If the software is working, you’ll see the status “active”.

If the service hasn’t been activated, you can start resolvconf manually:

sudo systemctl start resolvconf.service
sudo systemctl enable resolvconf.service
sudo systemctl status resolvconf.service 

Copy

bash

Step 3: Once resolvconf is running, you can make changes to the head file. Open the document using the nano editor:

sudo nano /etc/resolvconf/resolv.conf.d/head 

Copy

bash

Enter the DNS servers you’d like to use. Google’s DNS service is very popular. The search engine service offers two IPv4 addresses for this purpose.

nameserver 8.8.8.8
nameserver 8.8.4.4 

Copy

bash

Now save and exit the file.

Step 4: Update the resolv.conf file that is responsible for the DNS servers. Use the following commands to do so:

sudo resolvconf --enable-updates
sudo resolvconf -u 

Copy

bash

Step 5: For the changes to take effect, you should restart the corresponding services:

sudo systemctl restart resolvconf.service
sudo systemctl restart systemd-resolved.service 

Copy

bash

Check the resolv.conf file to view your changes. You can also see which DNS servers are currently in use. There are different commands for this, depending on which Ubuntu version you use.

Ubuntu 18.04 & 20.04:

systemd-resolve --status 

Copy

bash

Ubuntu 22.04:

resolvectl status 

Copy

bash

How to change your DNS server using the router

To switch DNS servers, you don’t need to make changes to your operating system. Configuring a different DNS server can easily be done from your router. The advantage of this method is that the changes to the server settings affect all devices in your network.

To do this, log in to the router’s admin interface. In most cases, you can just enter the router’s URL into your browser. You can find this in the device’s manual. Username and passwords should be available in the respective documents. Sometimes they’re printed on the router. In you have a Fritz!Box, enter http://fritz.box into your browser. You can now specify a DNS server in the internet settings.

With a Fritz!Box, you can enter other DNS servers in the internet settings.

Why should you consider changing your DNS server on Ubuntu?

Thanks to the Domain Name System (DNS), we typically don’t have to enter IP addresses into a browser when surfing the web. Computers use DNS for name resolution, that is, for the translation of a URL into an IP address. Your ISP assigns a default server for this purpose, but the default may not be the best choice. Here are some good reasons to change your DNS server:

Tip

You can change the DNS server on other operating systems too. From Windows to Mac to other Linux distributions, check out the following articles to see how:

Related articles

How does a DNS Records work?

Without the Domain Name System, the internet as we know it today would be inconceivable. The system for name resolution itself, is based on DNS records. In these simply structured records in normal text files, a name is stored for each IP address. However, DNS records can do more than this. Also known as resource records, various types of them exist.

How does a DNS Records work?

sdecoretShutterstock

What is DNS propagation?

If you change the DNS of a website, it can take hours or even days for the changes to reach each server. This transition phase is called DNS propagation. Our article shows you what it is, where the delay comes from, and how you can easily test DNS propagation.

What is DNS propagation?

Flush DNS | What it is and how it's done

Operating systems, such as Windows or macOS, automatically save information about address resolution from systems and applications in the network in a DNS cache. The purpose of this practical cache is to speed up network traffic. Read on to find out why it’s useful to regularly clear the DNS cache and how exactly such a DNS flush works.

Flush DNS | What it is and how it's done

Related Products

Cloud Servers

See packages

Deals at IONOS

Save on our most popular products, including cloud storage, hosting, websites, servers and more.

Find a deal

Popular Articles

Personal email domain: What is it and how to create an email address

Create your personal email address with your own email domain to demonstrate professionalism and credibility.

How do you buy a domain name? A guide

How do you register and secure a domain name? And how do you buy a domain that’s already been taken?

What are the different types of domains?

What are the different types of domain endings? And what’s the difference between top-level domains and second-level domains?…

What is prompt engineering and how does it work?

What is prompt engineering and how can it be used to improve the results of ChatGPT and other chatbots? Find out everything…

Different Website Types compared

Choosing the right type of website is critical to the success of any online endeavor. Corporate website, blog, microsite –…

We use cookies on our website to provide you with the best possible user experience. By continuing to use our website or services, you agree to their use. More Information.

OK

×

Special Deals Save on great business-boosting products

Build or host a website, launch a server, or store your data and more with our most popular products for less.

Find a deal

x▼