Software & AppsOperating SystemLinux

How To Reset DNS Settings in Ubuntu 18.04?

Ubuntu 13

In this article, we’ll guide you through the process of resetting DNS settings in Ubuntu 18.04. DNS, or Domain Name System, is a critical component of your system’s networking setup, translating human-friendly URLs into IP addresses that your computer can understand. However, there might be times when you need to reset these settings to their defaults. Let’s dive in.

Quick Answer

To reset DNS settings in Ubuntu 18.04, you can use the systemd-resolved service. By editing the resolved.conf file and modifying the necessary lines, you can reset the DNS servers, disable certain features, and enable caching. After saving the changes, update the resolv.conf file and verify the settings using systemctl.

Understanding DNS Settings

Before we proceed with the reset process, it’s important to understand what DNS settings are. When you connect to a network, your computer is assigned a DNS server, which it uses to resolve domain names into IP addresses. Sometimes, these settings may need to be reset, either because they’ve been configured incorrectly or because you want to switch back to the default settings.

Resetting DNS Settings in Ubuntu 18.04

Ubuntu 18.04 uses systemd-resolved, a system service that provides network name resolution to local applications. Here’s how you can reset your DNS settings to the defaults using this service:

Step 1: Edit the resolved.conf file

Open your terminal and type the following command:

sudo nano /etc/systemd/resolved.conf

This command opens the resolved.conf file in the Nano text editor with superuser permissions.

Step 2: Modify the DNS settings

In the resolved.conf file, you’ll see several lines starting with #. These are comments, and the settings they represent are currently inactive. To reset your DNS settings, you’ll need to uncomment and modify these lines as follows:

  • DNS=: This line specifies the DNS servers to use. Uncomment this line and leave it blank to use the default servers.
  • FallbackDNS=: This line specifies the fallback DNS servers. Uncomment it and leave it blank to use the default servers.
  • Domains=: This line specifies the search domains. Uncomment it and leave it blank to use the default domains.
  • LLMNR=no: This line disables Link-Local Multicast Name Resolution. Uncomment it to disable LLMNR.
  • MulticastDNS=no: This line disables Multicast DNS. Uncomment it to disable mDNS.
  • DNSSEC=no: This line disables DNSSEC. Uncomment it to disable DNSSEC.
  • DNSOverTLS=no: This line disables DNS over TLS. Uncomment it to disable DNS over TLS.
  • Cache=yes: This line enables DNS caching. Uncomment it to enable caching.
  • DNSStubListener=yes: This line enables the DNS stub listener. Uncomment it to enable the stub listener.

Step 3: Save and exit

Press Ctrl+X to exit the editor, then press Y and Enter to save your changes.

Step 4: Update the resolv.conf file

Next, you’ll need to update the resolv.conf file. Run the following command:

sudo rm /etc/resolv.conf && sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

This command removes the existing resolv.conf file and creates a symbolic link to the stub-resolv.conf file, which is managed by systemd-resolved.

Step 5: Verify the changes

To verify that systemd-resolved is enabled and using the correct settings, run the following command:

systemctl status systemd-resolved.service

If systemd-resolved is not enabled, you can enable and start it with these commands:

sudo systemctl enable systemd-resolved.service
sudo systemctl start systemd-resolved.service

Conclusion

Resetting your DNS settings in Ubuntu 18.04 is a straightforward process thanks to systemd-resolved. By following the steps outlined in this article, you can easily revert your DNS settings back to their defaults. If you encounter any issues, remember to check for any conflicting processes listening on port 53, as these can interfere with systemd-resolved.

What is DNS?

DNS stands for Domain Name System. It is a system that translates human-friendly domain names, such as www.example.com, into IP addresses that computers can understand.

Why would I need to reset DNS settings?

There are several reasons why you might need to reset DNS settings. Some common reasons include resolving issues with incorrect or misconfigured settings, reverting back to default settings, or troubleshooting network connectivity problems.

How does systemd-resolved work?

systemd-resolved is a system service in Ubuntu 18.04 that provides network name resolution to local applications. It manages DNS settings and caching, allowing your computer to resolve domain names into IP addresses.

Can I reset DNS settings without using systemd-resolved?

In Ubuntu 18.04, systemd-resolved is the default DNS resolver. While there may be alternative methods to reset DNS settings, this article focuses on using systemd-resolved for simplicity and compatibility.

How do I open the resolved.conf file?

To open the resolved.conf file, open your terminal and type the command sudo nano /etc/systemd/resolved.conf. This will open the file in the Nano text editor with superuser permissions.

How do I save and exit the editor in Nano?

To save and exit the editor in Nano, press Ctrl+X to exit. You will be prompted to save the changes. Press Y and then Enter to save the changes and exit the editor.

How can I verify if systemd-resolved is enabled and using the correct settings?

To verify if systemd-resolved is enabled and using the correct settings, run the command systemctl status systemd-resolved.service in the terminal. This will display the status of the systemd-resolved service and any relevant information.

What should I do if systemd-resolved is not enabled?

If systemd-resolved is not enabled, you can enable and start it by running the following commands in the terminal:

sudo systemctl enable systemd-resolved.service
sudo systemctl start systemd-resolved.service

Leave a Comment

Your email address will not be published. Required fields are marked *