How to configure a DNS server on Debian.

At the beginning we need to install bind:


root:# apt-get install bind

Now we will deal with configuration files of master DNS server. In the /etc/named.conf add the enrty:

include "/etc/bind/named.conf.zones";

then create the named.conf.zones:

root:# touch /etc/bind/named.conf.zones

In the named.conf.zones create a zone for our domain, in this case the 4network.eu domain and rev.

zone "4network.org" {
type master;
file "/etc/bind/4network.org.db";
notify yes; # notify the other servers, the entries in our domain have been changed
also-notify { 192.168.1.91; 192.168.1.50; }; # notify only this servers
allow-transfer { 192.168.1.91; 192.168.1.50; }; # transfer domain only to this servers
};

zone "1.168.192.in-addr.arpa" {
type master;
file "/etc/bind/192.rev";
notify yes; # notify the other servers, the entries in our domain have been changed
also-notify { 192.168.1.91; 192.168.1.50; }; # notify only this servers
allow-transfer { 192.168.1.91; 192.168.1.50; }; # transfer domain only to this servers
};

then create the 4network.org.db file and the 192.rev file.

root:# touch /etc/bind/4network.org.db
root:# touch /etc/bind/192.rev

then create entires for our domain in the 4network.org.db file.

; BIND data file for 4network.org
;
$ORIGIN 4network.eu.
@ IN SOA 4network.eu. root.4network.org. (
2011072311 ; Serial yyyymmddnn
1200 ; refresh (20 minutes)
900 ; retry (15 minutes)
3600 ; expire (1 hour)
3600 ; minimum (1 hour)
3600 ) ; TTL (1 hour)
@ IN NS 4network.org.
@ IN MX 10 mail.4network.org.
@ IN A 192.168.1.4
zeus IN A 192.168.1.2
julia IN A 192.168.1.3
julix IN CNAME julia
hades IN A 192.168.1.4
# NOTE
# If you would like have a load balancing on your DNS server,
# please add the following line.
www IN A 192.168.1.97
IN A 192.168.1.98
IN A 192.168.1.99

almost the same for reverse domain (file 192.rev)

; BIND reverse data file for 192.168.1.0
;
@ IN SOA 4network.org. root.4network.org. (
2011072311 ; Serial
20m ; Refresh
15m ; Retry
1h ; Expire
3600 ) ; TTL
@ IN NS 4network.org.
2 IN PTR zeus.4network.org.
3 IN PTR julia.4network.org.
4 IN PTR hades.4network.org.

Now you just restart the bind by:

/etc/init.d/bind9 restart

Now we will deal with slave DNS server.
Follow the same procedures as for master DNS server, only changes will be made in the named.conf.zones file.

zone "4network.org" {
type slave;
file "/var/cache/bind/4network.org.db";
masters { 192.168.1.4; };
};


zone "1.168.192.in-addr.arpa" {
type slave;
file "/var/cache/bind/192.rev";
masters { 192.168.1.4; };
};

That’s all. Now we have a master and slave DNS servers.

Leave a Reply

Your email address will not be published. Required fields are marked *

*