In this tutorial, we will show you how to install the BIND9 master and slave DNS server on Ubuntu. For those of you who didn’t know, BIND9 (Berkeley Internet Name Domain) is the most widely used Domain Name System (DNS) software on the internet. It is open-source software that can be used as a master or slave DNS server.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo
‘ to the commands to get root privileges. I will show you the step-by-step installation of the BIND9 on the Ubuntu system. You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.
Prerequisites
- A server running one of the following operating systems: Ubuntu 22.04, 20.04, and any other Debian-based distribution like Linux Mint.
- It’s recommended that you use a fresh OS install to prevent any potential issues.
- SSH access to the server (or just open Terminal if you’re on a desktop).
- An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies for BIND9.
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install BIND9 Master and Slave DNS Server on Ubuntu
Step 1. First, make sure that all your system packages are up-to-date by running the following apt
commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Installing BIND9 on Ubuntu.
By default, BIND9 is available on Ubuntu 22.04 base repository. Now we install BIND9 using the following command below:
sudo apt install bind9
After the installation is complete, you can verify the version of BIND9 using the following command:
named -v
Step 3. Configuring the Master DNS Server.
Open the named.conf.local
file using the nano editor:
nano /etc/bind/named.conf.local
Add the following lines:
zone "your-domain.com" { type master; file "/etc/bind/db.your-domain.com"; };
This code tells the BIND9 server to act as the master for the example.com domain and to use the file /etc/bind/db.your-domain.com
for zone data.
Next, create a zone data file /etc/bind/db.your-domain.com
using the following command:
nano /etc/bind/db.your-domain.com
Add the following file:
$TTL 604800 @ IN SOA ns1.your-domain.com. admin.your-domain.com. ( 3 ; Serial 604800 ; Refresh 86400 ; Retry 2419200 ; Expire 604800 ) ; Negative Cache TTL ; @ IN NS ns1.your-domain.com. @ IN NS ns2.your-domain.com. ns1 IN A 192.168.1.1 ns2 IN A 192.168.1.2
This code sets the Time to Live (TTL) for the zone to 604800 seconds, specifies the domain name and the email address of the domain administrator, and defines the nameservers and their IP addresses.
Save and close the file, then restart the BIND9 service to apply the changes:
sudo systemctl restart bind9
Step 4. Configuring the Slave DNS Server.
Now edit the /etc/bind/named.conf.local
file and add the following configuration:
zone "your-domain.com" { type slave; file "/var/cache/bind/db.your-domain.com"; masters { 192.168.1.1; }; };
This tells the Slave DNS Server that it is a slave for the your-domain.com
zone and that it should get its zone data from the Master DNS Server with IP address 192.168.1.1.
Save and close the file, then restart the BIND9 service to apply the changes:
sudo systemctl restart bind9
Step 5. Test the DNS Setup.
Run the nslookup
command and specify the domain name you want to look up:
nslookup www.your-domain.com
If everything is working correctly, the DNS Server should return the IP address of www.your-domain.com
that was configured in the db.your-domain.com
zone file on the Master DNS Server.
Congratulations! You have successfully installed BIND9. Thanks for using this tutorial for installing the BIND9 on the Ubuntu system. For additional help or useful information, we recommend you check the official BIND9 website.