How to Install Bind DNS on Ubuntu 20.04 Server (Setup / Configure). BIND server is the most popular Domain Name System (DNS) server in use today. BIND is used to run a caching DNS server or an authoritative name server and some features are: load balancing, dynamic update, notify, split DNS, DNSSEC, IPv6. We will walk you through the topic what is DNS Server and how does it work and introduce Bind DNS server with its pros and move onto install phase on Ubuntu 20.04. Let’s start!
What is DNS
DNS stands for the Domain Name System. It is a system that converts domain names into IP addresses which are used by a web browser to load internet web pages or other resources on the internet.
All devices that connect to the internet have their own unique IP address which helps other devices recognize it.
DNS servers make it easier for users to use ordinary names for the browser, say reddit.com, without referring to complex IP addresses for the website. Simply type the name of the website and DNS will get the IP address automatically.
A DNS Server is a computer device with a large database comprising all the IP addresses linked to the website names that an IP address redirects users to. DNS is like your internet phone book where it will find the right IP address linked to the domain names you type in the address bar of a browser.
Once you type the domain name, the DNS server will find the right IP address, and the browsers will use the address to transmit data to CDN (content delivery network) edge data servers. With this, users can easily access the site’s data. The DNS server instigates the process by precisely finding the right IP address for a site’s URL.
How Does DNS Work
In a DNS query, a user types the site’s URL and it further goes through 4 servers to get the right IP address. These four servers work collaboratively to achieve the correct IP address and provide it to the client. These are as follows:
1. DNS Recursor: The DNS recursor, also popularly known as a DNS resolver is the server that receives the initial DNS query from the DNS client. Further, it does the job of interacting with the rest of the three DNS servers to find the correct IP address. Once a DNS recursor retrieves the query, it now acts as a DNS client itself. It will receive queries and further send them to the rest of the three DNS servers.
2. Root Nameservers: The root nameserver, as name suggests, is consigned specifically to the internet’s DNS root zone. This server will answer the queries that come to it for records in the DNS root zone. As an answer, it will send back a list of the authoritative nameservers that match with the right TLD (top level domain) nameservers.
3. TLD nameservers: A TLD nameserver does the job of keeping the second level domain’s IP address confined inside the TLD name. Next, it releases the site’s IP address and sends the query further to the nameserver of the domain.
4. Authoritative nameservers: An authoritative nameserver will provide the correct answer to your DNS query. Authoritative nameservers are two types viz. A Master Server/Primary nameserver and a Slave Server/Secondary nameserver. Out of these, the master server contains the original copies of the records in root zone, and the slave server is the precise copy of the master server. It does the job of sharing the load of the DNS server and also acts as a backup in case the master server ever fails.
Follow this post to learn how to setup the Bind DNS server on Ubuntu 20.04.
BIND is a free and open source software package, where you can build your own custom tools to address specific DNS use cases and operational requirements. BIND gives a very granular control over a DNS server. BIND pros are as follows:
BIND Server features
DNS server with Authority .
Cache Only DNS (provides DNS name resolution for applications or acts as a secondary DNS server for read only copy of the authoritative zone file.
Bind DNS server’s configuration files are located inside /etc/bind directory. First, you will need to edit /etc/bind/named.conf.options file and add forwarders. DNS query will be forwarded to the forwarders when your local DNS server is unable to resolve the query.
nano /etc/bind/named.conf.options
Uncomment and change the following lines:
forwarders {
8.8.8.8;
};
Save and close the file when you are finished. Next, edit the /etc/bind/named.conf.local file to define the zone for your domain.
nano /etc/bind/named.conf.local
Add the following lines:
zone "mydomain.com" {
type master;
file "https://net.cloudinfrastructureservices.co.uk/etc/bind/forward.mydomain.com";
};
zone "0.16.172.in-addr.arpa" {
type master;
file "https://net.cloudinfrastructureservices.co.uk/etc/bind/reverse.mydomain.com";
};
Save and close the file, when you are finished. Then, verify the configuration file for any error using the following command:
named-checkconf
You will not get any output if everything is fine.
A brief explanation of above file is shown below:
mydomain.com is your forward zone.
0.16.172.in-addr.arpa is your reverse zone.
forward.mydomain.com is the name of the forward lookup zone file.
reverse.mydomain.com is the name of the reverse lookup zone file.
Next, you will need to configure the forward and reverse lookup zone for your domain. A forward lookup zone is a DNS zone that converts a name to an IP address. When a computer asks for the IP address of a specific hostname, the forward lookup zone is checked and the desired result is returned. A reverse lookup zone is the opposite of a forward lookup zone that converts an IP address to the fully qualified domain name.
First, change the directory to the /etc/bind with the following command:
cd /etc/bind/
Next, copy a sample forward and reverse lookup zone file with the following command:
$TTL 604800
@ IN SOA nameserver.mydomain.com. root.nameserver.mydomain.com. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
@ IN NS nameserver.mydomain.com.
nameserver IN A 172.16.0.10
www IN A 172.16.0.10
@ IN AAAA ::1
Where:
172.16.0.10: IP address of DNS server.
NS: Name server record.
A: Address record.
SOA: Start of authority record.
Save and close the file. Then, edit the reverse lookup zone file:
nano /etc/bind/reverse.mydomain.com
Make the following changes:
$TTL 604800
@ IN SOA nameserver.mydomain.com. root.nameserver.mydomain.com. (
1
604800
86400
2419200
604800 )
@ IN NS nameserver.mydomain.com.
nameserver IN A 172.16.0.10
10 IN PTR nameserver.mydomain.com.
Save and close the file. Then, edit the /etc/resolv.conf file and define your DNS server:
nano /etc/resolv.conf
Add the following lines:
search mydomain.com
nameserver 172.16.0.10
Save and close the file. Then, restart the Bind DNS service to apply the changes:
systemctl restart named
Next, check the forward and reverse lookup zone file for any syntax error with the following command:
Bind DNS server is now installed and configured. It’s time to check whether it is working or not. In this section, we will use the dig command line tool to check DNS.
First, run the dig command against your DNS nameserver:
dig nameserver.mydomain.com
You should see the following output:
; <<>> DiG 9.16.1-Ubuntu <<>> nameserver.mydomain.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29810
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: a5919d692166f92001000000627498b926c5a27d5f9c28a1 (good)
;; QUESTION SECTION:
;nameserver.mydomain.com. IN A
;; ANSWER SECTION:
nameserver.mydomain.com. 604800 IN A 172.16.0.10
;; Query time: 0 msec
;; SERVER: 172.16.0.10#53(172.16.0.10)
;; WHEN: Fri May 06 03:40:41 UTC 2022
;; MSG SIZE rcvd: 96
Now, run the dig command against the DNS server’s IP to perform the reverse lookup query as shown below:
How to Install Bind DNS on Ubuntu 20.04 Server (Setup / Configure) Conclusion
In this guide, we explained how to setup the Bind DNS server on Ubuntu 20.04. We also explained how to create forward and reverse DNS zones and test the DNS using the Dig command line utility. You can now implement the DNS server in your local environment for local name resolution.
I am a fan of open source technology and have more than 10 years of experience working with Linux and Open Source technologies. I am one of the Linux technical writers for Cloud Infrastructure Services.
3.33votes
Article Rating
Subscribe
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.
DisagreeAgree
Login and comment with
I allow to create an account
When you login first time using a Social Login button, we collect your account public profile information shared by Social Login provider, based on your privacy settings. We also get your email address to automatically create an account for you in our website. Once your account is created, you'll be logged-in to this account.