This article is a quick configuration manual of a Linux DNS server using bind. I believe thatbind do not need much introduction, but before you proceed with the installation and configuration of bind nameserver make sure that bind DNS server is exactly what you want. Default setup and execution of bind on Debian or Ubuntu may take around 200MB of RAM with no zones added to the config file. Unless you reduce the memory usage of a bind via various bind "options" config settings, be prepared to have some spare RAM available just for this service. This fact is even more important if you pay for your own VPS server.
Another DNS nameservers available on a Linux systems are NSD ( Name Server Daemon) or djbdns ( tinydns ). Both are lightweight alternatives to bind9 DNS server and have less RAM requirements. Apparently are even faster.
In this article we will not go into details of what Domain Name Service ( DNS ) is nor how DNS works. Rather we simply concentrate in a simple configuration of a custom zone and config file for a given domain / host supporting www, mail services.
Sample scenario notes to help you ready this DNS bind howto:
· nameserver IP address 192.168.135.130
· sample domain / host: linuxtechtips.com
· authoritative nameservers for a linuxtechtips.com zone: ns1.linuxtechtips.com ( 192.168.0.10 ) and ns2.linuxtechtips.com ( 192.168.0.11 )
· www and mail services for linuxtechtips.com will point to: 192.168.0.10
1. bind9 nameserver installation
Unless you prefer to install bind from a source code the installation is rather simple. On a Debian or Ubuntu Linux server you can install a bind nameserver with a following command:
CentOS or Fedora alternative:
dnsutils is not compulsory package to run bind webserver, but we will use a dig command which is part of this package as a testing tool of your bind configuration.
2. Creating a DNS zone file
At this stage we will need to create a new zone file for a domain linuxtechtips.com. Navigate to /etc/bind/ directory execute following sequence of commands to navigate to zones/master/
/etc/bind/zones/master directory will contain a zone file for a linuxtechtips.com domain. If you prefer to use another directory to hold this file you are free to do so. The following zone file db.linuxtechtips.com will hold a DNS record to assist a nameserver resolve a fully qualified domain name to an IP address. Create and save db.linuxtechtips.com with a following content:
Here is just a quick review of some lines from the above bind DNS zone file:
· SOA Record: nameserver authoritative for a zone linuxtechtips.com is ns1.linuxtechtips.com and admin.linuxtechtips.com is an email address of a person responsible for this DNS zone.
· NS Records: two nameservers for a linuxtechtips.com zone are ns[1,2].linuxtechtips.com
· MX ( Mail Exchange): linuxtechtips.com mail exachange record. Number 10 means a preference for discarting a records A : A simply means address inanother words in linuxtechtips.com's zone a ns1 would ahve a A ( address ) 192.168.0.10.
· CNAME Record ( Canonical Name record ): restart the query using the canonical name instead of the original name
3. address-to-name mappings
At this stage the bind DNS server can resolve an IP address mapped to a linuxtechtips.com host. What we should do now is the teach our nameserver the other way around, which is, to resolve a host from an IP address. For this we are going to need yet another file and that isdb.192.168.0 with a following content:
· PTR: a NDS record used for a mapping of an IP address to a host name.
4. Updating a BIND Configuration File
At this point we should have two files ready:
All we need to do now is to insert both zone file names into a bind's configuration file named.conf.local. To do that add following lines into this file:
Last thing before we go ahead to check a configuration is to add and IP address af a stable DNS server to a named.conf.options file. This IP address is used in case that a local DNS server do not know the answer the a name resolution query. In IP address of a DNS server in many cases is provided by your Internet provider. Alternatively if you are google fan use 184.108.40.206 or 220.127.116.11.
Replace a following blog of text withing a named.conf.options file:
with new stable DNS server IP address
5. Checking bind's zone files and configuration
Before we attempt to start a bind nameserver with a new zone and configuration here are some tools to check if we have not done some typo or misconfiguration.
To check a configuration files run a following command:
With this named-checkconf command the rule is: no news are good news. If no output had been produced your config files looks OK.
To check a DNS zone files we can use named-checkzone command:
reverse zone file check:
6. Start / restart bind nameserver
At this point nothing can stop us to run bind9 dns server:
Alternatively, if your bind server is already running use a following command to to assist you with its restart:
7. Testing a bind server configuration
A dig command from dnsutils package will become handy to help us to test a new configuration of bind nameserver.
dig command can be used from any PC which has a network access the your DNS server but preferably your should start your testing from a localhost. In our this case the IP address of our name server is 192.168.135.130. First we will test host-to-IP resolution:
Next we test IP-to-host resolution:
Congratulations, you have just created and configured your own DNS zone using bind nameserver.