Archive for December, 2015

If you haven’t already,set static IP address on Ubuntu Server.
If vim is your favorite editor,you need to download it

apt-get install vim

In terminal type:

sudo vi /etc/network/interfaces

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eno16777736 //inteface name
iface eno16777736 inet static 


Restart network for changes to take effect:

sudo /etc/init.d/networking restart


Install bind package

sudo apt-get install bind9

Bind comes with “templates” for zone files (/etc/bind),so we don’t need to create it from scratch (prefixed with db (0/127) are for reverse lookup zone).


But,first we need to define our zones in /etc/bind/named.conf file.

// This is the primary configuration file for the BIND DNS server named.
// Please read /usr/share/doc/bind9/README.Debian.gz for information on the
// structure of BIND configuration files in Debian, *BEFORE* you customize
// this configuration file.
// If you are just adding zones, please do that in /etc/bind/named.conf.local

include "/etc/bind/named.conf.options";
include "/etc/bind/named.conf.local";
include "/etc/bind/named.conf.default-zones";

zone "" {
type master;
file "/var/named/";

zone "" {
type master;
file "/var/named/";


In first section we define forward lookup zone (the resolution of host names to IP addresses)

Zone name is file name will be (You can name it whatever you like) and file location will be /var/named directory

In next section we define reverse lookup zone (use an IP address and look up a computer name based on its address)

Zone suffix is always and prefix is network in reverse order.In this example my network is 192.168.0 hence name file name is

I created folder named in /var directory

sudo mkdir /var/named


I copied “template” zone files from /etc/named  to /var/named and named it accordingly

sudo cp /etc/bind/db.local /var/named/
sudo cp /etc/bind/db.0 /var/named/

give named user ownership over /var/named:

sudo chown -R bind:bind /var/named/*

$TTL 604800
@ IN SOA                      (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
ubuntu IN A
win10 IN A
win8 IN A
@ IN AAAA ::1


$TTL 604800 defines the duration in seconds that the record may be cached

@ means this zone (

SOA:The SOA record stores information about the name of the server that supplied the data for the zone (don’t forget period at the end) is mail address resposibile person for zone

2 is serial zone number.It’s purpose in DNS zone files is to provide a way for the server to verify that the contents of a zone file are up-to-date. If the serial number in a zone file hasn’t changed since that zone was last loaded, named figures that it can ignore the file.I put datetime as number,followed with 01 at the end,you can put any number you like

Refresh: Indicates the time when the slave will try to refresh the zone from the master (if we have another DNS server which transfers zone files from master server)

Retry:Defines the time between retries if the slave (secondary) fails to contact the master when refresh (above) has expired

Expire:Indicates when the zone data are considered incorrect by slave server,then slave tries to get update from master server

Minimum: defines the duration in seconds that the record may be cached

We don’t have slave server so accept default values

@ IN NS don’t forget period at the end,if you omit it then server name would be appended at the end ( Name server for zone (our server)

ubuntu IN A –  host (A) record our server

Reverse zone file:

; BIND reverse data file
$TTL 604800
@ IN SOA     (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL


Basically all is the same except PTR record

PTR map a network address to a host name.

Some external mail exchange servers make reverse DNS lookups before accepting messages originating from your mail server.

Check zone files for typo errors:

named-checkzone /var/named/
named-checkzone /var/named/

Point our ubuntu DNS server to itsels,start named and check if it works:

Edit /etc/resolv.conf

cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
service bind9 start
dig -x




So far so good !,now try to ping some host,if ping fails,check /var/log/syslog



AppArmor is used to confine programs to a limited set of resources,similar to SELinux in Red Hat distros.In this example AppArmor prevents named to read our zone files.To overcome this issue edit /etc/apparmor.d/local/usr.sbin.named

# Site-specific additions and overrides for usr.sbin.named.
# For more details, please see /etc/apparmor.d/local/README.
/var/named/** r,

Reload apparmor and bind and you should be able to ping any hosts defined in zone files

sudo service apparmor reload sudo service bind9 restart

Test reverse zone:

dig AXFR