Konfigurasi Proxy pada Mikrotik
Memblokir Situs di Jaringan MikroTik
Teknik lengkap: Web Proxy (HTTP), Firewall TLS-Host (HTTPS/SNI), DNS Hijacking, Whitelist/Blacklist, Jadwal, Logging, dan Troubleshooting.
Daftar Isi
- Konsep Dasar & Arsitektur
- Pra-Syarat & Topologi
- Metode A: Web Proxy – Blokir HTTP
- Metode B: Firewall TLS-Host – Blokir HTTPS (SNI)
- Metode C: DNS Hijacking & Pemaksaan DNS
- Whitelist, Blacklist, & Pengecualian
- Penjadwalan (Jam Pelajaran / Kantor)
- Monitoring & Logging
- Troubleshooting
- Latihan/Praktik Siswa
- Lampiran: Perintah Lengkap
1) Konsep Dasar & Arsitektur
MikroTik menyediakan beberapa pendekatan untuk memblokir akses situs:
- Web Proxy (Layer 7 – HTTP): efektif untuk HTTP (port 80). Bisa transparan (redirect) dan memiliki access rules berbasis
dst-hostataupath. - Firewall TLS-Host (SNI): memeriksa Server Name Indication saat TLS handshake (HTTPS, port 443) lalu memblokir berdasarkan
tls-host. - DNS Enforcement: memaksa klien menggunakan DNS router, kemudian memblokir/menyetel static entries atau mem-blackhole domain tertentu.
2) Pra-Syarat & Topologi
Pra-Syarat
- RouterOS v6.41+ (disarankan v7.x) agar matcher
tls-hosttersedia. - Interface LAN (contoh:
bridge) dan WAN sudah berfungsi. - DNS Router aktif:
/ip dns set allow-remote-requests=yes. - Winbox/WebFig/CLI siap digunakan.
Topologi Singkat
Internet ⇄ [WAN] MikroTik [LAN/Bridge] ⇄ Switch/Access Point ⇄ Client
Semua contoh di bawah menggunakan bridge sebagai LAN. Sesuaikan nama interface Anda.
3) Metode A: Web Proxy – Blokir HTTP
Cocok untuk situs yang masih menggunakan HTTP (port 80) atau untuk kebutuhan edukasi. Untuk HTTPS, lanjut ke Metode B.
3.1 Aktifkan Web Proxy
/ip proxy set enabled=yes port=8080 cache-path=web-proxy1 cache-on-disk=yes max-cache-size=100MiB
/ip proxy set anonymous=no parent-proxy=0.0.0.0 parent-proxy-port=0
3.2 Transparent Proxy (Redirect HTTP → Proxy)
/ip firewall nat add chain=dstnat in-interface=bridge protocol=tcp dst-port=80 \
action=redirect to-ports=8080 comment="Redirect HTTP to Web-Proxy"
3.3 Aturan Akses: Blokir Domain via Web Proxy
Gunakan /ip proxy access untuk memblokir berdasarkan dst-host (nama domain) atau path.
# Contoh memblokir beberapa domain HTTP
/ip proxy access add action=deny dst-host=*.facebook.com comment="Block Facebook (HTTP)"
/ip proxy access add action=deny dst-host=*.tiktok.com comment="Block TikTok (HTTP)"
/ip proxy access add action=deny dst-host=*.example-bahaya.site comment="Block domain berbahaya"
# Izinkan yang lain
/ip proxy access add action=allow
4) Metode B: Firewall TLS-Host – Blokir HTTPS (SNI)
Matcher tls-host membaca SNI saat TLS handshake pada port 443, sehingga bisa memblokir domain HTTPS tanpa melakukan inspeksi konten.
4.1 Address-List untuk Manajemen
# Buat daftar domain yang diblokir (HTTPS)
/ip firewall address-list
add list=BLK-TLS-HOST address=*.facebook.com comment="Block Facebook"
add list=BLK-TLS-HOST address=*.tiktok.com comment="Block TikTok"
add list=BLK-TLS-HOST address=*.example-bahaya.site comment="Block Berbahaya"
# Daftar klien yang dikecualikan (whitelist IP)
add list=EXCEPT-CLIENT address=192.168.1.10 comment="Kepsek/Administrator"
4.2 Filter Rule: Drop berdasarkan tls-host
/ip firewall filter add chain=forward action=drop protocol=tcp dst-port=443 \
tls-host-list=BLK-TLS-HOST src-address-list=!EXCEPT-CLIENT \
in-interface=bridge comment="DROP HTTPS by TLS-Host (SNI)"
tls-host-list, gunakan tls-host satu per satu:
/ip firewall filter add chain=forward action=drop protocol=tcp dst-port=443 \
tls-host=*.facebook.com in-interface=bridge comment="Drop Facebook HTTPS"
4.3 Blokir lewat Chain raw (lebih efisien)
/ip firewall raw add chain=prerouting action=drop protocol=tcp dst-port=443 \
tls-host-list=BLK-TLS-HOST in-interface=bridge comment="RAW: Drop lebih awal"
5) Metode C: DNS Hijacking & Pemaksaan DNS
Pastikan semua klien menggunakan DNS dari MikroTik agar aturan blokir DNS/redirect berlaku konsisten.
5.1 Paksa Semua Query DNS ke Router
# 1) Izinkan klien query ke router
/ip dns set allow-remote-requests=yes
# 2) Redirect semua UDP/TCP 53 ke router (NAT)
/ip firewall nat add chain=dstnat in-interface=bridge protocol=udp dst-port=53 \
action=redirect to-ports=53 comment="Hijack DNS UDP ke router"
/ip firewall nat add chain=dstnat in-interface=bridge protocol=tcp dst-port=53 \
action=redirect to-ports=53 comment="Hijack DNS TCP ke router"
# 3) Blokir DNS keluar selain dari router (opsional, via filter)
/ip firewall filter add chain=forward action=drop protocol=udp dst-port=53 \
out-interface=!bridge comment="Drop DNS langsung ke internet"
/ip firewall filter add chain=forward action=drop protocol=tcp dst-port=53 \
out-interface=!bridge comment="Drop DNS langsung ke internet"
5.2 Blokir Domain via DNS (Blackhole)
# Balas domain terlarang dengan alamat "blackhole" (0.0.0.0)
/ip dns static add name=facebook.com address=0.0.0.0 comment="Block via DNS"
/ip dns static add name=tiktok.com address=0.0.0.0 comment="Block via DNS"
# Gunakan subdomain juga jika perlu
/ip dns static add name=www.facebook.com address=0.0.0.0
5.3 Blokir DNS-over-HTTPS (DoH)
# Contoh blokir DoH populer via TLS SNI
/ip firewall address-list
add list=BLK-TLS-HOST address=cloudflare-dns.com comment="DoH Cloudflare"
add list=BLK-TLS-HOST address=dns.google comment="DoH Google"
add list=BLK-TLS-HOST address=doh.opendns.com comment="DoH OpenDNS"
add list=BLK-TLS-HOST address=dns.adguard.com comment="DoH AdGuard"
# (Aturan drop TLS-Host di bagian 4 sudah akan menjegal SNI ini)
5.4 Paksa SafeSearch (Opsional Edukasi)
# Google SafeSearch: arahkan domain ke forcesafesearch
/ip dns static add regexp="(^|\.)google\.com$" address=216.239.38.120 comment="Force SafeSearch"
# YouTube Restricted Mode (Strict)
/ip dns static add name=restrict.youtube.com address=216.239.38.119
/ip dns static add name=www.youtube.com address=216.239.38.119
6) Whitelist, Blacklist, & Pengecualian
6.1 Pengecualian berdasarkan IP Klien
/ip firewall address-list add list=EXCEPT-CLIENT address=192.168.1.10 comment="Kepsek"
# Pastikan aturan drop menggunakan syarat src-address-list=!EXCEPT-CLIENT
6.2 Whitelist Domain Penting
/ip firewall address-list add list=WHITE-TLS-HOST address=*.kemdikbud.go.id
/ip firewall raw add chain=prerouting action=accept protocol=tcp dst-port=443 \
tls-host-list=WHITE-TLS-HOST in-interface=bridge place-before=0 \
comment="Selalu izinkan domain edukasi"
6.3 Manajemen Terpusat
Untuk banyak domain, simpan dalam address-list (seperti contoh), sehingga mudah ditambah/kurangi tanpa mengubah banyak rule.
7) Penjadwalan (Jam Pelajaran/Kerja)
Aktif/nonaktifkan pemblokiran pada jam tertentu menggunakan /system scheduler atau parameter time pada firewall rule.
# Contoh: Blokir hanya Senin–Jumat pukul 07:00–15:00
/ip firewall raw add chain=prerouting action=drop protocol=tcp dst-port=443 \
tls-host-list=BLK-TLS-HOST in-interface=bridge time=mon-fri,7h-15h \
comment="Jadwal sekolah"
/system scheduler dengan script enable/disable.
8) Monitoring & Logging
8.1 Log Hit Firewall
/ip firewall raw add chain=prerouting action=drop protocol=tcp dst-port=443 \
tls-host-list=BLK-TLS-HOST in-interface=bridge log=yes log-prefix="DROP-HTTPS-SNI "
# Cek log:
/log print where message~"DROP-HTTPS-SNI"
8.2 Tools Bantu
/tool torchuntuk melihat koneksi real-time./ip firewall connection printuntuk daftar koneksi./tool sniffer quick interface=bridge port=443untuk capture cepat.
9) Troubleshooting
| Gejala | Penyebab Umum | Solusi |
|---|---|---|
| HTTPS masih lolos | Aplikasi pakai ECH/ESNI atau DoH, rule kurang spesifik | Aktifkan DNS hijacking, blokir DoH, tambah domain terkait ke BLK-TLS-HOST, gunakan raw |
| Klien tidak terpengaruh | Rule tidak di-hit, interface salah, urutan rule salah | Pastikan in-interface=bridge, pindahkan rule ke atas (place-before), cek counters |
| Internet klien terputus | Rule terlalu ketat (drop semua DNS/HTTPS) | Mulai dari log-only, tes bertahap, gunakan whitelist |
| HTTP tidak terblokir | Transparent proxy belum aktif | Tambahkan rule dstnat redirect port 80 ke 8080 |
10) Latihan/Praktik Siswa
- Aktifkan DNS hijacking (bagian 5.1) dan uji dengan nslookup/ping.
- Tambahkan 3 domain ke
BLK-TLS-HOSTdan verifikasi blokir HTTPS dengan membuka dari browser. - Konfigurasi whitelist untuk 1 komputer guru agar bebas filter.
- Aktifkan logging dan kirimkan screenshot
/log printsaat blokir terjadi. - Buat jadwal blokir hanya di jam pelajaran; uji di luar jam tersebut.
11) Lampiran: Perintah Lengkap (Copy–Paste)
11.1 Paket Dasar (sesuaikan interface & jaringan)
# === Variabel contoh ===
# LAN bridge: bridge
# Jaringan LAN: 192.168.1.0/24
# Aktifkan DNS di router
/ip dns set allow-remote-requests=yes
# === Web Proxy (HTTP) ===
/ip proxy set enabled=yes port=8080 cache-path=web-proxy1 cache-on-disk=yes
/ip firewall nat add chain=dstnat in-interface=bridge protocol=tcp dst-port=80 \
action=redirect to-ports=8080 comment="Transparent Proxy HTTP"
# Blokir HTTP tertentu
/ip proxy access add action=deny dst-host=*.facebook.com
/ip proxy access add action=deny dst-host=*.tiktok.com
/ip proxy access add action=allow
# === TLS-Host (HTTPS) ===
/ip firewall address-list
add list=BLK-TLS-HOST address=*.facebook.com
add list=BLK-TLS-HOST address=*.tiktok.com
add list=EXCEPT-CLIENT address=192.168.1.10 comment="Whitelist IP"
# Drop di chain raw (efisien)
/ip firewall raw add chain=prerouting action=drop protocol=tcp dst-port=443 \
tls-host-list=BLK-TLS-HOST in-interface=bridge comment="Drop HTTPS by SNI"
# === DNS Enforcement ===
/ip firewall nat add chain=dstnat in-interface=bridge protocol=udp dst-port=53 \
action=redirect to-ports=53 comment="Hijack DNS UDP"
/ip firewall nat add chain=dstnat in-interface=bridge protocol=tcp dst-port=53 \
action=redirect to-ports=53 comment="Hijack DNS TCP"
# (Opsional) Drop DNS langsung ke internet
/ip firewall filter add chain=forward action=drop protocol=udp dst-port=53 out-interface=!bridge
/ip firewall filter add chain=forward action=drop protocol=tcp dst-port=53 out-interface=!bridge
# === Blokir DoH populer via SNI ===
/ip firewall address-list
add list=BLK-TLS-HOST address=cloudflare-dns.com
add list=BLK-TLS-HOST address=dns.google
add list=BLK-TLS-HOST address=doh.opendns.com
add list=BLK-TLS-HOST address=dns.adguard.com
# === Logging (opsional) ===
/ip firewall raw add chain=prerouting action=drop protocol=tcp dst-port=443 \
tls-host-list=BLK-TLS-HOST in-interface=bridge log=yes log-prefix="DROP-HTTPS-SNI "
11.2 Jadwal Blokir
/ip firewall raw add chain=prerouting action=drop protocol=tcp dst-port=443 \
tls-host-list=BLK-TLS-HOST in-interface=bridge time=mon-fri,7h-15h comment="Jam sekolah"
11.3 Whitelist Domain Edukasi
/ip firewall address-list add list=WHITE-TLS-HOST address=*.kemdikbud.go.id
/ip firewall raw add chain=prerouting action=accept protocol=tcp dst-port=443 \
tls-host-list=WHITE-TLS-HOST in-interface=bridge place-before=0
Komentar
Posting Komentar