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 google.com, run the following command:
dig google.com
You should see a result similar to the following:
;; QUESTION SECTION:
;google.com. IN A;; ANSWER SECTION:
google.com. 300 IN A 172.217.6.46
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:
That's it for this post. Keep practicing and have fun. Leave your comments if any.
0 Comments