Difference between revisions of "Raspbian: Konfigurasi DNS Server"

From OnnoWiki
Jump to navigation Jump to search
 
(12 intermediate revisions by the same user not shown)
Line 21: Line 21:
 
  sudo vi /etc/bind/named.conf.local
 
  sudo vi /etc/bind/named.conf.local
  
Di file ini kita bisa tambahkan forward dan revese zone (asumsi subnet 10.128.0.0/16) dari sebuah domain, contoh
+
Di file ini kita bisa tambahkan forward dan revese zone (asumsi subnet 192.168.1.0/24) dari sebuah domain, contoh
  
  zone "nyc3.example.com" {
+
  zone "darmajaya.ac.id" {
 
     type master;
 
     type master;
     file "/etc/bind/zones/db.nyc3.example.com"; # zone file path
+
     file "/etc/bind/zones/db.itts.ac.id";       # zone file path
     allow-transfer { 10.128.20.12; };         # ns2 private IP address - secondary
+
     allow-transfer { 10.128.20.12; };           # ns2 private IP address - secondary
 
  };
 
  };
  
  zone "128.10.in-addr.arpa" {
+
  zone "4.168.192.in-addr.arpa" {
 
     type master;
 
     type master;
     file "/etc/bind/zones/db.10.128"; # 10.128.0.0/16 subnet
+
     file "/etc/bind/zones/db.192.168";     # 192.168.0.0/16 subnet
     allow-transfer { 10.128.20.12; }; # ns2 private IP address - secondary
+
     allow-transfer { 10.128.20.12; };     # ns2 private IP address - secondary
 
  };
 
  };
  
Line 41: Line 41:
 
  sudo mkdir /etc/bind/zones
 
  sudo mkdir /etc/bind/zones
 
  cd /etc/bind/zones
 
  cd /etc/bind/zones
  sudo cp ../db.local ./db.nyc3.example.com
+
  sudo cp ../db.local ./db.itts.ac.id
  sudo vi /etc/bind/zones/db.nyc3.example.com
+
  sudo vi /etc/bind/zones/db.itts.ac.id
  
 
Isi awalnya kira-kira
 
Isi awalnya kira-kira
Line 61: Line 61:
  
 
  $TTL    604800
 
  $TTL    604800
  @      IN      SOA    ns1.nyc3.example.com. admin.nyc3.example.com. (
+
  @      IN      SOA    ns1.itts.ac.id. admin.itts.ac.id. (
                   3       ; Serial
+
                   3     ; Serial
 
               604800    ; Refresh
 
               604800    ; Refresh
 
               86400    ; Retry
 
               86400    ; Retry
Line 69: Line 69:
 
  ;
 
  ;
 
  ; name servers - NS records
 
  ; name servers - NS records
       IN      NS      ns1.nyc3.example.com.
+
       IN      NS      ns1.itts.ac.id.
       IN      NS      ns2.nyc3.example.com.  
+
       IN      NS      ns2.itts.ac.id.  
 
   
 
   
 
  ; name servers - A records
 
  ; name servers - A records
  ns1.nyc3.example.com.          IN      A      10.128.10.11
+
  ns1.itts.ac.id.          IN      A      192.168.0.1
  ns2.nyc3.example.com.          IN      A      10.128.20.12
+
  ns2.itts.ac.id.          IN      A      192.168.4.10
 
   
 
   
  ; 10.128.0.0/16 - A records
+
  ; 192.168.0.0/16 - A records
  host1.nyc3.example.com.        IN      A      10.128.100.101
+
  www.itts.ac.id.        IN      A      192.168.0.1
  host2.nyc3.example.com.        IN      A      10.128.200.102
+
  www.itts.ac.id.        IN      A      192.168.4.10
 +
itts.ac.id.           IN      A      192.168.0.1
 +
itts.ac.id.            IN      A      192.168.4.10
  
 
==Buat Reverse Zone File==
 
==Buat Reverse Zone File==
Line 84: Line 86:
 
Buat dan edit
 
Buat dan edit
  
    cd /etc/bind/zones
+
cd /etc/bind/zones
    sudo cp ../db.127 ./db.10.128
+
sudo cp ../db.127 ./db.192.168
    sudo vi /etc/bind/zones/db.10.128
+
sudo vi /etc/bind/zones/db.192.168
  
 
Awalnya akan berisi kira-kira
 
Awalnya akan berisi kira-kira
Line 104: Line 106:
  
 
  $TTL    604800
 
  $TTL    604800
  @      IN      SOA    nyc3.example.com. admin.nyc3.example.com. (
+
  @      IN      SOA    itts.ac.id. admin.itts.ac.id. (
 
                               3        ; Serial
 
                               3        ; Serial
 
                           604800        ; Refresh
 
                           604800        ; Refresh
Line 111: Line 113:
 
                           604800 )      ; Negative Cache TTL
 
                           604800 )      ; Negative Cache TTL
 
  ; name servers
 
  ; name servers
       IN      NS      ns1.nyc3.example.com.
+
       IN      NS      ns1.itts.ac.id.
       IN      NS      ns2.nyc3.example.com.
+
       IN      NS      ns2.itts.ac.id.
 
   
 
   
 
  ; PTR Records
 
  ; PTR Records
  11.10  IN      PTR    ns1.nyc3.example.com.    ; 10.128.10.11
+
  1.IN      PTR    ns1.itts.ac.id.    ; 192.168.0.1
  12.20  IN      PTR    ns2.nyc3.example.com.    ; 10.128.20.12
+
  10.4 IN      PTR    ns2.itts.ac.id.    ; 192.168.4.10
  101.100 IN      PTR    host1.nyc3.example.com. ; 10.128.100.101
+
1.0  IN      PTR    www.itts.ac.id.    ; 192.168.0.1
  102.200 IN      PTR    host2.nyc3.example.com.  ; 10.128.200.102
+
  10.4 IN      PTR    www.itts.ac.id.   ; 192.168.4.10
 +
  1.IN      PTR    itts.ac.id.       ; 192.168.0.1
 +
  10.4 IN      PTR    itts.ac.id.        ; 192.168.4.10
  
 
==Cek Syntax Konfigurasi BIND==
 
==Cek Syntax Konfigurasi BIND==
Line 128: Line 132:
 
Cek zone tertentu
 
Cek zone tertentu
  
  sudo named-checkzone nyc3.example.com db.nyc3.example.com
+
  sudo named-checkzone itts.ac.id db.itts.ac.id
  sudo named-checkzone 128.10.in-addr.arpa /etc/bind/zones/db.10.128
+
  sudo named-checkzone 168.192.in-addr.arpa /etc/bind/zones/db.192.168
  
Pastikan tidak ada error
+
Pastikan tidak ada error, keluar
 +
 
 +
OK
  
 
==Restart BIND==
 
==Restart BIND==
Line 137: Line 143:
 
Restart
 
Restart
  
    sudo service bind9 restart
+
sudo service bind9 restart
 
+
sudo systemctl start bind9
  
 
==Pranala Menarik==
 
==Pranala Menarik==

Latest revision as of 05:18, 21 October 2021

Install BIND

install BIND

sudo su
apt update
apt install bind9 bind9utils bind9-doc

Setup hanya untuk IPv4 (-4) jika dibutuhkan

vi /etc/default/bind9

Tambahkan (-4)

OPTIONS="-4 -u bind"

Konfigurasi Local File

Edit

sudo vi /etc/bind/named.conf.local

Di file ini kita bisa tambahkan forward dan revese zone (asumsi subnet 192.168.1.0/24) dari sebuah domain, contoh

zone "darmajaya.ac.id" {
    type master;
    file "/etc/bind/zones/db.itts.ac.id";        # zone file path
    allow-transfer { 10.128.20.12; };            # ns2 private IP address - secondary
};
zone "4.168.192.in-addr.arpa" {
    type master;
    file "/etc/bind/zones/db.192.168";     # 192.168.0.0/16 subnet
    allow-transfer { 10.128.20.12; };      # ns2 private IP address - secondary
};

Buat Forward Zone File

Buat dan edit

sudo mkdir /etc/bind/zones
cd /etc/bind/zones
sudo cp ../db.local ./db.itts.ac.id
sudo vi /etc/bind/zones/db.itts.ac.id

Isi awalnya kira-kira

$TTL    604800
@       IN      SOA     localhost. root.localhost. (
                              2         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      localhost.      ; delete this line
@       IN      A       127.0.0.1       ; delete this line
@       IN      AAAA    ::1             ; delete this line

Dapat kita ubah menjadi, misalnya,

$TTL    604800
@       IN      SOA     ns1.itts.ac.id. admin.itts.ac.id. (
                  3     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
;
; name servers - NS records
     IN      NS      ns1.itts.ac.id.
     IN      NS      ns2.itts.ac.id. 

; name servers - A records
ns1.itts.ac.id.          IN      A       192.168.0.1
ns2.itts.ac.id.          IN      A       192.168.4.10

; 192.168.0.0/16 - A records
www.itts.ac.id.        IN      A      192.168.0.1
www.itts.ac.id.        IN      A      192.168.4.10
itts.ac.id.            IN      A      192.168.0.1
itts.ac.id.            IN      A      192.168.4.10

Buat Reverse Zone File

Buat dan edit

cd /etc/bind/zones
sudo cp ../db.127 ./db.192.168
sudo vi /etc/bind/zones/db.192.168

Awalnya akan berisi kira-kira

$TTL    604800
@       IN      SOA     localhost. root.localhost. (
                              1         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      localhost.      ; delete this line
1.0.0   IN      PTR     localhost.      ; delete this line

Ubah menjadi kira-kira,

$TTL    604800
@       IN      SOA     itts.ac.id. admin.itts.ac.id. (
                              3         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
; name servers
      IN      NS      ns1.itts.ac.id.
      IN      NS      ns2.itts.ac.id.

; PTR Records
1.0  IN      PTR     ns1.itts.ac.id.    ; 192.168.0.1
10.4 IN      PTR     ns2.itts.ac.id.    ; 192.168.4.10
1.0  IN      PTR     www.itts.ac.id.    ; 192.168.0.1
10.4 IN      PTR     www.itts.ac.id.    ; 192.168.4.10
1.0  IN      PTR     itts.ac.id.        ; 192.168.0.1
10.4 IN      PTR     itts.ac.id.        ; 192.168.4.10

Cek Syntax Konfigurasi BIND

Jalankan perintah

sudo named-checkconf

Cek zone tertentu

sudo named-checkzone itts.ac.id db.itts.ac.id
sudo named-checkzone 168.192.in-addr.arpa /etc/bind/zones/db.192.168

Pastikan tidak ada error, keluar

OK

Restart BIND

Restart

sudo service bind9 restart
sudo systemctl start bind9

Pranala Menarik