BIND(Berkeley Internet Name Domain) is a free open-source domain name server that can be installed on Linux. Having your local DNS server can be useful for several reasons:
- Faster DNS Queries
- Use as a mail server
- Blacklisting using DNS
- Use alongside your VPN server
In this tutorial, we will go through installing and configuring BIND DNS server to be used as a local resolver.
First, let's open up the terminal by selecting on the bottom left on the Ubuntu desktop and search for terminal up top to open up a terminal session.
Next, let's make sure our system packages are up to date
sudo apt update
Installing Bind DNS resolver
Now let’s install BIND with the following command below.
sudo apt install bind9 bind9utils bind9-doc bind9-host
Once installed, use the following command to check the version of BIND
Once installed, make sure to start/enable BIND with systemctl. The enable command will make sure BIND starts up at boot.
sudo systemctl start named
sudo systemctl enable named
After that, use systemctl to check the status of BIND
sudo systemctl status named
Setting up BIND as your local resolver
By default, BIND is already setup to be a DNS resolver for the localhost and local network but it is not set as your DNS server on your Shell. We need to change this to set BIND as your default resolver. We will do this by editing the following file
sudo nano /etc/systemd/resolved.conf
Just as the above screenshots, set DNS=127.0.0.1.
Next, we will need to restart the resolver service.
sudo systemctl restart systemd-resolved
Then, we will check the status to make sure our localhost address is used as the resolver.
Next, let's install dig to check A records
sudo apt install dnsutils
After dnsutils is installed, use dig to query a website. In this example I use shells.com
dig A shells.com
Then check syslogs to see if the localhost 127.0.0.1 actually queried for shells.com
sudo tail /ar/log/syslogs
And that’s it. You now have your own local DNS server/resolver using BIND. If you would like to learn more, about BIND please click on the link below.