Difference between revisions of "DNS server unique zone"

(Primary master)
Line 4: Line 4:
  
  
Here, I will focus on the '''installation of a DNS primary server''' (= DNS for domain smartcards.local) using ''BIND9''.
+
Here, I will present the installation of:
 +
* '''DNS primary server''' (= DNS for domain smartcards.local) using ''BIND9''
 +
* Local domain (.local)
 +
 
 +
 
 +
 
 +
You can re-use all this content for a web-site or public domain. Just replace ''smartcards.local'' by ''mywebsite.com''.
 +
 
  
  
Line 54: Line 61:
  
  
Adjust the file content
+
Uncomment and adjust the file content
  
 
<syntaxhighlight lang="bash">
 
<syntaxhighlight lang="bash">
 +
[...]
 
forwarders {
 
forwarders {
 
     # Local gateway or router
 
     # Local gateway or router
     192.168.1.1;  
+
     172.16.50.1;  
  
 
     # Your ISP DNS IP’s  
 
     # Your ISP DNS IP’s  
Line 69: Line 77:
 
     8.8.4.4
 
     8.8.4.4
 
};
 
};
 +
[...]
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 75: Line 84:
 
==Declare the new domain==
 
==Declare the new domain==
  
 +
Edit configuration file:
 +
 +
<syntaxhighlight lang="bash">
 +
vim /etc/bind/named.conf.local
 +
</syntaxhighlight>
 +
 +
 +
Uncomment and adjust the file content
 +
 +
<syntaxhighlight lang="bash">
 +
zone "smartcards.local" {
 +
type master;
 +
        file "/etc/bind/smartcards.local";
 +
};
 +
</syntaxhighlight>
  
  
  
 
==Domain configuration file==
 
==Domain configuration file==
 +
 +
 +
Create the domain configuration file from a local template:
 +
 +
<syntaxhighlight lang="bash">
 +
cp /etc/bind/db.local /etc/bind/smartcards.local
 +
</syntaxhighlight>
 +
 +
 +
Edit configuration file:
 +
 +
<syntaxhighlight lang="bash">
 +
vim /etc/bind/smartcards.local
 +
</syntaxhighlight>
 +
 +
 +
Adjust the file content
 +
 +
<syntaxhighlight lang="bash">
 +
;
 +
; BIND data file for smartcards.local (you can use mywebsite.com)
 +
;
 +
$TTL    604800
 +
@      IN      SOA    smartcards.local. root.smartcards.local. (
 +
                  201406031132        ; Serial
 +
                                        ; As the serial be changed everytime you edit this file
 +
                                        ; it's recommended to use the pattern "yyyyMMddHHmm"
 +
                        604800        ; Refresh
 +
                          86400        ; Retry
 +
                        2419200        ; Expire
 +
                        604800 )      ; Negative Cache TTL
 +
;
 +
; Primary DNS server declaration
 +
@      IN      NS      smartcard-gw.smartcards.local
 +
@      IN      A      172.16.50.2
 +
;
 +
; -- alternative -- To declare a server a specific domain only
 +
;
 +
;website.com      IN      NS      smartcard-gw.website.com
 +
;website.com      IN      A      172.16.50.2
 +
                  IN      A      192.168.1.10
 +
 +
; Make
 +
@      IN      A      192.168.1.10
 +
@      IN      AAAA    ::1
 +
ns      IN      A      192.168.1.10
 +
</syntaxhighlight>
  
  
  
 
==Reverse zone file==
 
==Reverse zone file==
 +
 +
 +
Edit configuration file:
 +
 +
<syntaxhighlight lang="bash">
 +
vim /etc/bind/named.conf.local
 +
</syntaxhighlight>
 +
 +
 +
Uncomment and adjust the file content
 +
 +
<syntaxhighlight lang="bash">
 +
</syntaxhighlight>

Revision as of 10:40, 3 June 2014

The DNS [Domain Name System] is a key component of a network infrastructure. It allows you to use NAMES instead of IP addresses and technical garbage.

You can learn how it works through a simple Google request.


Here, I will present the installation of:

  • DNS primary server (= DNS for domain smartcards.local) using BIND9
  • Local domain (.local)


You can re-use all this content for a web-site or public domain. Just replace smartcards.local by mywebsite.com.



Setup

apt-get install bind9 dnsutils bind9-doc


Primary master

A DNS primary master is the main DNS for your local domain (ex: smartcards.local).


These are the steps to do:

  • Set the external DNS to use by your server
    • File: /etc/bind/named.conf.options
  • Declare the new domain to manage
    • File: /etc/bind/named.conf.local
  • Create a dedicated configuration file for the new domain
    • New file: /etc/bind/smartcards.local
  • Adjust the reverse zone
    • Rename and adjust file: /etc/bind/db.192


Set the external DNS

This is the list of DNS your server will use to populate its own cache.


The external DNS can either be your ISP's DNS or Google's servers.

!! Mind the order !! First DNS have a higher priority.


Edit configuration file:

vim /etc/bind/named.conf.options


Uncomment and adjust the file content

[...]
forwarders {
     # Local gateway or router
     172.16.50.1; 

     # Your ISP DNS IP’s 
     182.176.39.23;
     182.176.18.13;

     # Google's DNS
     8.8.8.8
     8.8.4.4
};
[...]


Declare the new domain

Edit configuration file:

vim /etc/bind/named.conf.local


Uncomment and adjust the file content

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


Domain configuration file

Create the domain configuration file from a local template:

cp /etc/bind/db.local /etc/bind/smartcards.local


Edit configuration file:

vim /etc/bind/smartcards.local


Adjust the file content

;
; BIND data file for smartcards.local (you can use mywebsite.com)
;
$TTL    604800
@       IN      SOA     smartcards.local. root.smartcards.local. (
                   201406031132         ; Serial
                                        ; As the serial be changed everytime you edit this file
                                        ; it's recommended to use the pattern "yyyyMMddHHmm"
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
; 
; Primary DNS server declaration
@       IN      NS      smartcard-gw.smartcards.local
@       IN      A       172.16.50.2
;
; -- alternative -- To declare a server a specific domain only
;
;website.com      IN      NS      smartcard-gw.website.com
;website.com      IN      A       172.16.50.2
                  IN      A       192.168.1.10

; Make 
@       IN      A       192.168.1.10
@       IN      AAAA    ::1
ns      IN      A       192.168.1.10


Reverse zone file

Edit configuration file:

vim /etc/bind/named.conf.local


Uncomment and adjust the file content