woensdag 10 juli 2013

Configuring Debian DNS server Advanced.


1. bind9 nameserver installation

Unless you prefer to install bind from a source code the installation is rather simple. On a Debian or Ubuntu Linux server you can install a bind nameserver with a following command:
apt-get install bind9 dnsutils
CentOS or Fedora alternative:
yum install bind dnsutils
Here we go good luck.

2. Creating a DNS zone file

At this stage we will need to create a file for a domain jeromic.nl  Navigate to /etc/bind/ directory execute following sequence of commands to navigate to etc/bind/zones/master/ if you dont have it create it like below
cd /etc/bind
mkdir -p zones/master
cd zones/master/
/etc/bind/zones/master directory will contain a zone file for a jeromic.nl domain. If you prefer to use another directory to hold this file you are free to do so. The following zone file db.jeromic.nlwill hold a DNS record to assist a nameserver resolve a fully qualified domain name to an IP address. Create and save db.jeromic.nl with a following content: you can create a site by typing cd /etc/bind/zones/master/ nano. Then put it the command below with you own domain. and save it as db.domain.extension.
;
; BIND data file for jeromic.nl

;
$TTL    3h
@       IN      SOA     ns1.jeromic.nl. admin.jeromic.nl. (
                          1        ; Serial
                          3h       ; Refresh after 3 hours
                          1h       ; Retry after 1 hour
                          1w       ; Expire after 1 week
                          1h )     ; Negative caching TTL of 1 day
;
@       IN      NS      ns1.jeromic.nl.
@       IN      NS      ns2.jeromic.nl.



jeromic.nl.    IN      A       192.168.0.10
ns1                     IN      A       192.168.0.10
blog.jeromic.nl         IN      CNAME   superitconsultant.blogspot.nl.

Here is just a quick overview of the records:
  • SOA Record: nameserver authoritative for a zone jeromic.nl is ns1.jeromic.nl and admin.jeromic.nl is an email address of a person responsible for this DNS zone.
  • NS Records: two nameservers for a jeromic.nl zone are ns[1,2].jeromic.nl
  • MX ( Mail Exchange): jeromic.nl mail exachange record. Number 10 means a preference for discarting a records A : A simply means address inanother words in jeromic.nl zone a ns1 would ahve a A ( address ) 192.168.0.10.
  • CNAME Record ( Canonical Name record ): restart the query using the canonical name instead of the original name

3. address-to-name mappings

At this stage the bind DNS server can resolve an IP address mapped to a jeromic.nl host. What we should do now is the teach our nameserver the other way around, which is, to resolve a host from an IP address. For this we are going to need yet another file and that is db.192.168.0 with a following content:
PTR
;
; BIND reverse data file for 0.168.192.in-addr.arpa
;
$TTL    604800
0.168.192.in-addr.arpa.      IN      SOA     ns1.jeromic.nl. admin.jeromic.nl. (
                          1         ; Serial
                          3h       ; Refresh after 3 hours
                          1h       ; Retry after 1 hour
                          1w       ; Expire after 1 week
                          1h )     ; Negative caching TTL of 1 day
;
0.168.192.in-addr.arpa.       IN      NS      ns1.jeromic.nl.
0.168.192.in-addr.arpa.       IN      NS      ns2.jeromic.nl.

10.0.168.192.in-addr.arpa.   IN      PTR     jeromic.nl.
  • PTR: a NDS record used for a mapping of an IP address to a host name.

4. Updating a BIND Configuration File

At this point we should have two files ready:
  • /etc/bind/zones/master/db.jeromic.nl
  • /etc/bind/zones/master/db.192.168.0
All we need to do now is to insert both zone file names into a bind's configuration file named.conf.local. To do that add following lines into this file:
zone "jeromic.nl" {
       type master;
       file "/etc/bind/zones/master/db.jeromic.nl";
};

zone "0.168.192.in-addr.arpa" {
       type master;
       file "/etc/bind/zones/master/db.192.168.0";
};
Last thing before we go ahead to check a configuration is to add and IP address af a stable DNS server to a named.conf.options file. This IP address is used in case that a local DNS server do not know the answer the a name resolution query. In IP address of a DNS server in many cases is provided by your Internet provider. Alternatively if you are google fan use 8.8.8.8.
Replace a following blog of text withing a named.conf.options file:
       // forwarders {
       //      0.0.0.0;
       // };
with new stable DNS server IP address
        forwarders {
              8.8.4.4;
         };
Ok now you are finished. You can check DNS by doing a NSlookup
root@debian:~# nslookup
> 192.168.0.10
Server:         192.168.0.10
Address:        192.168.0.10#53

** server can't find 10.0.168.192.in-addr.arpa.: NXDOMAIN
> blog.jeromic.nl
Server:         192.168.0.10
Address:        192.168.0.10#53

Name:   blog.jeromic.nl
Address: private ip
Thank and please leave a message or comment :)

Geen opmerkingen:

Een reactie posten