Linux Series 2: DNS Zones and BIND9 configuration settings.

dedicated linux server hostingIn our last tutorial we covered the basics of how to install and configure a LAMP stack running Linux, Apache HTTP server, MySQL, and PHP. Now what is the next step? In this next tutorial we  will be learning how to set up and configure a DNS server. A DNS server is how we are going to  manage internal domain names at home or in the office. For this tutorial we will be using the BIND9 service. First a little bit about how DNS Works, DNS stands for Domain Name Servers, this is a service running on the server which tells that is located at IP address (amongst a million others) if the DNS service cannot find address on its DNS table it will begin querying other DNS services with a higher authority until it finds which DNS table holds the domain information for address When it finds this information that is then passed to the users browser however in the event no internet connected DNS server is found with domain information for this address it will display a message in the users browser such as “Server not found”

When it comes to DNS configuration settings they can be very tricky. They can also be very difficult at times and we can go into depth about some more of the functions later so we want to create a private internal domain name “” so lets find out what our internal IP address is. Open your terminal and type ifconfig this will display a listing of all of our network connections. Now let’s assume our internal network address is 10.0.2.x (which is what mine is at the moment) and our router and gateway is lets suppose all the devices on our network are going to be configured using static IP addresses (normally IP addresses are assigned automatically by DHCP but for the purpose of this tutorial we will have three static IP devices connected to our gateway.

1. Windows Desktop (pc) at

2. Ubuntu Desktop –

3. Our DNS server –

In order to configure our DNS server we first need to get it installed
so in the terminal we type:

sudo apt-get install bind9

after bind9 is installed we need to configure it. When it comes to configurations for DNS there are many codes it will allow us to use including SOA record (Indicates authority for this zone), NS record (Lists a name server for this zone), Other records (Data about hosts in this zone ), A (Name-to-address mapping), PTR (Address-to-name mapping), CNAME (Canonical name [for aliases]) Now the first thing we need to do is add our domain zone to the DNS local configuration

sudo gedit /etc/bind/named.conf.local

In here we want to place the following lines of code.

# Our domain zone
zone "" {
type master;
file "/etc/bind/zones/";


# For reverse DNS

zone “” {

type master;

file “/etc/bind/zones/”;


Next we need to add the DNS servers for our ISP into the options file, I am using “Bridgemaxx” as my ISP so I am using their DNS. IP addresses here can be separated by semicolons;

sudo gedit /etc/bind/named.conf.options

and add this snippet of code inserting your ISP DNS settings instead of mine.

forwarders {;

now we need to change the resolve.conf file and add our IP address of our DNS server here

sudo gedit /etc/resolve.conf

and then we add this bit of code:



The next step is to define our “zones” for that we need this piece of

sudo gedit /etc/bind/zones/


@ IN SOA (
); IN NS

ubuntudesktop IN A

www IN CNAME ubuntudesktop

pc IN A

gw IN A

TXT “Network Gateway”

The TTL or time to live is set for 3 days the nameserver is defined ubuntudesktop, pc and gateway are entered as an A record an alias of www is assigned to ubuntudesktop using CNAME. Now we need to create a file for the reverse DNS lookup. Now take special notice of the dot at the end of our nameservers this dot must be there or we will get some errors later.

sudo gedit /etc/bind/zones/

then type in this code:


@ IN SOA (











Save and close that and then restart the DNS server
sudo /etc/init.d/bind9 restart

Thats it a fully running operational internet facing domain name server and now a few commands just to prove it.

**There are so many other options we can change in the DNS settings and if you leave some specific questions in the comments I will respond to them. I will also be going more in depth on DNS settings Firewall settings, primary nameservers, secondary nameservers, authoritiv nameservers,  canonical names, firewall configurations, information security, system administration, user administration later. Also in order to effectivly manage and monitor our network and servers we will need the use of some programming so I will also be weaving some Perl,
Python, VB, PHP, SQL into these tutorials.