How to set up DNS server with BIND on Ubuntu
Posted: October 1, 2009 at 6:57 pm | Tags: bind, dns, LinuxThis tutorial is about setting up DNS on Ubuntu and is the result of lot of documentation, many tutorials and many attempts. Hope you’ll find it usefull.
For installing DNS service on a machine, first thing to do in installing BIND (Berkley Internet Name Daemon):
sudo apt-get install bind9
The next thing to do is to configure bind. Usualy, for this you have to edit named.conf, but in Ubuntu the configuration file for bine is named.conf.local:
sudo /etc/bind/named.conf.local
Now you have to add the zones:
zone “domain.com” {
type master;
file “/etc/bind/zones/domain.com.db”;
};#reverse DNS. (reverse notation of your network address (NOT you IP!!!) example: if NA = 192.168.1.0 then reverse DNS is: 1.168.192 )
zone “1.168.192.in-addr.arpa” {
type master;
file “/etc/bind/zones/rev.1.168.192.in-addr.arpa”;
};
The next step is to modify the forwarders to point to your ISP (the DNS server to which your own DNS will forward the requests). For this you have to edit named.conf.options:
sudo gedit /etc/bind/named.conf.options
This is what you have to add (replace with approriate IP addresses of course. We assum here that my ISP’s DNS are: 111.111.111.111 and 222.222.222.22):
forwarders {
111.111.111.111;
222.222.222.222;
};
Now we have to add the zone definition file. In the definition file will be stored all the addresses that our DNS server will know. We olso have to create a folder where to keep the file:
sudo mkdir /etc/bind/zones
sudo gedit /etc/bind/zones/domain.com.db
This is how the definition file should look like:
domain.com. IN SOA ns1.domain.com. admin.domain.com. (
2006081401
28800
3600
604800
38400
)domain.com. IN NS ns1.domain.com.
domain.com. IN MX 10 mta.domain.com.www IN A 192.168.0.2
mta IN A 192.168.0.3
ns1 IN A 192.168.0.1
The file for reverse DNS zone:
sudo gedit /etc/bind/zones/rev.0.168.192.in-addr.arpa
The number colored in red is the IP address of the machine running DNS server (in this case is 1, because the IP address of the machine running DNS server is 192.168.0.1).
@ IN SOA ns1.domain.com. admin.domain.com. (
2006081401;
28800;
604800;
604800;
86400
)IN NS ns1.domain.com.
1 IN PTR domain.com
Edit resolv.conf:
sudo gedt /etc/resolv.conf
Modify resolv.conf:
search domain.com
nameserver 192.168.0.1
Now you have to restart bind and test your DNS server.
sudo /etc/init.d/bind9 restart
dig domain.com
dig domain.com mx

(14 votes, average: 4.93 out of 5)






















