In this article, we will see how to setup a dns server in Ubuntu Linux which is running in a local area network ( LAN ). We are setting up DNS in Ubuntu 11.04 using Bind9.
1. What to do
In this article, we will do the following things :
- Setup a name server in an Ubuntu machine(Ubuntu 12.04) whose static ip address is 192.168.1.100
- Test the domain “wptrafficanalyzer.local” from Ubuntu 11.04
- Test the domain “wptrafficanalyzer.local” from Windows 7
2. Setup the domain “wptrafficanalyzer.local” in Ubuntu machine
2.1. Install bind9
$sudo apt-get install bind9
2.2 Edit the file /etc/bind/named.conf.local to add zone for the domain wptrafficanalyzer.local
# Our domain zone zone "wptrafficanalyzer.local" { type master; file "/etc/bind/zones/wptrafficanalyzer.local.db"; }; # For reverse DNS zone "1.168.192.in-addr.arpa" { type master; file "/etc/bind/zones/rev.1.168.192.in-addr.arpa"; };
2.3 Edit the file /etc/bind/named.conf.options to set forwarders
forwarders { x.x.x.x; };
Note : Update x.x.x.x with the ip of your ISP’s name server
2.4 Create a directory /etc/bind/zones
$mkdir /etc/bind/zones
2.5 Create a zone file namely wptrafficanalyzer.local.db in /etc/bind/zones
$TTL 1D ; default expiration time ; @ represents zone origin ; dot(.) at the end of host name represents that it is a fully qualified domain name ; ns.wptrafficanalyzer.local. represents name server ; admin.wptrafficanalyzer.local. represents email id of zone admin @ IN SOA ns.wptrafficanalyzer.local. admin.wptrafficanalyzer.local. ( 2012120316 ; serial number 1d ; slave refresh time 2h ; slave retry time 4w ; slave expiration time 1h ; Negative Cache TTL ) ; the given below record specifies that, nameserver of wptrafficanalyzer.local ; is ns.wptrafficanalyzer.local @ IN NS ns.wptrafficanalyzer.local. ; the given below record specifies that, the ip address of ns.wptrafficanalyzer.local is ; 192.168.1.100 ns IN A 192.168.1.100 ; the given below record specifies that, the ip address of wptrafficanalyzer.local is ; 192.168.1.3 @ IN A 192.168.1.3
Note : Semicolon(;) in the above lines, represents comments
2.6 Create a reverse zone file namely rev.1.168.192.in-addr.arpa in /etc/binds/zone
$TTL 1D ; default expiration time ; @ represents zone origin ; dot(.) at the end of host name represents that it is a fully qualified domain name ; ns.wptrafficanalyzer.local. represents name server ; admin.wptrafficanalyzer.local. represents email id of zone admin @ IN SOA ns.wptrafficanalyzer.local. admin.wptrafficanalyzer.local. ( 2012120316 ; serial number 1d ; slave refresh time 2h ; slave retry time 4w ; slave expiration time 1h ; maximum caching time ) ; the given below record specifies that, nameserver of wptrafficanalyzer.local ; is ns.wptrafficanalyzer.local @ IN NS ns.wptrafficanalyzer.local. ; Points the ip address 192.168.1.100 to the domain ns.wptrafficanalyzer.local 100 IN PTR ns.wptrafficanalyzer.local. ; Point the ip address 192.168.1.3 to the domain wptrafficanalyzer.local 3 IN PTR wptrafficanalyzer.local.
2.7 Restart bind server
$sudo service bind9 restart
3. Test the domain “wptrafficanalyzer.local” from Ubuntu 11.04
3.1 Add IP address of name server to /etc/resolv.conf
By default, in Ubuntu, the contents in /etc/resolv.conf file is written by NetworkManager, if it is installed. So we are writing name server’s ip address to the file /etc/resolv.conf via the NetworkManager.
Open the NetworkManager’s application and edit the connection to add the name server’s ip address as shown in the Figure 1 given below :
Note : Here IP address 192.168.1.1 represents the ip of router which connects to Internet
3.2. Editing the file /etc/nsswitch.conf to change the order of lookup
Let the first argument to hosts be dns. So on editing, the corresponding line in the /etc/nsswitch.conf will look like as given below :
hosts: dns files mdns4_minimal [NOTFOUND=return] mdns4
3.3 Restarting Network Manager Service
$sudo service network-manager restart
3.4 Testing the domain wptrafficanalyzer.local by ping
3.5 Testing the domain wptrafficanalyzer.local by nslookup
3.6 Testing the domain wptrafficanalyzer.local by dig
4. Test the domain “wptrafficanalyzer.local” from Windows 7
4.1 Adding Name Server’s IP address to Network Connection
Open Properties window of the network connection and add name server as shown in the figure 5 below :
4.2 Testing the domain wptrafficanalyzer.local by ping
4.3 Testing the domain wptrafficanalyzer.local by nslookup

I am George Mathew, working as software architect and Android app developer at wptrafficanalyzer.in
You can hire me on hourly basis or on project basis for Android applications development.
For hiring me, please mail your requirements to info@wptrafficanalyzer.in.
My other blogs
store4js.blogspot.com