Friday, 8 August 2025

Konfigurasi Lengkap Queue Tree + PCQ / HTB di MikroTik

 Berikut adalah konfigurasi lengkap Queue Tree + PCQ / HTB di MikroTik yang memenuhi semua kebutuhan kamu:


🎯 Tujuan Konfigurasi

  1. Limit bandwidth presisi & otomatis per user (PCQ)

  2. Cocok untuk 5–50 pengguna (DHCP)

  3. Prioritas 1: Komunikasi (WhatsApp, Zoom, VoIP, dll)

  4. Prioritas 2: Web Browsing

  5. Prioritas 3: Download (dibatasi 5 Mbps)

  6. Berlaku untuk semua user DHCP secara otomatis

  7. Implementasi dengan Queue Tree + Mangle + PCQ + HTB


🧱 Asumsi

  • ether1 = WAN (ke internet)

  • ether2 = LAN (ke user DHCP)

  • IP LAN = 192.168.88.0/24 (ubah jika beda)

  • User pakai DHCP otomatis dari MikroTik

  • Prioritas diberi lewat priority (1 = tertinggi, 8 = terendah)


🔧 LANGKAH 1: Buat PCQ Type

/queue type
add name=pcq-comm kind=pcq pcq-rate=1M pcq-classifier=dst-address
add name=pcq-web kind=pcq pcq-rate=512k pcq-classifier=dst-address
add name=pcq-download kind=pcq pcq-rate=5M pcq-classifier=dst-address

🔧 LANGKAH 2: Mangle untuk Tandai Traffic

/ip firewall mangle
# Tandai koneksi komunikasi
add chain=forward protocol=udp port=3478,5349,10000,30000-50000 action=mark-connection new-connection-mark=comm-conn passthrough=yes
add chain=forward protocol=tcp port=443 dst-port=443 content=whatsapp action=mark-connection new-connection-mark=comm-conn passthrough=yes

# Tandai koneksi web
add chain=forward protocol=tcp port=80,443 action=mark-connection new-connection-mark=web-conn passthrough=yes

# Tandai koneksi download (umumnya HTTP besar, FTP, video streaming, dll)
add chain=forward protocol=tcp port=20,21,8000-8999,8080 action=mark-connection new-connection-mark=download-conn passthrough=yes

# Tandai paket berdasarkan koneksi
add chain=forward connection-mark=comm-conn action=mark-packet new-packet-mark=comm-packet passthrough=no
add chain=forward connection-mark=web-conn action=mark-packet new-packet-mark=web-packet passthrough=no
add chain=forward connection-mark=download-conn action=mark-packet new-packet-mark=download-packet passthrough=no

🔧 LANGKAH 3: Buat Queue Tree

/queue tree
# KOMUNIKASI - PRIORITAS 1
add name="COMM-TREE" parent=ether1 packet-mark=comm-packet queue=pcq-comm priority=1

# WEB BROWSING - PRIORITAS 2
add name="WEB-TREE" parent=ether1 packet-mark=web-packet queue=pcq-web priority=2

# DOWNLOAD - PRIORITAS 3
add name="DOWNLOAD-TREE" parent=ether1 packet-mark=download-packet queue=pcq-download priority=8 max-limit=5M

Jika ingin memisahkan upload & download, bisa buat dua set mangle dan queue untuk masing-masing in-interface dan out-interface.


🧠 Penjelasan:

  • PCQ otomatis mendeteksi IP user dari DHCP

  • Priority 1, 2, 8 digunakan MikroTik HTB untuk mengatur antrian

  • Komunikasi (Zoom, WhatsApp, dll) tetap lancar walau user banyak download

  • Download tetap bisa tapi dibatasi maksimal 5 Mbps total


✅ BONUS: Lihat Statistik Realtime

Gunakan:

/queue tree print stats

Untuk memantau penggunaan bandwidth setiap kelas.


🔄 Opsional:

Ingin supaya total bandwidth dibatasi juga? Misal total maksimal 50 Mbps?
Tambahkan satu queue parent:

/queue tree
add name="PARENT-LIMIT" parent=ether1 max-limit=50M

Lalu jadikan semua child tree (COMM-TREE, WEB-TREE, DOWNLOAD-TREE) sebagai child dari PARENT-LIMIT.


Kalau kamu pakai hotspot atau VLAN, tinggal sesuaikan parent dan ip subnet saja.

Perlu saya bantu buatkan export script .rsc lengkap biar bisa copy-paste langsung?

Konfigurasi Queue Tree + PCQ (HTB)

 Berikut adalah konfigurasi Queue Tree + PCQ (HTB) yang otomatis membatasi bandwidth per user (tanpa perlu atur satu-satu), cocok untuk jaringan dengan 5–50 user DHCP, dan bandwidth terbagi adil secara otomatis:


🎯 Tujuan:

  • Semua user DHCP dibatasi 1 Mbps upload / 2 Mbps download per user

  • Total bandwidth dibagi merata otomatis (misal 50 user sharing 100 Mbps tetap masing-masing dapat 2 Mbps)

  • Tanpa perlu IP statis

  • Gunakan interface LAN dan interface WAN sesuai perangkat kamu (ganti nama jika perlu)


🧱 Langkah 1: Buat PCQ Type

/queue type
add name=pcq-download kind=pcq pcq-rate=2M pcq-classifier=dst-address pcq-limit=50 pcq-total-limit=2000
add name=pcq-upload kind=pcq pcq-rate=1M pcq-classifier=src-address pcq-limit=50 pcq-total-limit=2000

🎯 Penjelasan:

  • dst-address → untuk download (target IP di LAN)

  • src-address → untuk upload (source IP dari LAN)

  • pcq-rate → batas kecepatan per user

  • pcq-limit/total-limit → buffer per koneksi dan total


🧱 Langkah 2: Tandai koneksi dan paket

Asumsikan:

  • ether1 = WAN

  • ether2 = LAN (DHCP ke client)

/ip firewall mangle
add chain=forward action=mark-connection new-connection-mark=conn-download passthrough=yes in-interface=ether1
add chain=forward action=mark-connection new-connection-mark=conn-upload passthrough=yes in-interface=ether2

add chain=forward action=mark-packet new-packet-mark=packet-download passthrough=no connection-mark=conn-download
add chain=forward action=mark-packet new-packet-mark=packet-upload passthrough=no connection-mark=conn-upload

🧱 Langkah 3: Buat Queue Tree

/queue tree
add name="DOWNLOAD-TREE" parent=ether2 packet-mark=packet-download queue=pcq-download
add name="UPLOAD-TREE" parent=ether1 packet-mark=packet-upload queue=pcq-upload

🔧 Tambahan (Opsional)

Jika interface kamu beda (misalnya bridge atau VLAN), sesuaikan parent di queue tree.

Contoh:

  • Kalau pakai bridge: parent=bridge1

  • Kalau VLAN: parent=vlan10


✅ Hasil Akhir:

  • Setiap device yang terhubung ke LAN akan dapat 2 Mbps download & 1 Mbps upload

  • Otomatis, walaupun jumlah user naik-turun

  • Tetap adil, tanpa berebut bandwidth


Kalau kamu mau atur pembagian misalnya:

  • Total 50 Mbps dibagi rata (bukan limit fix per user)

  • Limit per grup IP (misalnya: 192.168.88.0 dibedakan dengan 192.168.89.0)

... saya juga bisa bantu. Cukup bilang saja.

Perlu juga script backup-nya atau ekspor otomatisnya?

Pengaturan bandwidth di MikroTik

 Untuk membatasi bandwidth di MikroTik, Queue adalah metode paling umum, tapi memang ada metode lain yang lebih presisi, scalable, dan efisien, terutama di jaringan besar atau yang butuh kontrol kompleks. Berikut beberapa metode yang bisa lebih bagus daripada Queue sederhana:


🔧 1. Simple Queue vs Queue Tree (HTB)

Metode Kelebihan Kekurangan
Simple Queue Mudah digunakan, cocok untuk skenario kecil Kurang presisi di jaringan besar atau kompleks
Queue Tree (HTB) Lebih fleksibel dan presisi, cocok untuk multiple interface & VLAN Butuh lebih banyak konfigurasi dan pemahaman dasar

📌 Queue Tree dengan HTB (Hierarchical Token Bucket) memungkinkan:

  • Pembagian bandwidth per grup IP / VLAN / interface

  • Limit upload & download di satu aturan

  • Penjadwalan prioritas (QoS)


🔧 2. PCQ (Per Connection Queue) dengan Queue Tree

  • Ideal untuk membatasi bandwidth per user otomatis (misal hotspot).

  • Digunakan bersama Queue Tree.

  • Tidak perlu buat satu-satu aturan untuk tiap user.

/queue type
add kind=pcq name=pcq-download pcq-classifier=dst-address pcq-rate=1M
add kind=pcq name=pcq-upload pcq-classifier=src-address pcq-rate=1M
/queue tree
add name="Download-LAN" parent=ether2 queue=pcq-download packet-mark=download
add name="Upload-LAN" parent=ether1 queue=pcq-upload packet-mark=upload

➡ Ini jauh lebih scalable dibanding Simple Queue per-IP.


🧠 3. Dynamic Queue via Radius / User Manager

  • Bila kamu pakai Hotspot atau PPP, kamu bisa set limit bandwidth via Radius.

  • Ideal untuk manajemen user berbasis akun (bukan IP statis).

  • Bisa diatur limit otomatis via profil user.


🔒 4. Firewall Mangle + Queue Tree (Mark Packet/Connection)

Jika butuh kontrol lanjutan (misal by port, by app, by protocol):

  • Tandai koneksi/packet via Mangle Rules

  • Terapkan Queue Tree berdasarkan mark itu

Contoh:

/ip firewall mangle
add chain=forward protocol=tcp dst-port=80 action=mark-packet new-packet-mark=HTTP passthrough=yes

⚙️ 5. Smart QoS Script (Auto Limit berdasarkan load)

Ada beberapa script komunitas seperti "Smart QoS" atau "PCQ Auto" yang bisa:

  • Mengelompokkan user otomatis

  • Membagi bandwidth secara adil

  • Bisa dijalankan otomatis saat user banyak


Kapan Queue Tree Lebih Baik?

Gunakan Queue Tree + PCQ / HTB jika:

  • Ingin limit bandwidth lebih presisi

  • Punya lebih dari 5-10 pengguna

  • Ingin sistem otomatis per user

  • Ingin limit per VLAN / interface


Kalau kamu jelaskan lebih detail topologi kamu (jumlah user, apakah pakai hotspot, pakai IP static atau DHCP, dll), saya bisa bantu buatkan contoh konfigurasinya.

Mau?