DNS Server Setup: BIND9 Configuration and Zone File Management
The Domain Name System (DNS)
The Domain Name System (DNS) is a standard technology for managing the names of Web sites and other Internet domains. DNS technology allows you to type names into your Web browser like engine.com and your computer to automatically find that address on the Internet. A key element of the DNS is a worldwide collection of DNS servers. A DNS server is any computer registered to join the Domain Name System. A DNS server runs special-purpose networking software, features a public IP address, and contains a database of network names and addresses for other Internet hosts. A local DNS server which performs domain name lookup is usually located on the network to which your computer is attached. If you are using an Internet Service Provider (ISP), your DNS server is at your ISP. If you are using the network at your college or your office, you probably have a local DNS server somewhere near you in the server room.
BIND9 can provide many different DNS services. Some of the most useful setups are:
- Caching Server: In this configuration, BIND9 will find the answer to name queries and remember the answer for the next query. This can be useful for a slow internet connection. By caching DNS queries, you will reduce bandwidth and (more importantly) latency.
- Primary Master Server: BIND9 can be used to serve DNS records (groups of records are referred to as zones) for a registered domain name or an imaginary one (but only if used on a restricted network).
- Secondary Master DNS Server: A secondary master DNS server is used to complement a primary master DNS server by serving a copy of the zone(s) configured on the primary server. Secondary servers are recommended in larger setups. If you intend to serve a registered domain name, they ensure that your DNS zone is still available even if your primary server is not online.
Configuring BIND9
Step 1: Install BIND9 and DNS utilities:
sudo apt-get install bind9 dnsutils
Step 2: The DNS configuration files are stored in the /etc/bind directory:
- /etc/bind/named.conf
- /etc/bind/named.options
- /etc/bind/named.conf.local
The primary configuration file is /etc/bind/named.options (this file tells DNS where to look for files). The file named /etc/bind/db.root describes the root nameservers in the world. The servers change over time, so the /etc/bind/db.root file must be maintained now and then. This is usually done as updates to the bind9 package. The zone section defines a master server, and it is stored in a file mentioned in the file option.
Step 2.1: Configure DNS to Cache Requests
To configure the DNS to cache requests and forward unknown requests to other DNS servers, open sudo /etc/bind/named.conf.options file. Uncomment or add the forwarders section and replace the x:es with the IP addresses of Google Public DNS as my forwarders, currently 8.8.8.8 and 8.8.4.4.
Step 3: Make the server use its own DNS for look-ups, assign static IP for our critical server:
/etc/network/interfaces
Run the following command:
sudo /etc/init.d/networking restart
Zone File Configuration
To add a DNS zone to BIND9, turning BIND9 into a Primary Master server, all you have to do is edit named.conf.local. Now use an existing zone file as a template:
sudo cp /etc/bind/db.local /etc/bind/db.engine.com
Edit the new zone. Once you’ve made a change to the zone file, BIND9 will need to be restarted for the changes to take effect:
sudo /etc/init.d/bind9 restart
Reverse Zone File
Now that the zone file is setup and resolving names to IP Addresses, a Reverse zone is also required. A Reverse zone allows DNS to convert from an address to a name.
Now create the db.192
file:
sudo cp /etc/bind/db.127 /etc/bind/db.192
Next, edit /etc/bind/db.192
, changing basically the same options as in /etc/bind/db.engine.com
.
sudo /etc/init.d/bind9 restart
Testing the Configuration
You should now be able to ping engine.com
and have it resolve to the host configured above:
ping engine.com