You can Watch all our Tutorials and Training Videos for Free on ourYouTube Channel

How to Configure DNS Server in Linux Ubuntu?

How to Configure DNS Server in Linux Ubuntu, ?, linux dns server, linux dns server configuration, simple dns server linux, configure dns, DevOps
How to Configure DNS Server in Linux Ubuntu

DNS (Domain Name System) is an essential component of the internet infrastructure. It allows users to access websites and services by typing a domain name instead of an IP address. In this article, we will explain how to configure a DNS server on Linux Ubuntu.

Before we start, make sure you have root access to your Linux Ubuntu system and have installed the Bind9 DNS server package.

Step 1: Configure the Network Settings

To configure the DNS server, the first step is to ensure that the network settings on your Ubuntu system are configured to use the local DNS server. Open the /etc/network/interfaces file and add the following lines at the end:

dns-nameservers <IP_address_of_your_DNS_server>
dns-search <your_domain_name>

Save and exit the file.

Step 2: Configure the Bind9 DNS Server

Next, we need to configure the Bind9 DNS server. Open the /etc/bind/named.conf.local file and add the following lines:

zone "<your_domain_name>" {
type master;
file "/etc/bind/db.<your_domain_name>";

Replace <your_domain_name> with your actual domain name. Save and exit the file.

Step 3: Create a Zone File

Now, we need to create a zone file for our domain. Create a file called /etc/bind/db.<your_domain_name> and add the following lines:

$TTL 86400
@ IN SOA ns1.<your_domain_name>. admin.<your_domain_name>. (
1 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ; Minimum TTL
IN NS ns1.<your_domain_name>.
ns1 IN A <IP_address_of_your_DNS_server>

Replace <your_domain_name> and <IP_address_of_your_DNS_server> with your actual values. Save and exit the file.

Step 4: Restart the DNS Server

After making the above changes, we need to restart the Bind9 DNS server. Run the following command:

sudo service bind9 restart

Step 5: Test the DNS Server

To test the DNS server, use the dig command. For example, to look up the IP address of, run the following command:


You should see a result similar to the following:

; IN A


Congratulations! You have successfully configured a DNS server on Linux Ubuntu.

More Examples:

  • To add additional DNS records, edit the zone file (/etc/bind/db.<your_domain_name>) and add the required records.
  • To configure a secondary DNS server, add the necessary configuration in the named.conf.local file and create a copy of the zone file on the secondary server.

Related Searches and Questions asked:

  • How to Find All DNS Servers in Linux?
  • How to Add CNAME Record to DNS in Linux
  • How to Configure Primary and Secondary DNS Server in Linux?
  • How to Configure DNS Server in Linux Step by Step?
  • That's it for this post. Keep practicing and have fun. Leave your comments if any.

    Cookie Consent
    We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
    It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
    AdBlock Detected!
    We have detected that you are using adblocking plugin in your browser.
    The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
    Site is Blocked
    Sorry! This site is not available in your country.
    whatsapp logo