Ubuntu is one of the most popular Linux distributions, and it is widely used by web developers and system administrators alike. Setting up a DNS server on Ubuntu is a relatively straightforward process, and in this blog article, I will walk you through the steps you need to take to set up a DNS server on Ubuntu.
A DNS server is a computer that acts as a translator between the IP address and the domain name. It is responsible for translating the domain name into its corresponding IP address. By setting up a DNS server on Ubuntu, you will be able to manage your DNS records and improve the performance of your website.
Are you looking for an easy way to set up a DNS server on Ubuntu? Well, you have come to the right place! In this blog article, I will provide you with a comprehensive step-by-step guide on how to quickly and easily set up a DNS server on Ubuntu.
Whether you are a beginner or an expert, this guide will help you set up a DNS server on Ubuntu in no time. So, let’s get started!
Step 1 – Install DNS (bind9) Packages
The first step in setting up a DNS server on Ubuntu is to install the DNS server. It is a straightforward process, and you can do it by running the following command:
sudo apt update
sudo apt install bind9 -y
Step 2 – Create Forward Zone File
A forward DNS zone is responsible for translating the domain name into the corresponding IP address. To set up a forward DNS zone, you need to create a zone file for each domain that you want the DNS server to manage. For example, if your domain is example.net, then create the zone files by running the following command:
sudo vi /etc/bind/example.net.zone
Add the following content
Save the file and close it.
Then use named-checkzone command to verify the syntax of the configuration file.
sudo named-checkzone example.net /etc/bind/example.net.zone
On successful, an OK message will appear on the output screen.
Step 3 – Create Reverse Zone File
Generally, reverse DNS configuration is not required, but in some cases, you may need to configure it. This is used to resolve the domain name corresponding to an IP address. For example, we are using the 192.168.1.0/32 IP range in our intranet. Create reverse DNS file named /etc/bind/db.1.168.192 with following content.
sudo vi /etc/bind/db.1.168.192
and add following content
Save the file and verify the file syntax:
named-checkzone 192.168.01.0/32 /etc/bind/db.1.168.192
On successful, an OK message will appear on the output screen.
Step 4 – Update Bind9 Main Configuration
The next step in setting up a DNS server on Ubuntu is to configure the DNS server. You can do this by editing the configuration file. You can find the configuration file by running the following command:
sudo vi /etc/bind/named.conf.local
Append following content
Save the file and check the configuration files:
On successful, nothing will appear on the output screen.
Step 5 – Restart bind9 Service
Once all the configuration files are verified, You can restart the bind9 service o apply changes.
sudo systemctl restart bind9
sudo systemctl status bind9
Output● named.service - BIND Domain Name Server Loaded: loaded (/lib/systemd/system/named.service; enabled; vendor preset: enabled) Active: active (running) since Mon 2022-04-25 12:17:31 IST; 2h 16min ago Docs: man:named(8) Process: 10725 ExecStart=/usr/sbin/named $OPTIONS (code=exited, status=0/SUCCESS) Main PID: 10726 (named) Tasks: 4 (limit: 2271) Memory: 5.6M CPU: 146ms CGroup: /system.slice/named.service └─10726 /usr/sbin/named -u bind
The bind9 service should be active and running.
Step 6 – Testing the DNS Server
Once you have configured the DNS server, you need to test it to make sure that it is working properly. You can do this by running the following command:
This command will query the DNS server for information about the domain example.com. If the DNS server is configured correctly, you should be able to see the IP address of the domain in the output.
Verify Forward Zone:
Output; <<>> DiG 9.16.1-Ubuntu <<>> example.net ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 42007 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ; COOKIE: b8e8bae7636ea5990100000062665dfb3fce096db82322ba (good) ;; QUESTION SECTION: ;example.net. IN A ;; ANSWER SECTION: example.net. 14400 IN A 192.168.1.100 ;; Query time: 4 msec ;; SERVER: 192.168.1.212#53(192.168.1.212) ;; WHEN: Mon Apr 25 14:04:08 IST 2022 ;; MSG SIZE rcvd: 84
Verify Reverse Zone:
dig -x 192.168.1.100
Output; <<>> DiG 9.16.1-Ubuntu <<>> -x 192.168.1.100 ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26175 ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1 ;; OPT PSEUDOSECTION: ; EDNS: version: 0, flags:; udp: 1232 ; COOKIE: df64db0c13af750e0100000062665e1e52dc99d0a2d5dd41 (good) ;; QUESTION SECTION: ;18.104.22.168.in-addr.arpa. IN PTR ;; ANSWER SECTION: 22.214.171.124.in-addr.arpa. 604800 IN PTR example.net. ;; Query time: 0 msec ;; SERVER: 192.168.1.212#53(192.168.1.212) ;; WHEN: Mon Apr 25 14:04:43 IST 2022 ;; MSG SIZE rcvd: 108
Setting up a DNS server on Ubuntu is a relatively straightforward process. In this blog article, I have provided you with a comprehensive step-by-step guide on how to quickly and easily setup a DNS server on Ubuntu, Debian and Linux Mint. I hope this guide was helpful and that you were able to set up a DNS server on Ubuntu without any issues.
If you have any questions or comments, please feel free to leave them in the comments section below. I would love to hear your feedback!
another site with no help for beginners don’t understand what’s suppose to be done or how to
How did you disable / remove dnsmasq so that port 53 was available for bind9 to use as a dns server?
This is a problem on Linux Mint 17 which puts bind9 on port 953 when dnsmasq is already installed. (it is installed and active and attached to port 53 by default when you install Linux Mint 17 )
I added bind9 to my system and am now experiencing 15 second or longer delays in responses to queries from remote hosts. This delay blows mail services out of the water and delays client access to the web server. My bind9 server is being used as an authoritative dns for my domain so this affects everything associated to the domain.