Language:

Search

Bind9 Install on Debian or Ubuntu

  • Share this:
post-title

1. Run Following Command

apt update

apt install bind9 bind9utils bind9-doc

2. Open the file following by command line

nano /etc/bind/named.conf.options

Update as following

options {
    directory "/var/cache/bind";
    
    recursion yes;                 # enables resursive queries
    listen-on port 53 { any; };
    listen-on-v6 port 53 { ::1; };
    allow-recursion { any; };  # allows recursive queries from "trusted" clients
    listen-on { any; };   # ns1 private IP address - listen on private network only
    allow-transfer { none; };
    // If there is a firewall between you and nameservers you want
    // to talk to, you may need to fix the firewall to allow multiple
    // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

    // 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 {
      8.8.8.8;
      8.8.4.4;
    };

    //========================================================================
    // If BIND logs error messages about the root key being expired,
    // you will need to update your keys.  See https://www.isc.org/bind-keys
    //========================================================================
    dnssec-validation auto;

    auth-nxdomain no;    # conform to RFC1035
    listen-on-v6 { any; };
};

3. Open the following file by command line

nano /etc/bind/named.conf.local

and Update as follwoing

zone "example.com" {
    type master;
    file "/etc/bind/zones/db.example.com"; # zone file path
    allow-transfer { 192.168.25.31; };         # ns2 private IP address - secondary
};
zone "25.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/zones/db.192.168.25";  # 10.128.0.0/16 subnet
    allow-transfer { 192.168.25.31; };  # ns2 private IP address - secondary
};
zone "example2.com" {
    type master;
    file "/etc/bind/zones/db.example2.com"; # zone file path
    allow-transfer { 192.168.25.31;};         # ns2 private IP address - secondary
};

4. Create Directory "zones" like /etc/bind/zones

5. Create a file db.example.com in location /etc/bind/zones, Command Line touch  /etc/bind/zones/db.example.com

6. Open the created file nano /etc/bind/zones/db.example.com and Update as following

$TTL    604800
example.com.       IN      SOA     ns1.nameserver.com. adminex.gmail.com. (
                  3       ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
; name servers - NS records
example.com.  86400   IN      NS      ns1.nameserver.com.
example.com.  86400   IN      NS      ns2.nameserver.com.

; name servers - A records
example.com.         IN      A         192.168.25.31
www                       IN      A          192.168.25.31
; 10.128.0.0/16 - A records
example.com.                         IN     MX   0  mail.example.com.
mail.example.com.                IN      A          192.168.25.32

7. Create a file db.192.168.25 in location /etc/bind/zones, Command Line touch  /etc/bind/zones/db.192.168.25

8. Open the created file nano /etc/bind/zones/db.192.168.25 and Update as following

$TTL    604800
@       IN      SOA     ns1.nameserver.com.  adminex.gmail.com. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
; name servers
@      IN      NS      ns1.nameserver.com.
@      IN      NS      ns2.nameserver.com.

; PTR Records
139   IN      PTR     server.example.com.    ; 10.128.10.11
138   IN      PTR     mail.example.com.    ; 10.128.20.12
141   IN      PTR     opac.example.com.  ; 10.128.100.101

 

9.  Run Command: named-checkconf

10. Run Command: named-checkzone example.com /etc/bind/zones/db.example.com

11. Run Command: named-checkzone 25.168.192.in-addr.arpa /etc/bind/zones/db.192.168.25

12. Restart Bind9: systemctl restart bind9

 

 

Yusuf Khalil

Yusuf Khalil