DNS Server (Bind9 & dnsmasq) di Linux

Dokumen ini menjelaskan konsep, instalasi, konfigurasi, serta best practice untuk mengelola DNS server di Linux menggunakan Bind9 dan dnsmasq, termasuk penguatan keamanan, manajemen dari sisi server hingga client, serta rekomendasi penggunaan GUI untuk mempermudah administrasi DNS.


1. DNS

  • DNS (Domain Name System): sistem yang menerjemahkan nama domain (contoh: example.com) menjadi alamat IP (contoh: 93.184.216.34).
  • Bind9: DNS server skala besar, cocok untuk enterprise & production (authoritative & recursive).
  • dnsmasq: DNS server ringan, cocok untuk local caching, DHCP, small network.

2. Instalasi

a) Bind9 (Debian/Ubuntu)

sudo apt update
sudo apt install bind9 bind9-utils bind9-dnsutils -y

b) dnsmasq (Debian/Ubuntu)

sudo apt update
sudo apt install dnsmasq -y

3. Konfigurasi Bind9

a) Konfigurasi dasar (forwarder)

Edit file /etc/bind/named.conf.options:

options {
    directory "/var/cache/bind";

    recursion yes;
    allow-query { any; };

    forwarders {
        1.1.1.1;
        8.8.8.8;
    };

    dnssec-validation auto;
    auth-nxdomain no;
    listen-on { any; };
};

b) Zone File (Authoritative)

Buat file /etc/bind/named.conf.local:

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

Contoh zone file /etc/bind/zones/db.example.com:

$TTL    604800
@       IN      SOA     ns1.example.com. admin.example.com. (
                        2         ; Serial
                        604800    ; Refresh
                        86400     ; Retry
                        2419200   ; Expire
                        604800 )  ; Negative Cache TTL
;
@       IN      NS      ns1.example.com.
@       IN      A       192.168.1.10
ns1     IN      A       192.168.1.10
www     IN      A       192.168.1.20

Reload konfigurasi:

sudo systemctl restart bind9
sudo systemctl enable bind9

4. Konfigurasi dnsmasq

Edit /etc/dnsmasq.conf:

domain-needed
bogus-priv
no-resolv
server=1.1.1.1
server=8.8.8.8
listen-address=127.0.0.1,192.168.1.1
cache-size=1000

# DHCP optional
dhcp-range=192.168.1.50,192.168.1.150,12h

Restart service:

sudo systemctl restart dnsmasq
sudo systemctl enable dnsmasq

5. Best Practices (Server Side)

✅ Jalankan DNS di VM/container terisolasi.\ ✅ Aktifkan DNSSEC untuk validasi query.\ ✅ Batasi query recursive hanya untuk internal (Bind9 allow-query).\ ✅ Gunakan firewall (iptables/ufw/nftables) untuk filter port 53/tcp dan 53/udp.\ ✅ Rutin update paket untuk patch keamanan.\ ✅ Monitoring dengan dnstop, netstat, systemd journal.\ ✅ Backup zone file dengan versioning (Git/Ansible).


6. Best Practices (Client Side)

✅ Gunakan /etc/resolv.conf dengan DNS internal → external (failover).\ ✅ Implementasikan DNS over TLS (DoT) atau DNS over HTTPS (DoH) untuk keamanan tambahan.\ ✅ Cache lokal menggunakan dnsmasq.\ ✅ Untuk laptop/mobile, gunakan VPN dengan internal DNS.

Contoh /etc/resolv.conf:

nameserver 192.168.1.10   # Internal DNS (Bind9)
nameserver 1.1.1.1        # Cloudflare fallback
nameserver 8.8.8.8        # Google DNS fallback

7. DNS Management GUI

Mengelola DNS dengan CLI cukup kompleks, maka disarankan memakai GUI/Panel:\

  • Webmin → GUI server management (mendukung Bind9).\
  • phpLDAPadmin / FreeIPA → untuk enterprise DNS + LDAP integration.\
  • PowerDNS + PowerAdmin → alternatif modern dengan database backend.\
  • Cockpit → GUI modern untuk Linux server, bisa ditambahkan modul DNS.

8. Kesimpulan

  • Gunakan Bind9 untuk kebutuhan enterprise/production authoritative & recursive DNS.\
  • Gunakan dnsmasq untuk caching & lightweight DNS/DHCP.\
  • Terapkan best practice keamanan di sisi server & client.\
  • Gunakan GUI management untuk mempermudah operasional sehari-hari.