How to Set DNS Server in Linux Ubuntu?

How to Set DNS Server in Linux Ubuntu

DNS (Domain Name System) is an essential component of the internet infrastructure that translates domain names into IP addresses. In Linux Ubuntu, setting up a DNS server can improve the performance and reliability of your network connections. In this article, we will discuss how to set up a DNS server in Linux Ubuntu.

  1. Checking the Current DNS Server

Before configuring a DNS server, it is essential to check the current DNS server. To check the current DNS server, open the terminal and type the following command:

systemd-resolve --status | grep 'DNS Servers' -A2

The output will display the current DNS server.

  1. Setting up a DNS Server

To set up a DNS server in Linux Ubuntu, follow these simple steps:

Step 1: Open the terminal and edit the /etc/systemd/resolved.conf file using the following command:

sudo nano /etc/systemd/resolved.conf

Step 2: In the resolved.conf file, add the following lines:

[Resolve]
DNS=your_dns_server_ip
FallbackDNS=8.8.8.8 8.8.4.4

Replace "your_dns_server_ip" with the IP address of your DNS server.

Step 3: Save the file and exit.

Step 4: Restart the systemd-resolved service using the following command:

sudo systemctl restart systemd-resolved

  1. Verifying the DNS Server Configuration

To verify the DNS server configuration, open the terminal and type the following command:

systemd-resolve --status | grep 'DNS Servers' -A2

The output should display the new DNS server IP address.

  1. More Examples

Here are some more examples of how to set up a DNS server in Linux Ubuntu:

Example 1: Setting up Google Public DNS

To set up Google Public DNS, edit the /etc/systemd/resolved.conf file and add the following lines:

[Resolve]
DNS=8.8.8.8 8.8.4.4
FallbackDNS=

Save the file and restart the systemd-resolved service.

Example 2: Setting up Cloudflare DNS

To set up Cloudflare DNS, edit the /etc/systemd/resolved.conf file and add the following lines:

[Resolve]
DNS=1.1.1.1 1.0.0.1
FallbackDNS=

Save the file and restart the systemd-resolved service.

By following the steps and examples provided in this article, you can easily set up a DNS server in Linux Ubuntu and improve your network connection's performance and reliability.

Related Searches and Questions asked:

  • Linux DNS Server Configuration
  • How to Set DNS Server in Ubuntu Command Line?
  • Setting Up a Linux DNS Server on Ubuntu
  • Linux DNS Server List
  • That's it for this post. Keep practicing and have fun. Leave your comments if any.

    Post a Comment

    0 Comments