Software & AppsOperating SystemLinux

How To Refresh DNS Servers on Ubuntu Server 20.04?

Ubuntu 3

In this article, we will guide you through the process of refreshing or obtaining new DNS servers on Ubuntu Server 20.04. This task is important for maintaining the server’s ability to resolve domain names into IP addresses, which is crucial for the operation of many network services. Let’s get started.

Quick Answer

To refresh DNS servers on Ubuntu Server 20.04, you can start by restarting the systemd-resolved service using the command sudo systemctl restart systemd-resolved. If that doesn’t work, you can try requesting new DNS servers from the DHCP server using the sudo dhclient -r eth0 command. If all else fails, you can restart the networking service with sudo /etc/init.d/networking restart.

What is DNS?

The Domain Name System (DNS) is a hierarchical and decentralized naming system for computers, services, or other resources connected to the Internet or a private network. In simpler terms, it’s the phonebook of the Internet. Computers understand IP addresses, while humans find it easier to work with domain names. DNS servers are responsible for translating these domain names into IP addresses.

Checking DNS Servers

Before we start, it’s important to check the current status of your DNS servers. You can do this by opening an SSH session to your server and running the following command:

systemd-resolve --status

This command will display the status of the systemd-resolved service, which includes the list of DNS servers the system is currently using. If the DNS servers are not listed in the output, it means that they were not obtained during the boot process.

Restarting the systemd-resolved Service

The first method to refresh DNS servers is by restarting the systemd-resolved service. This service is responsible for network name resolution in Ubuntu. You can restart it by running the following command:

sudo systemctl restart systemd-resolved

In this command, sudo is used to execute the command with root privileges, systemctl is the system service manager, restart is the command to restart a service, and systemd-resolved is the name of the service to restart.

After restarting the service, you should check the output of systemd-resolve --status again to see if the DNS servers are now listed.

Requesting New DNS Servers

If the DNS servers are still not obtained, you can try running the dhclient command to request new DNS servers from the DHCP server. This command sends a request to the DHCP server to renew the DHCP lease and obtain new network configuration information, including DNS servers. Here is the command:

sudo dhclient -r eth0

In this command, -r is used to release the current lease and stop the running DHCP client as previously described, and eth0 is the name of the network interface. You should replace eth0 with the appropriate network interface name if necessary.

After running dhclient, check the output of systemd-resolve --status once more to verify if the DNS servers are now listed.

Restarting the Networking Service

If none of the above steps work, you can try restarting the networking service. However, keep in mind that this may temporarily disconnect your SSH session, so proceed with caution. Here is the command:

sudo /etc/init.d/networking restart

In this command, /etc/init.d/networking is the script that controls the networking service, and restart is the command to restart the service.

After the networking service restarts, check the output of systemd-resolve --status to confirm if the DNS servers are now obtained.

Conclusion

Refreshing or obtaining new DNS servers is an important task for maintaining the operation of your Ubuntu Server 20.04. By following these steps, you should be able to refresh your DNS servers and ensure that your server can resolve domain names into IP addresses. If you encounter any issues, don’t hesitate to consult the Ubuntu Server documentation or seek help from the Ubuntu community.

How do I check the current DNS servers on my Ubuntu Server 20.04?

To check the current DNS servers on your Ubuntu Server 20.04, you can open an SSH session to your server and run the command systemd-resolve --status. This will display the status of the systemd-resolved service, including the list of DNS servers the system is currently using.

What is the `systemd-resolved` service responsible for?

The systemd-resolved service is responsible for network name resolution in Ubuntu. It translates domain names into IP addresses, allowing your server to resolve domain names and access network services.

How do I restart the `systemd-resolved` service?

To restart the systemd-resolved service, you can run the command sudo systemctl restart systemd-resolved. This command will restart the service and refresh the DNS servers.

What can I do if restarting the `systemd-resolved` service doesn’t obtain new DNS servers?

If restarting the systemd-resolved service doesn’t obtain new DNS servers, you can try running the command sudo dhclient -r eth0 to request new DNS servers from the DHCP server. This command sends a request to renew the DHCP lease and obtain new network configuration information, including DNS servers.

Is it possible to restart the networking service to obtain new DNS servers?

Yes, it is possible to restart the networking service to obtain new DNS servers. However, keep in mind that this may temporarily disconnect your SSH session. To restart the networking service, you can run the command sudo /etc/init.d/networking restart.

Where can I find more information about Ubuntu Server 20.04 and DNS configuration?

You can find more information about Ubuntu Server 20.04 and DNS configuration in the Ubuntu Server documentation. Additionally, you can seek help from the Ubuntu community if you encounter any issues.

Leave a Comment

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