| Dieser Inhalt in deutsch |

Debian - DNS Server - Bind

Goal

In your own network, a DNS Server has to be installed an used.

I used:
Debian Lenny with the default installation
+ mc (to edit files)

Installation

# apt-get install bind9

Files to be processed in this example:
/etc/bind/domain.de
/etc/bind/192.168.1.in-addr.arpa
/etc/bind/named.conf.local.


/etc/bind/named.conf - don't touch this file, if you only want to add zones.

DNS-Zones

Name of the zone file in this example: domain.de.
Accordingly, the file is in /etc/bind then domain.de. File creation:

# touch /etc/bind/domain.de

Suppose the network address would be 192.168.1, then the other zone file would be named: 192.168.1.in-addr.arpa. Create the file:

# touch /etc/bind/192.168.1.in-addr.arpa

An NS record for the name server is specified in this example with dnsserver.domain.de
MX records for mailservers are mailserver.domain.de
SOA records related to the start of authority.

File /etc/bind/domain.de (excerpt)

(Distances/tabs here somewhat reduced)

$TTL 2d
@ IN SOA dnsserver.domain.de. root.dnsserver.domain.de. (
2006090501 ; serial
3h ; refresh
1h ; retry
1w ; expiry
1d ) ; minimum

domain.de. IN NS dnsserver.domain.de.
domain.de. IN MX 1 mailserver.domain.de.
computer001 IN A 192.168.1.1
computer002 IN A 192.168.1.2
computer003 IN A 192.168.1.3
computer004 IN A 192.168.1.4
computer005 IN A 192.168.1.5
mailserver IN A 192.168.1.6

File /etc/bind/192.168.1.in-addr.arpa (excerpt)

Here are listed the individual computers.

$TTL 604800
@ IN SOA dnsserver.domain.de. root.dnsserver.domain.de. (
2006090501 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL

192.168.1.in-addr.arpa. IN MX 1 mailserver.domain.de.
192.168.1.in-addr.arpa. IN NS dnsserver.domain.de.
1 IN PTR computer001.domain.de.
2 IN PTR computer002.domain.de.
3 IN PTR computer003.domain.de.
4 IN PTR computer004.domain.de.
5 IN PTR computer005.domain.de.
6 IN PTR mailserver.domain.de.

It is important to change the serial number at the left side bevore 'Serial'. Increase the serial number is You changed anythin in this file. Here I have used the scheme year-month-day-number (two digits). Year: 2006, Month: 09, Day: 05. If appropriate, a two-digit number for the version follows in a day here now: 01. If entries in the file were changed, the serial number also has to be changed. If the serial number is maintained, the service can't notice the changes in the config file. In other words: with the serial number the system recognizes that something new has happen.

Make sure that the point is set at the end of the numbered lines or behind entries with domain names. Computer with a special function get an entry that identifies their function. Mail server are listet with an MX record. In addition, the mail server receives a 'normal' entry, as well as other computers. For the mail server must be given a priority number. The lower the number, the higher the priority. So You can add several mail server with different priorities. If one mail server can not be contacted to accept an email, another server will be contacted.

File /etc/bind/named.conf
// 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";

// prime the server with knowledge of the root servers
zone "." {
type hint;
file "/etc/bind/db.root";
};

// be authoritative for the localhost forward and
// reverse zones, and forbroadcast zones as per RFC 1912

zone "localhost" {
type master;
file "/etc/bind/db.local";
};

zone "127.in-addr.arpa" {
type master;
file "/etc/bind/db.127";
};

zone "0.in-addr.arpa" {
type master;
file "/etc/bind/db.0";
};

zone "255.in-addr.arpa" {
type master;
file "/etc/bind/db.255";
};

// zone "com" { type delegation-only; };
// zone "net" { type delegation-only; };

// From the release notes:
// Because many of our users are uncomfortable
// receiving undelegated answers from root or top
// level domains, other than a few for whom that behaviour
// has been trusted and expected for quite some length of
// time, we have now introduced the "root-delegations-only"
// feature which applies delegation-only logic to all top
// level domains, and to the root domain. An exception list
// should be specified, including "MUSEUM" and "DE", and
// any other top level domains from whom undelegated
// responses are expected and trusted.
// root-delegation-only exclude { "DE"; "MUSEUM"; };

// Link to anothe file to look for.
include "/etc/bind/named.conf.local";

File /etc/bind/named.conf.local

Here You see the path to the zone files used above.

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not
// used in your organization
// include "/etc/bind/zones.rfc1918";


zone "domain.de" in {
type master;
file "/etc/bind/domain.de";
allow-update { none;};
};

zone "192.168.1.in-addr.arpa" in {
type master;
file "/etc/bind/192.168.1.in-addr.arpa";
allow-update { none;};
};

File /etc/bind/named.conf.options

Forwarders are DNS servers, which can be asked by a DNS server, if he himself can not resolve the name to an ip address. Adapt the entry 123.123.123.123 to your needs.

options {
directory "/var/cache/bind";

// If there is a firewall between you and
// nameservers you want to talk to, you might need
// to uncomment the query-sourcedirective below.
// Previous versions of BIND always asked questions using
// port 53, but BIND 8.1 and later use an unprivileged
// port by default.

// query-source address * port 53;

// If your ISP provided one or more IP addresses for
// stable nameservers, you probably want to use them
// as forwarders. Uncomment the following block,
// and insert the addresses replacing the all-0's
// placeholder.

// forwarders {
// 0.0.0.0;
// };
forwarders {
123.123.123.123;
};

auth-nxdomain no; # conform to RFC1035

};

Let changes take effect

The service once must be restarted for the changes to take effect.

# /etc/init.d/bind9 restart.