π DNS Fundamentals & BIND9 Self-Hosting
Filosofi: DNS adalah hal pertama yang harus working sebelum service apapun jalan. Tapi juga hal paling sering dianggap remeh β sampai ada outage dan semua app βConnection refusedβ karena resolver gak bisa resolve.
DNS Resolution Flow
Browser Anda
β
βΌ
ββββββββββββββββββββ 1 ββββββββββββββββββββ
β Stub Resolver ββββββββββΆβ Recursive β
β (/etc/resolv.conf)β β Resolver (ISP/ β
β 192.168.1.1 βββββββββββ 8.8.8.8/1.1.1.1) β
ββββββββββββββββββββ 6 ββββββββββ¬ββββββββββ
β 2
βΌ
ββββββββββββββββββββ
β Root Nameserver β
β (.) β
ββββββββββ¬ββββββββββ
β 3 β "ask .id"
βΌ
ββββββββββββββββββββ
β TLD Nameserver β
β (.id) β
ββββββββββ¬ββββββββββ
β 4 β "ask ns1.domain.com"
βΌ
ββββββββββββββββββββ
β Authoritative ββββ BIND9 HERE
β Nameserver β
β (BIND9) β
ββββββββββββββββββββ
β 5 β "A record: 203.x.x.x"
β
βΌ
Answer to client
Record Types β Yang Sering Dipakai
| Record | Fungsi | Contoh |
|---|---|---|
| A | IPv4 address | domain.com. IN A 203.0.113.1 |
| AAAA | IPv6 address | domain.com. IN AAAA 2001:db8::1 |
| CNAME | Alias ke domain lain | www IN CNAME domain.com. |
| MX | Mail server priority | domain.com. IN MX 10 mail.domain.com. |
| TXT | Teks (SPF, DKIM, verification) | domain.com. IN TXT "v=spf1 mx ~all" |
| NS | Nameserver delegation | domain.com. IN NS ns1.domain.com. |
| SOA | Start of Authority β master data | Wajib di setiap zone |
| SRV | Service location | _sip._tcp IN SRV 10 5 5060 sip.domain.com |
TTL Strategy
TTL rendah (60-300s) untuk record yang sering berubah (failover, CDN). TTL tinggi (3600-86400s) untuk MX, NS, TXT.
Authoritative vs Recursive
| Aspek | Authoritative | Recursive |
|---|---|---|
| Tugas | Jawab query untuk zone yang di-manage | Cari jawaban dari rantai resolver |
| Data | Zone file lokal β source of truth | Hasil cache dari upstream |
| Contoh | BIND9 sebagai primary/secondary | Unbound, systemd-resolved, 8.8.8.8 |
| Homelab use | Host domain sendiri | Lebih baik pake upstream (Cloudflare/Google) |
Jangan Campur
BIND9 bisa jadi authoritative + recursive sekaligus. Tapi jangan. Authoritative harus bisa diakses publik. Recursive cuma boleh untuk internal. Campur = open resolver β DDoS amplification vector.
BIND9 β Basic Setup (Authoritative Only)
Install
apt install bind9 bind9utils bind9-docZone File Example β db.domain.com
$TTL 3600
@ IN SOA ns1.domain.com. admin.domain.com. (
2026071101 ; serial (YYYYMMDDNN)
3600 ; refresh
900 ; retry
86400 ; expire
600 ) ; minimum TTL
; Nameservers
@ IN NS ns1.domain.com.
@ IN NS ns2.domain.com.
; Records
@ IN A 203.0.113.10
ns1 IN A 203.0.113.10
ns2 IN A 203.0.113.20
www IN CNAME @
mail IN A 203.0.113.10
@ IN MX 10 mail.domain.com.
@ IN TXT "v=spf1 mx -all"Named.conf β named.conf.local
zone "domain.com" {
type master;
file "/etc/bind/db.domain.com";
allow-transfer { 203.0.113.20; }; // secondary NS
also-notify { 203.0.113.20; };
};Testing
# Verifikasi config
named-checkconf
named-checkzone domain.com /etc/bind/db.domain.com
# Query test
dig @localhost domain.com A
dig @localhost domain.com MX
dig @localhost domain.com TXTHomelab Use Cases
| Skenario | Setup | Complexity |
|---|---|---|
Local dev domains (*.test) | BIND9 + dnsmasq | Mudah |
| Ad blocking | Pi-hole (DNS sinkhole) | Mudah |
| Internal service discovery | BIND9 + SRV records | Medium |
| Public nameserver | BIND9 + DDNS + monitoring | Advanced |
| Secondary (slave) | BIND9 zone transfer | Medium |
Failure Mode β Ketika DNS Gagal
| Gejala | Kemungkinan | Test |
|---|---|---|
| βping: name not resolvedβ | Resolver broken | dig @1.1.1.1 domain.com |
| Website buka, email gak bisa | MX record salah | dig domain.com MX |
| Lambat banget buka web | Resolver slow/loss | dig +stats domain.com |
| βSERVFAILβ | Authoritative NS error | dig +trace domain.com |
| Port 53 filtered | Firewall block | nmap -sU -p 53 -Pn host |
| Serial mismatch | Zone transfer gagal | Cek serial di SOA vs secondary |
π§ Berpikir β Metodologi Penyusunan Catatan
Catatan ini disusun melalui proses berpikir terstruktur sebagai berikut:
1. Thinking Type yang Digunakan
| Type | Kenapa | Bagian |
|---|---|---|
| Cognitive Thinking | Membangun fondasi pemahaman DNS dari resolusi flow β siapa yang ngomong sama siapa, urutannya gimana | DNS Resolution Flow diagram |
| Analytical Thinking | Memecah record types berdasarkan fungsi dan use case β kapan pake A vs CNAME vs MX vs SRV | Record Types table |
| Systems Thinking | Menganalisis Authoritative vs Recursive β bagaimana koneksi keduanya, kenapa bahaya kalau digabung | Authoritative vs Recursive |
| Concrete Thinking | BIND9 setup step-by-step β install, zone file, named.conf, testing | BIND9 Basic Setup |
| Futures Thinking | Failure mode analysis β apa yang terjadi ketika DNS gagal di tiap layer | Failure Mode table |
2. Background Knowledge (Pra-Penulisan)
- DNS resolution chain: stub β recursive β root β TLD β authoritative. 7 hops minimal
- SOA fields: serial (YYYYMMDDNN β wajib increment), refresh/retry/expire/TTL β hubungan satu sama lain
- Open resolver danger: pengalaman BIND9 config salah β recursive terbuka β jadi DDoS amplifier
- dig diagnostic:
+tracebuat debug rantai,+statsbuat ukur latency,+shortbuat output bersih - TTL strategy: MX dan NS sebaiknya TTL tinggi β jarang berubah, dan caching membantu stability
- Serial number convention: format YYYYMMDDNN β NN untuk multiple changes dalam sehari. Git hook bisa auto-increment
3. RAG Vault β Dokumen yang Dikonsultasi
| Dokumen | Kontribusi |
|---|---|
| Network Security | OSI layer context, port UDP 53, TCP 53 untuk zone transfer |
| Infrastructure Administrator | Server layout β namespace atau VM dedicated untuk BIND9 |
| Podman Networking & UFW | Port exposure untuk BIND9 β UFW allow 53, routing rules |
4. Sintesis β Bagaimana Bagian Bergabung
Background Knowledge (DNS protocol + BIND9 ops + dig diagnostics)
β
βΌ
RAG Vault (server architecture context)
β
βΌ
Cognitive: Resolution flow β siapa ngomong sama siapa
β
βΌ
Analytical: Record types β decompose per function β comparison table
β
βΌ
Systems: Auth vs Recursive β kenapa gabung itu bahaya β DDoS amplification
β
βΌ
Concrete: BIND9 config β install β zone file β named.conf β testing
β
βΌ
Futures: Failure modes β tiap gejala β diagnosis β fix
5. Sequential Thinking Steps
Thought 1 (Cognitive): "DNS resolution flow: stub β recursive β root β TLD β authoritative β answer."
"Butuh diagram urutan biar jelas."
Thought 2 (Analytical): "Ada 8 record types yang sering dipakai. Masing-masing punya format dan use case beda."
"A untuk IPv4, AAAA untuk IPv6, CNAME untuk alias, MX untuk mail."
Thought 3 (Systems): "Authoritative = punya data. Recursive = cari data. Kalau digabung = open resolver."
"Open resolver = DDoS amplification vector. Jangan."
Thought 4 (Concrete): "BIND9 config: install β zone file β named.conf β named-checkconf β dig test."
"Exact file content, bukan placeholder."
Thought 5 (Critical): "Serial number lupa di-increment = zone transfer gak jalan, slave serve stale data."
"Ini bug paling sering dan paling silent."
Thought 6 (Futures): "Kalau DNS down, apa yang terjadi? 'name not resolved', MX fail, SERVFAIL."
"Bikin table gejala β kemungkinan β test β fix."
π Lihat Juga
- Network Security β OSI layer, port knowledge
- Infrastructure Administrator β Server setup
- Podman Networking & UFW β Port exposure pattern