Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to setup a DNS Server on ubuntu 12.04

This tutorial will help you in setting up a dns gateway in your ubuntu machine (I'm using 12.04 version, not sure if this would work on others).

First we need to install bind9, which is a dns server:

sudo apt-get install bind9

Open /etc/bind/named.conf.local and replace with:

acl internal {
 10.0.0.0/8;
 localhost;
};

view "internal-view" {
 match-clients { internal; };
 include "/etc/bind/named.conf.default-zones";

 zone "ipiel.net" {
  type master;
  file "/etc/bind/zones/db.ipiel.net";
 };

};

view "external-view" {
 match-clients { any; };
 include "/etc/bind/named.conf.default-zones";
};
Then create a file: /etc/bind/zones/db.ipiel.net, with the following contents:
$TTL 300
@ IN SOA ipiel.net. hostmaster.ipiel.net. (
   2012091800 ; Serial
   10800   ; Refresh
   3600  ; Retry
   604800  ; Expire
   300 )  ; Negative Cache TTL

$ORIGIN @
   NS      ns1.ipiel.net.
   A 10.1.1.69
ns1   A 10.1.1.55
                IN      MX  10  mail.ipiel.net.

www  IN A 10.1.1.69
po1  IN A 10.1.1.69
db1  IN A 10.1.1.55
gw1  IN A 10.1.1.55
gw   CNAME gw1
po   CNAME po1
db   CNAME db1

The settings means that I have 3 servers:
1.) portal - po1, po
2.) gateways - gw1, gw
3.) database - db1, db

These settings are useful when you have a client (mobile app or another web application on another machine) and you don't want to change the IP setting. Because in mobile that means rebuild and redeploy. When you have these settings all you need to do is change your dns setting to 10.1.1.55, or the machine ip where you install  and configured bind9.

Finally edit, /etc/bin/named.conf and comment this line:
include "/etc/bind/named.conf.default-zones";

Restart bind9
sudo /etc/init.d/bind9 restart

In another machine all you need to do to change your dns server is to edit /etc/resolv.conf and add
nameserver 10.1.1.55
How to setup a DNS Server on ubuntu 12.04 How to setup a DNS Server on ubuntu 12.04 Reviewed by Edward Legaspi on Thursday, September 20, 2012 Rating: 5

No comments:

Powered by Blogger.