Install DNS Server

install keperluan :

sudo su
apt update
apt install bind9 bind9utils bind9-doc

edit named.conf.local

vim /etc/bind/named.conf.local

diisi :

zone "example.com" {
    type master;
    file "/etc/bind/db.example.com";   # zone file path
};

buat db.example.com, agar mudah copas saja db.local sebagai template

cp /etc/bind/db.local /etc/bind/db.example.com

diisi :

;
; BIND data file for local loopback interface
;
$TTL	604800
@	IN	SOA	ns.example.com. root.example.com. (
		   20211201		; Serial
			 604800		; Refresh
			  86400		; Retry
			2419200		; Expire
			 604800 )	; Negative Cache TTL
;
; name servers
      IN      NS      ns1.example.com.

; name servers - NS records
ns1.example.com. 	IN 	A 	192.168.150.11

; PTR Records
www.example.com. 	IN      A	192.168.150.11
example.com. 		IN 	A 	192.168.150.11
service bind9 restart

checking :

sudo named-checkzone example.com db.example.com

lihat hasil :

dig NS example.com @localhost

output


; <<>> DiG 9.16.1-Ubuntu <<>> NS example.com @localhost
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52920
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 2

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
; COOKIE: 2dd46f623ed54bd00100000061a6b941354873c5842c14c5 (good)
;; QUESTION SECTION:
;example.com.			IN	NS

;; ANSWER SECTION:
example.com.		604800	IN	NS	ns1.example.com.

;; ADDITIONAL SECTION:
ns1.example.com.	604800	IN	A	192.168.150.11

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1)
;; WHEN: Tue Nov 30 23:52:33 UTC 2021
;; MSG SIZE  rcvd: 102