Bind
Installation
Source: fosslinux.com
- Update System
sudo apt-get update sudo apt-get upgrade sudo apt-get dist-upgrade
- Install DNS package
sudo apt-get install bind9
- Install DNS Utilities
sudo apt-get install dnsutils
- DNS Configuration
Usually, you can find the DNS configuration files stored in /etc/bind directory. /etc/bind/named.conf is the master configuration file that contains the DNS options. It’s highly recommended that you should be careful while editing it.
- Configuring NameServer
sudo vi /etc/bind/named.conf.options
Add the following block to it, here we have used Google’s DNS.
forwarders { 8.8.8.8; };
To enable the new configurations you should restart the DNS service.
sudo systemctl restart bind9
Test your query time:
dig google.com
- Primary Master
For a primary master server configuration, the DNS gets the data for a zone from a file stored on its host. Also, the DNS has control for that zone. Now let’s say we have a domain called “example.com” we are going to configure the DNS to be the primary master for that domain.
- Forward Zone File
Here in the forward zone, the name will map to the IP.
Step 1. Open and edit the /etc/bind/named.conf file.
sudo vi /etc/bind/named.conf
Ensure that it contains the following lines and NOT commented:
include “/etc/bind/named.conf.options”; include “/etc/bind/named.conf.local”; include “/etc/bind/named.conf.default-zones”;
Step 2. Open and edit the /etc/bind/named.conf.local file to add a DNS zone.
sudo vi /etc/bind/named.conf.local
Add the following block to it:
zone “example.com” { type master; file “/etc/bind/db.example.com”; };
Step 3. Create a zone file from the template one.
sudo cp /etc/bind/db.local /etc/bind/db.example.com
Step 4. Now open the new example zone file.
sudo vi /etc/bind/db.example.com
Please note that you have to increase the Serial Number every time you make changes to the zone files.
Step 5. Restart DNS Service to apply changes.
sudo systemctl restart bind9
- Reverse Zone File
Now to map an IP to a name you have to configure the reverse zone file.
Step 1. Edit the /etc/bind/named.conf.local file.
sudo vi /etc/bind/named.conf.local
Add the following block:
zone “10.0.2.in-addr.arpa” { type master; file “/etc/bind/db.10”; };
Where the 10.0.2 is the first three octets of your network.
Step 2. Create the /etc/bind/db.10 file from template one.
sudo cp /etc/bind/db.127 /etc/bind/db.10
Step 3. Edit the /etc/bind/db.10 file.
sudo vi /etc/bind/db.10
Step 4. Restart DNS Service to apply changes.
- Configuration Files Verification
Step 1. Execute the following commands to check if it will return any errors.
named-checkzone example.com /etc/bind/db.example.com named-checkzone 192.168.0.0/32 /etc/bind/db.10 named-checkconf /etc/bind/named.conf.local named-checkconf /etc/bind/named.conf
- References
{{#widget:DISQUS |id=networkm |uniqid=Bind |url=https://aman.awiki.org/wiki/Bind }}