ABDURROZAK
HOME ABOUT ME MICROSITE KONTAK PERSEMBAHAN HELP
ABDURROZAK.MY.ID // MIKROTIK TUTORIAL

LAYER7 PROTOCOL

RB941 hAP LITE - DEEP PACKET INSPECTION LENGKAP

Panduan mendalam Layer7 Protocol: regex pattern, deteksi aplikasi, blocking YouTube/TikTok/Facebook, integrasi mangle + queue tree, monitoring, dan troubleshooting. Setup lengkap dari dasar router hingga advanced DPI. Konfigurasi dual: CLI (Terminal) & WinBox (GUI).

SPESIFIKASI HARDWARE RB941-2nD

RB941 hAP lite dengan CPU AR9344 650MHz dan RAM 32MB. Layer7 Protocol SANGAT MEMBERATKAN CPU karena harus inspect isi packet. Untuk RB941, batasi maksimal 5-10 pattern L7 aktif bersamaan. Untuk kebutuhan DPI intensif, pertimbangkan upgrade ke hAP ac^2 (717MHz, 128MB RAM) atau CCR series.

CPU
AR9344 - 650MHz
RAM
32 MB DDR2
STORAGE
16 MB FLASH
ETHERNET
4x 10/100 Mbps
WIRELESS
2.4GHz b/g/n
L7 PATTERN
5-10 MAX
L7 MAX BW
~20-30 Mbps
CLIENT MAX
~20 DEVICE
POWER
5V DC / USB
OS
RouterOS v6 L4
DIMENSI
113 x 89 x 28mm
BERAT
160 gram
LIMITASI LAYER7 RB941: Layer7 inspect isi packet = CPU intensive. RB941 dengan RAM 32MB terbatas. Jangan gabungkan L7 + hotspot + banyak queue tree. Monitor CPU load, jika >80% kurangi pattern atau upgrade hardware.
TOPOLOGI LAYER7 DPI SCHEMA
// TOPOLOGI LAYER7 PROTOCOL DETECTION // [ INTERNET / ISP ] | | kabel UTP v +--------------------------------------+ | MikroTik RB941 | | LAYER7 DEEP PACKET INSPECTION | | | | ether1 = WAN (IP dari ISP) | | | | [ L7 ENGINE ] | | |- youtube-pattern | | |- tiktok-pattern | | |- facebook-pattern | | |- instagram-pattern | | | | [ MANGLE ] | | |- mark-connection (by L7) | | |- mark-packet (by conn-mark) | | | | [ QUEUE TREE ] | | |- youtube-queue (limit/block) | | |- tiktok-queue (limit/block) | | |- facebook-queue (limit/block) | | | | bridge1 (LAN Gateway) | | |- ether2-4 + wlan1 | +--------------------------------------+ | v [ CLIENT ] -- traffic di-inspect by L7
ALUR LAYER7: (1) Packet masuk dari client, (2) Mangle inspect isi packet dengan regex pattern, (3) Jika match -> mark connection, (4) Mark packet berdasarkan connection-mark, (5) Queue tree apply limit/block berdasarkan packet-mark.
ANIMASI DEEP PACKET INSPECTION LIVE FLOW

Visualisasi DPI: packet dari client di-inspect oleh L7 engine, regex pattern match dengan konten packet, lalu di-mark dan di-route ke queue tree yang sesuai (limit/block/allow).

INTERNET ISP / SERVER MIKROTIK RB941 LAYER7 DEEP PACKET INSPECTION WAN ether1 L7 ENGINE Regex Pattern Match MANGLE Mark Conn/Packet QUEUE TREE Limit / Block e2 LAN WIFI wlan1 PATTERN: youtube, tiktok, facebook, instagram, dll YOUTUBE L7 MATCH BLOCKED BROWSING NO MATCH ALLOWED TIKTOK L7 MATCH LIMITED 2M FACEBOOK L7 MATCH LIMITED 3M // LAYER7 DPI FLOW // PACKET -> L7 INSPECT -> REGEX MATCH -> MARK -> QUEUE TREE -> BLOCK/LIMIT/ALLOW
Blocked (L7 Match)
Allowed (No Match)
Limited (L7 Match)
Request Packet
Response Packet
DEEP INSPECTION: L7 engine membuka isi packet (payload), bukan hanya header. Regex pattern mencocokkan dengan konten (domain, URL, dll). Jika match, packet di-mark dan di-route sesuai queue tree.
KONSEP DASAR LAYER7 PROTOCOL FUNDAMENTAL

Layer7 Protocol di MikroTik adalah fitur Deep Packet Inspection (DPI) yang bekerja di Layer 7 (Application Layer) model OSI. Berbeda dengan firewall biasa yang hanya melihat header packet (IP, port), Layer7 membuka isi payload packet dan mencocokkan dengan regex pattern untuk mengidentifikasi aplikasi.

MODEL OSI - LAYER 7
LAYERNAMAFUNGSICONTOH
7ApplicationAplikasi userHTTP, FTP, SMTP, DNS, YouTube, TikTok
6PresentationEnkripsi, formatSSL/TLS, JPEG, ASCII
5SessionSession managementNetBIOS, RPC
4TransportEnd-to-end connectionTCP, UDP
3NetworkRouting, addressingIP, ICMP
2Data LinkFrame, MAC addressEthernet, WiFi
1PhysicalBit, sinyalKabel, radio
FIREWALL BIASA vs LAYER7
ASPEKFIREWALL BIASALAYER7 PROTOCOL
InspeksiHeader (IP, port, protocol)Payload (isi packet)
IdentifikasiBerdasarkan port (80, 443)Berdasarkan konten (regex)
ContohBlokir port 443 = semua HTTPSBlokir youtube.com saja
AkurasiRendah (bisa salah blok)Tinggi (pattern spesifik)
PerformaRinganBerat (CPU intensive)
HTTPSBisa blokir portTidak bisa baca isi (encrypted)
Use caseBlock port/protocolBlock aplikasi spesifik
ALUR LAYER7 DPI
1
PACKET MASUK
Packet dari client masuk ke router. Bisa HTTP, HTTPS, atau protocol lain.
2
MANGLE INSPECT
Mangle rule dengan layer7-protocol inspect isi packet. Buka payload, baca konten.
3
REGEX MATCH
Regex pattern mencocokkan dengan konten. Contoh: pattern "youtube\.com" match dengan "www.youtube.com/watch?v=xxx".
4
MARK CONNECTION
Jika match, connection di-mark dengan nama tertentu (conn-youtube, conn-tiktok, dll).
5
MARK PACKET
Packet di-mark berdasarkan connection-mark. Setiap packet dalam connection yang sama dapat mark yang sama.
6
QUEUE TREE ACTION
Queue tree apply action berdasarkan packet-mark: block (drop), limit (max-limit), atau allow (priority).
LIMITASI LAYER7
PENTING:
1. Layer7 TIDAK BISA baca isi HTTPS (terenkripsi TLS/SSL). Hanya match di SNI header yang masih terlihat.
2. Layer7 SANGAT BERAT CPU. RB941 bisa 80-100% CPU dengan 5+ pattern aktif.
3. Untuk HTTPS modern, lebih baik pakai DNS filtering atau IP address-list.
4. Batasi maksimal 3-5 L7 pattern di RB941 untuk performa optimal.
KAPAN PAKAI LAYER7? Untuk block aplikasi HTTP (non-HTTPS) atau aplikasi yang masih bisa dideteksi via SNI. Untuk block HTTPS modern (YouTube, TikTok, Facebook), lebih efektif pakai DNS filtering + IP address-list.
DASAR REGEX (REGULAR EXPRESSION) FUNDAMENTAL

Regex adalah pattern untuk mencocokkan text. Layer7 MikroTik pakai regex untuk identifikasi aplikasi. Pahami dasar regex untuk membuat pattern yang efektif.

SIMBOL REGEX DASAR
SIMBOLARTICONTOHMATCH
.Character apapun (1 karakter)a.cabc, axc, a3c
*0 atau lebih dari sebelumnyaab*cac, abc, abbc, abbbc
+1 atau lebih dari sebelumnyaab+cabc, abbc (tapi BUKAN ac)
?0 atau 1 dari sebelumnyaab?cac, abc
\.Titik literal (bukan wildcard)youtube\.comyoutube.com
^Awal string^www\.www. di awal
$Akhir string\.com$.com di akhir
[...]Character class[abc]a, b, atau c
[^...]Negated character class[^0-9]Bukan angka
(...)Group(abc)+abc, abcabc
|ORyoutube|tiktokyoutube ATAU tiktok
\dDigit (0-9)\d+123, 456
\wWord character (a-z, A-Z, 0-9, _)\w+kata, kata123
\sWhitespace (space, tab, newline)\s+spasi, tab
CONTOH PATTERN & HASIL
# Pattern: youtube\.com youtube\.com -> www.youtube.com/watch MATCH -> m.youtube.com MATCH -> youtubecom (nomatch, tidak ada titik) # \. = titik literal, bukan "karakter apapun" # Pattern: (youtube|tiktok|facebook)\.com (youtube|tiktok|facebook)\.com -> www.youtube.com MATCH -> www.tiktok.com MATCH -> www.facebook.com MATCH -> www.twitter.com (nomatch) # () = group, | = OR # Pattern: \.tiktok\.com \.tiktok\.com -> m.tiktok.com MATCH -> www.tiktok.com MATCH -> api.tiktok.com MATCH # cocok untuk semua subdomain tiktok # Pattern: ^.*\.(fbcdn|fb\.com) ^.*\.(fbcdn|fb\.com) -> scontent.fbcdn.net MATCH -> www.fb.com MATCH # ^.* = awal string, apapun
TIPS MENULIS REGEX
ESCAPE TITIK
Selalu pakai \. untuk titik di domain. Titik tanpa escape = wildcard yang match karakter apapun.
PAKAI WILDCARD SUBDOMAIN
Awali dengan .*\. atau (^|\.). untuk match semua subdomain (m, www, api, dll).
GROUP MULTIPLE DOMAIN
Pakai (a|b|c) untuk gabungkan beberapa domain dalam satu pattern. Lebih efisien.
TEST DI REGEX TOOL
Test pattern di regex101.com atau regexr.com sebelum apply di MikroTik. Hemat waktu debugging.
TIPS: Regex case-sensitive secara default. "YouTube" berbeda dengan "youtube". Untuk case-insensitive, perlu flag khusus (tidak support di MikroTik). Buat pattern yang match kedua-duanya jika perlu.
PERSIAPAN SEBELUM KONFIGURASI STEP 01

Siapkan hal-hal berikut agar proses konfigurasi Layer7 berjalan lancar.

YANG HARUS DISIAPKAN
ITEMKETERANGANCATATAN
Router RB941Sudah terpasang adaptor 5VLED PWR harus menyala
Kabel UTPMinimal 2 buah (straight)1 untuk WAN, 1 untuk PC
PC/LaptopDengan port ethernetUntuk akses awal via kabel
WinBoxDownload dari mikrotik.comAtau pakai browser (WebFig)
Info ISPJenis koneksi: DHCP/PPPoE/StaticTanya ISP jika tidak tahu
Daftar AplikasiAplikasi yang ingin di-block/limitYouTube, TikTok, Facebook, dll
Regex PatternPattern untuk setiap aplikasiTest dulu di regex tool
SKEMA IP YANG AKAN DIGUNAKAN
KOMPONENIP ADDRESSKETERANGAN
Gateway Router192.168.10.1/24IP router di LAN
Subnet192.168.10.0/24Range: .0 - .255
Netmask255.255.255.0/24 = 254 host
DHCP Pool192.168.10.100 - .200101 IP untuk client
TIPS: Sebelum konfigurasi Layer7, pastikan router sudah bisa akses internet. Test ping ke 8.8.8.8 dan google.com. Jika belum bisa, selesaikan masalah koneksi dulu.
RESET & AKSES ROUTER STEP 02

Reset router ke factory default, lalu akses via WinBox atau browser.

VIA HARDWARE
1
Cabut power router
2
Tekan tombol RESET dengan pin
3
Colok power sambil tekan RESET
4
Tunggu ~5 detik sampai LED ACT berkedip
5
Lepas tombol, router reboot
6
Tunggu 1-2 menit sampai fully boot
VIA CLI
# Reset dengan default config [admin@MikroTik] > /system reset-configuration Do you really want to reset configuration? [y/N] y # Reset tanpa default config [admin@MikroTik] > /system reset-configuration no-defaults=yes skip-backup=yes ! WARNING: semua konfigurasi terhapus
AKSES ROUTER
VIA WINBOX (RECOMMENDED)
1
Colok kabel UTP dari PC ke ether2
2
Buka WinBox
3
Tab Neighbors, tunggu router muncul
4
Klik MAC address router
5
Login: admin | Password: (kosong)
6
Klik Connect
VIA WEBFIG (BROWSER)
1
Colok kabel UTP dari PC ke ether2
2
Buka browser
3
Ketik: http://192.168.88.1
4
Login: admin | Password: (kosong)
5
Masuk ke WebFig
PENTING: Selalu connect via MAC address di WinBox. Jika IP berubah atau salah konfigurasi, Anda masih bisa akses via MAC.
IDENTITY & GANTI PASSWORD STEP 03

Beri nama router dan GANTI PASSWORD ADMIN. WAJIB sebelum router terhubung internet.

VIA CLI
# 1. Set identity [admin@MikroTik] > /system identity set name="L7-GATEWAY" [admin@L7-GATEWAY] > # 2. Ganti password admin (WAJIB!) [admin@L7-GATEWAY] > /user set admin password="Rozak@L7-2024!" # 3. Cek list user [admin@L7-GATEWAY] > /user print # NAME GROUP 0 admin full
VIA WINBOX
1
Menu: System -> Identity
2
Name: L7-GATEWAY
3
Klik OK
4
Menu: System -> Users
5
Double-click admin -> tombol Password
6
Password baru (min 12 karakter)
7
Klik OK -> OK
KRITIS: Password admin harus KUAT. Minimal 12 karakter, kombinasi huruf besar, kecil, angka, dan simbol. CATAT di tempat aman. Jika lupa, harus reset fisik router.
CEK & NAMA INTERFACE STEP 04

Cek interface, beri nama yang jelas. ether1 = WAN, ether2-4 = LAN, wlan1 = WIFI.

VIA CLI
# 1. Cek interface [admin@L7-GATEWAY] > /interface print # NAME TYPE MTU 0 ether1 ether 1500 1 ether2 ether 1500 2 ether3 ether 1500 3 ether4 ether 1500 4 wlan1 wlan 1500 5 bridge1 bridge 1500 # 2. Rename interface [admin@L7-GATEWAY] > /interface set ether1 name="WAN" [admin@L7-GATEWAY] > /interface set ether2 name="LAN1" [admin@L7-GATEWAY] > /interface set ether3 name="LAN2" [admin@L7-GATEWAY] > /interface set ether4 name="LAN3"
VIA WINBOX
1
Menu: Interfaces
2
Double-click ether1 -> Name: WAN
3
Ulangi untuk ether2-4: LAN1, LAN2, LAN3
4
Klik Apply -> OK
BRIDGE SETUP STEP 05

Bridge menyatukan LAN (ether2-4) dan WiFi (wlan1) menjadi satu jaringan.

VIA CLI
# 1. Cek bridge port default [admin@L7-GATEWAY] > /interface bridge port print # INTERFACE BRIDGE PVID 0 ether2 bridge1 1 1 ether3 bridge1 1 2 ether4 bridge1 1 3 wlan1 bridge1 1 # 2. Optimasi bridge [admin@L7-GATEWAY] > /interface bridge set bridge1 protocol-mode=rstp fast-forward=yes
VIA WINBOX
1
Menu: Bridge
2
Tab Ports: cek ether2-4, wlan1 sudah ada
3
Double-click bridge1
4
Tab Advanced: Protocol Mode: rstp
5
Tab HW: centang Fast Forward
6
Klik Apply -> OK
PENTING: Jangan masukkan ether1 (WAN) ke bridge! ether1 harus terpisah sebagai WAN.
IP ADDRESS GATEWAY STEP 06

Setup IP address untuk bridge (gateway LAN).

VIA CLI
# 1. Ganti IP gateway [admin@L7-GATEWAY] > /ip address set [find interface=bridge] address=192.168.10.1/24 # 2. Verifikasi [admin@L7-GATEWAY] > /ip address print # ADDRESS NETWORK INTERFACE 0 192.168.10.1/24 192.168.10.0 bridge
VIA WINBOX
1
Menu: IP -> Addresses
2
Double-click entry bridge
3
Address: 192.168.10.1/24
4
Interface: bridge
5
Klik Apply -> OK
DHCP CLIENT (WAN) STEP 07

Setup DHCP client di WAN agar router dapat IP dari ISP.

VIA CLI
# Setup DHCP client di WAN [admin@L7-GATEWAY] > /ip dhcp-client add interface=ether1 disabled=no use-peer-dns=yes use-peer-ntp=no add-default-route=yes # Cek status - harus "bound" [admin@L7-GATEWAY] > /ip dhcp-client print # INTERFACE STATUS ADDRESS 0 ether1 bound 10.10.10.5/24
VIA WINBOX
1
Menu: IP -> DHCP Client
2
+ Add: Interface: ether1
3
Add Default Route: yes
4
Use Peer DNS: yes
5
Klik OK
6
Status harus bound
DHCP SERVER (LAN) STEP 08

Setup DHCP server agar client dapat IP otomatis.

VIA CLI
# 1. Buat IP pool [admin@L7-GATEWAY] > /ip pool add name="pool-lan" ranges=192.168.10.100-192.168.10.200 # 2. Buat DHCP server [admin@L7-GATEWAY] > /ip dhcp-server add name="dhcp-lan" interface=bridge address-pool="pool-lan" lease-time=10m authoritative=yes # 3. Buat DHCP network [admin@L7-GATEWAY] > /ip dhcp-server network add address=192.168.10.0/24 gateway=192.168.10.1 dns-server=192.168.10.1,8.8.8.8 # 4. Verifikasi [admin@L7-GATEWAY] > /ip dhcp-server print # NAME INTERFACE ADDRESS-POOL 0 dhcp-lan bridge pool-lan
VIA WINBOX
1
Menu: IP -> Pool -> + Add
2
Name: pool-lan, Ranges: 192.168.10.100-200
3
Menu: IP -> DHCP Server -> DHCP Setup
4
Interface: bridge -> Next (sampai selesai)
5
Verifikasi di tab Networks
NAT MASQUERADE STEP 09

NAT masquerade WAJIB agar client LAN bisa akses internet.

VIA CLI
[admin@L7-GATEWAY] > /ip firewall nat add chain=srcnat action=masquerade out-interface=ether1 comment="NAT to ISP" [admin@L7-GATEWAY] > /ip firewall nat print # CHAIN ACTION OUT-INTERFACE 0 srcnat masquerade ether1
VIA WINBOX
1
Menu: IP -> Firewall -> Tab NAT
2
+ Add
3
Chain: srcnat
4
Out. Interface: ether1
5
Action: masquerade
6
Klik OK
DNS FORWARDING STEP 10

Setup DNS agar client bisa resolve domain.

VIA CLI
[admin@L7-GATEWAY] > /ip dns set servers=1.1.1.1,8.8.8.8 allow-remote-requests=yes cache-size=2048KiB [admin@L7-GATEWAY] > /ip dns print servers: 1.1.1.1, 8.8.8.8 allow-remote-requests: yes [admin@L7-GATEWAY] > /ping google.com count=4
VIA WINBOX
1
Menu: IP -> DNS
2
Servers: 1.1.1.1, 8.8.8.8
3
Centang Allow Remote Requests
4
Cache Size: 2048 KiB
5
Klik Apply -> OK
NTP & TIMEZONE STEP 11

Setup NTP agar waktu router akurat.

VIA CLI
[admin@L7-GATEWAY] > /system ntp client set enabled=yes mode=unicast primary-ntp=132.163.96.1 secondary-ntp=8.8.8.8 [admin@L7-GATEWAY] > /system clock set time-zone-name=Asia/Jakarta [admin@L7-GATEWAY] > /system clock print date and time: 2024-11-15 14:32:08 time-zone-name: Asia/Jakarta
VIA WINBOX
1
Menu: System -> NTP Client
2
Centang Enabled
3
Primary NTP: 132.163.96.1
4
Menu: System -> Clock
5
Time Zone Name: Asia/Jakarta
6
Klik OK
FIREWALL DASAR STEP 12

Setup firewall dasar untuk melindungi router.

VIA CLI
# 1. Allow established/related [admin@L7-GATEWAY] > /ip firewall filter add chain=input connection-state=established,related action=accept in-interface=ether1 # 2. Drop invalid [admin@L7-GATEWAY] > /ip firewall filter add chain=input connection-state=invalid action=drop in-interface=ether1 # 3. Allow ICMP [admin@L7-GATEWAY] > /ip firewall filter add chain=input protocol=icmp action=accept in-interface=ether1 # 4. Drop semua dari WAN [admin@L7-GATEWAY] > /ip firewall filter add chain=input action=drop in-interface=ether1 # 5. Forward: allow established [admin@L7-GATEWAY] > /ip firewall filter add chain=forward connection-state=established,related action=accept # 6. Forward: drop invalid [admin@L7-GATEWAY] > /ip firewall filter add chain=forward connection-state=invalid action=drop
VIA WINBOX
1
Menu: IP -> Firewall -> Tab Filter Rules
2
+ Add Rule 1: Chain: input, Conn. State: established,related, In. Interface: ether1, Action: accept
3
+ Add Rule 2: Chain: input, Conn. State: invalid, In. Interface: ether1, Action: drop
4
+ Add Rule 3: Chain: input, Protocol: icmp, In. Interface: ether1, Action: accept
5
+ Add Rule 4: Chain: input, In. Interface: ether1, Action: drop
6
+ Add Rule 5: Chain: forward, Conn. State: established,related, Action: accept
7
+ Add Rule 6: Chain: forward, Conn. State: invalid, Action: drop
PENTING: Urutan rule firewall SANGAT PENTING. Rule accept established HARUS di paling atas.
WIRELESS SETUP STEP 13

Setup WiFi agar client wireless bisa connect.

VIA CLI
# 1. Set mode AP, SSID [admin@L7-GATEWAY] > /interface wireless set wlan1 mode=ap-bridge ssid="L7-NETWORK" country=indonesia frequency-mode=regulatory-domain # 2. Set channel [admin@L7-GATEWAY] > /interface wireless set wlan1 channel=6 band=2ghz-b/g/n # 3. Setup WPA2-PSK security [admin@L7-GATEWAY] > /interface wireless security-profiles set [find default=yes] mode=dynamic-keys authentication-types=wpa2-psk wpa2-pre-shared-key="wifi@l7net2024!" # 4. Set tx-power [admin@L7-GATEWAY] > /interface wireless set wlan1 tx-power-mode=all-rates-fixed tx-power=17 # 5. Verifikasi [admin@L7-GATEWAY] > /interface wireless print
VIA WINBOX
1
Menu: Wireless
2
Double-click wlan1
3
Tab Wireless: Mode: ap-bridge, SSID: L7-NETWORK
4
Band: 2GHz-B/G/N, Channel: 6
5
Tab Security Profiles -> edit default
6
Mode: dynamic-keys, Auth: wpa2-psk
7
WPA2 Pre-Shared Key: wifi@l7net2024!
8
Klik OK -> Apply -> OK
JANGAN: pakai WEP/WPA (sudah jebol). Selalu WPA2-PSK minimal. Password 12+ karakter.
LAYER7 PATTERN - DETEKSI APLIKASI L7 CORE

Layer7 Pattern adalah regex pattern untuk mendeteksi aplikasi berdasarkan isi packet. Pattern ini yang akan dipakai di mangle untuk mark connection.

PATTERN POPULER
APLIKASIPATTERNKETERANGAN
YouTube(^|\.)(youtube|youtu\.be|googlevideo)\.comVideo streaming Google
TikTok(^|\.)(tiktok|tiktokcdn|bytecdn)\.comShort video ByteDance
Facebook(^|\.)(facebook|fbcdn|fbsbx)\.comSocial media Meta
Instagram(^|\.)(instagram|cdninstagram)\.comFoto/video Meta
Twitter/X(^|\.)(twitter|x\.com|twimg)\.comMicroblogging
WhatsApp(^|\.)(whatsapp|whatsappcdn)\.comMessaging Meta
Telegram(^|\.)(telegram|telegramcdn)\.orgMessaging
Netflix(^|\.)(netflix|nflxvideo|nflximg)\.comVideo streaming
Spotify(^|\.)(spotify|scdn)\.comMusic streaming
Pornografi(^|\.)(xvideos|pornhub|xhamster)\.comAdult content
Judi Online(^|\.)(188bet|sbobet|bet365)\.comOnline gambling
Torrent(bittorrent|peer-to-peer|\.torrent)P2P file sharing
TIPS MEMBUAT PATTERN
PAKAI WILDCARD SUBDOMAIN
Awali dengan (^|\.). untuk match semua subdomain (m, www, api, dll).
ESCAPE TITIK
Selalu pakai \. untuk titik di domain. Titik tanpa escape = wildcard.
GROUP MULTIPLE DOMAIN
Pakai (a|b|c) untuk gabungkan beberapa domain dalam satu pattern.
TEST DI REGEX TOOL
Test pattern di regex101.com sebelum apply di MikroTik.
LIMITASI: Layer7 TIDAK BACA isi HTTPS (terenkripsi). Hanya match di SNI header. Untuk HTTPS modern, pattern mungkin tidak bekerja 100%.
MEMBUAT LAYER7 PROTOCOL L7 CORE

Buat Layer7 protocol entry di MikroTik. Entry ini berisi regex pattern yang akan dipakai untuk match traffic.

VIA CLI
# 1. Buat L7 pattern untuk YouTube [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="youtube" regexp="(^|\.)(youtube|youtu\.be|googlevideo)\.com" comment="YouTube video streaming" # 2. Buat L7 pattern untuk TikTok [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="tiktok" regexp="(^|\.)(tiktok|tiktokcdn|bytecdn)\.com" comment="TikTok short video" # 3. Buat L7 pattern untuk Facebook [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="facebook" regexp="(^|\.)(facebook|fbcdn|fbsbx)\.com" comment="Facebook social media" # 4. Buat L7 pattern untuk Instagram [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="instagram" regexp="(^|\.)(instagram|cdninstagram)\.com" comment="Instagram photo/video" # 5. Buat L7 pattern untuk streaming umum [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="streaming" regexp="(^|\.)(youtube|netflix|spotify|twitch|tiktok)\.com" comment="All streaming services" # 6. Verifikasi [admin@L7-GATEWAY] > /ip firewall layer7-protocol print # NAME REGEXP 0 youtube (^|\.)(youtube|youtu\.be|googlevideo)\.com 1 tiktok (^|\.)(tiktok|tiktokcdn|bytecdn)\.com 2 facebook (^|\.)(facebook|fbcdn|fbsbx)\.com 3 instagram (^|\.)(instagram|cdninstagram)\.com 4 streaming (^|\.)(youtube|netflix|spotify|twitch|tiktok)\.com
VIA WINBOX
1
Menu: IP -> Firewall
2
Tab Layer7 Protocol
3
+ Add entry baru
4
Name: youtube
5
Regexp: (^|\.)(youtube|youtu\.be|googlevideo)\.com
6
Comment: YouTube video streaming
7
Klik OK
8
Ulangi untuk aplikasi lain
PARAMETER LAYER7
PARAMETERFUNGSICONTOH
nameNama pattern (identifier)youtube, tiktok, facebook
regexpRegex pattern untuk match(^|\.)(youtube)\.com
commentDeskripsi (opsional)YouTube video streaming
TIPS: Batasi maksimal 5-10 pattern L7 aktif di RB941. Setiap pattern menambah beban CPU. Gabungkan beberapa aplikasi dalam satu pattern jika memungkinkan.
PATTERN APLIKASI POPULER L7 REFERENCE

Kumpulan pattern untuk aplikasi populer. Copy-paste ke Layer7 protocol.

YouTube
(^|\.)(youtube|youtu\.be|googlevideo|ytimg)\.com
Video streaming Google. Match semua subdomain youtube.com, youtu.be, googlevideo.com, ytimg.com
TikTok
(^|\.)(tiktok|tiktokcdn|bytecdn|musically)\.com
Short video ByteDance. Match tiktok.com, tiktokcdn.com, bytecdn.com, musical.ly
Facebook
(^|\.)(facebook|fbcdn|fbsbx|fb\.com)\.com
Social media Meta. Match facebook.com, fbcdn.net, fbsbx.com untuk CDN gambar/video
Instagram
(^|\.)(instagram|cdninstagram)\.com
Foto/video Meta. Match instagram.com dan cdninstagram.com untuk CDN
Twitter/X
(^|\.)(twitter|x\.com|twimg|t\.co)\.com
Microblogging. Match twitter.com, x.com, twimg.com, t.co untuk short URL
WhatsApp
(^|\.)(whatsapp|whatsappcdn|whatsapp-net)\.com
Messaging Meta. Match whatsapp.com dan CDN untuk gambar/video/voice
Telegram
(^|\.)(telegram|telegramcdn|t\.me)\.org
Messaging. Match telegram.org, telegramcdn.com, t.me
Netflix
(^|\.)(netflix|nflxvideo|nflximg|nflxext)\.com
Video streaming. Match netflix.com dan semua CDN video (nflxvideo, nflximg)
Spotify
(^|\.)(spotify|scdn|spotifycdn)\.com
Music streaming. Match spotify.com, scdn.co, spotifycdn.com
Twitch
(^|\.)(twitch|ttvnw|jtvnw)\.com
Live streaming gaming. Match twitch.com, ttvnw.net, jtvnw.net
Pornografi
(^|\.)(xvideos|pornhub|xhamster|redtube|youporn)\.com
Adult content. Block situs dewasa populer
Judi Online
(^|\.)(188bet|sbobet|bet365|betcash|judionline)\.com
Online gambling. Block situs judi online populer
Torrent
(bittorrent|peer-to-peer|\.torrent|utorrent|bitcomet)
P2P file sharing. Match protocol bittorrent dan client populer
COMBINED PATTERN
# Gabungkan beberapa aplikasi dalam 1 pattern # Lebih efisien, hemat CPU # Social Media Bundle [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="social-media" regexp="(^|\.)(facebook|instagram|twitter|x\.com|tiktok)\.com" # Streaming Bundle [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="streaming" regexp="(^|\.)(youtube|netflix|spotify|twitch|tiktok)\.com" # Messaging Bundle [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="messaging" regexp="(^|\.)(whatsapp|telegram|line|wechat)\.com" # Adult Content Bundle [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="adult" regexp="(^|\.)(xvideos|pornhub|xhamster|redtube|youporn)\.com" # Gambling Bundle [admin@L7-GATEWAY] > /ip firewall layer7-protocol add name="gambling" regexp="(^|\.)(188bet|sbobet|bet365|betcash|judionline)\.com"
TIPS: Gunakan combined pattern untuk efisiensi. Daripada buat 5 pattern terpisah untuk Facebook, Instagram, Twitter, TikTok, WhatsApp, lebih baik gabung jadi 1 pattern "social-media". Hemat CPU dan lebih mudah dikelola.
MARK CONNECTION DENGAN L7 MANGLE CORE

Mark Connection adalah step pertama di mangle. Jika packet match dengan L7 pattern, connection akan di-mark dengan nama tertentu. Connection = group packet dari source ke destination yang sama.

VIA CLI
# 1. Mark connection untuk YouTube [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark="conn-youtube" layer7-protocol="youtube" passthrough=yes comment="Mark YouTube connections" # 2. Mark connection untuk TikTok [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark="conn-tiktok" layer7-protocol="tiktok" passthrough=yes # 3. Mark connection untuk Facebook [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark="conn-facebook" layer7-protocol="facebook" passthrough=yes # 4. Mark connection untuk Instagram [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark="conn-instagram" layer7-protocol="instagram" passthrough=yes # 5. Mark connection untuk social media (combined) [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark="conn-social" layer7-protocol="social-media" passthrough=yes # 6. Verifikasi [admin@L7-GATEWAY] > /ip firewall mangle print where action="mark-connection" # CHAIN ACTION NEW-CONN-MARK L7-PROTOCOL 0 prerouting mark-connection conn-youtube youtube 1 prerouting mark-connection conn-tiktok tiktok 2 prerouting mark-connection conn-facebook facebook 3 prerouting mark-connection conn-instagram instagram 4 prerouting mark-connection conn-social social-media
VIA WINBOX
1
Menu: IP -> Firewall
2
Tab Mangle
3
+ Add rule baru
4
Tab General:
5
Chain: prerouting
6
Layer7 Protocol: youtube
7
Tab Action:
8
Action: mark-connection
9
New Connection Mark: conn-youtube
10
Passthrough: yes (WAJIB!)
11
Klik OK
12
Ulangi untuk aplikasi lain
PARAMETER MARK CONNECTION
PARAMETERFUNGSIREKOMENDASI
chainChain mangleprerouting (untuk traffic dari client)
actionAction manglemark-connection
new-connection-markNama mark connectionconn-youtube, conn-tiktok, dll
layer7-protocolL7 pattern untuk matchyoutube, tiktok, facebook, dll
passthroughLanjut ke rule berikutnyayes (WAJIB untuk mark-connection)
PENTING: PASSTHROUGH
MARK CONNECTION: PASSTHROUGH=YES
WAJIB yes! Agar packet lanjut ke rule mark-packet berikutnya. Jika no, packet stop di rule ini.
MARK PACKET: PASSTHROUGH=NO
Untuk mark-packet, set no. Agar packet tidak diproses rule mangle lain (hemat CPU).
URUTAN RULE
Mark connection HARUS di atas mark packet. Rule diproses dari atas ke bawah.
PAKAI COMMENT
Beri comment untuk setiap rule. Memudahkan troubleshooting dan dokumentasi.
PENTING: Jika passthrough=no di mark-connection, packet tidak akan lanjut ke mark-packet. Queue tree tidak akan bekerja. Selalu set passthrough=yes untuk mark-connection.
MARK PACKET BERDASARKAN CONNECTION MANGLE CORE

Mark Packet adalah step kedua. Mark packet berdasarkan connection-mark yang sudah di-set sebelumnya. Packet-mark inilah yang akan dipakai oleh queue tree.

VIA CLI
# 1. Mark packet YouTube (upload & download) # Upload (dari client ke internet) [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-youtube-up" connection-mark="conn-youtube" passthrough=no # Download (dari internet ke client) [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-youtube-down" connection-mark="conn-youtube" passthrough=no # 2. Mark packet TikTok [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-tiktok-up" connection-mark="conn-tiktok" passthrough=no [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-tiktok-down" connection-mark="conn-tiktok" passthrough=no # 3. Mark packet Facebook [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-facebook-up" connection-mark="conn-facebook" passthrough=no [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-facebook-down" connection-mark="conn-facebook" passthrough=no # 4. Mark packet Instagram [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-instagram-up" connection-mark="conn-instagram" passthrough=no [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-instagram-down" connection-mark="conn-instagram" passthrough=no # 5. Verifikasi [admin@L7-GATEWAY] > /ip firewall mangle print where action="mark-packet" # CHAIN ACTION NEW-PKT-MARK CONN-MARK 0 prerouting mark-packet pkt-youtube-up conn-youtube 1 prerouting mark-packet pkt-youtube-down conn-youtube 2 prerouting mark-packet pkt-tiktok-up conn-tiktok 3 prerouting mark-packet pkt-tiktok-down conn-tiktok 4 prerouting mark-packet pkt-facebook-up conn-facebook 5 prerouting mark-packet pkt-facebook-down conn-facebook 6 prerouting mark-packet pkt-instagram-up conn-instagram 7 prerouting mark-packet pkt-instagram-down conn-instagram
VIA WINBOX
1
Menu: IP -> Firewall -> Mangle
2
+ Add rule baru
3
Tab General:
4
Chain: prerouting
5
Connection Mark: conn-youtube
6
Tab Action:
7
Action: mark-packet
8
New Packet Mark: pkt-youtube-up
9
Passthrough: no
10
Klik OK
11
Ulangi untuk download dan aplikasi lain
PARAMETER MARK PACKET
PARAMETERFUNGSIREKOMENDASI
chainChain mangleprerouting
actionAction manglemark-packet
new-packet-markNama packet markpkt-youtube-up, pkt-youtube-down
connection-markConnection mark sumberconn-youtube, conn-tiktok, dll
passthroughLanjut ke rule berikutnyano (hemat CPU)
TIPS MARK PACKET
PISAH UPLOAD & DOWNLOAD
Buat packet-mark terpisah untuk upload dan download. Queue tree bisa limit berbeda.
PASSTHROUGH=NO
Set no agar packet tidak diproses rule mangle lain. Hemat CPU.
NAMING CONSISTENT
Pakai pola konsisten: pkt-{app}-{direction}. Contoh: pkt-youtube-up, pkt-youtube-down.
URUTAN RULE
Mark connection di atas, mark packet di bawah. Rule diproses dari atas ke bawah.
TIPS: Setelah mark packet selesai, packet-mark siap dipakai di queue tree. Queue tree akan apply limit/block berdasarkan packet-mark ini.
QUEUE TREE - LIMIT & BLOCK QUEUE CORE

Queue Tree apply action berdasarkan packet-mark. Bisa limit bandwidth, block traffic, atau beri priority. Queue tree bekerja di hierarki parent-child.

VIA CLI
# 1. Parent queue (total bandwidth) [admin@L7-GATEWAY] > /queue tree add name="total-global" parent=global max-limit="45M/48M" comment="Total bandwidth" # 2. Queue YouTube (LIMIT 2M/5M) [admin@L7-GATEWAY] > /queue tree add name="youtube-upload" parent="total-global" packet-mark="pkt-youtube-up" max-limit="2M" priority=8 [admin@L7-GATEWAY] > /queue tree add name="youtube-download" parent="total-global" packet-mark="pkt-youtube-down" max-limit="5M" priority=8 # 3. Queue TikTok (LIMIT 1M/3M) [admin@L7-GATEWAY] > /queue tree add name="tiktok-upload" parent="total-global" packet-mark="pkt-tiktok-up" max-limit="1M" priority=8 [admin@L7-GATEWAY] > /queue tree add name="tiktok-download" parent="total-global" packet-mark="pkt-tiktok-down" max-limit="3M" priority=8 # 4. Queue Facebook (LIMIT 3M/5M) [admin@L7-GATEWAY] > /queue tree add name="facebook-upload" parent="total-global" packet-mark="pkt-facebook-up" max-limit="3M" priority=7 [admin@L7-GATEWAY] > /queue tree add name="facebook-download" parent="total-global" packet-mark="pkt-facebook-down" max-limit="5M" priority=7 # 5. Queue Instagram (LIMIT 3M/5M) [admin@L7-GATEWAY] > /queue tree add name="instagram-upload" parent="total-global" packet-mark="pkt-instagram-up" max-limit="3M" priority=7 [admin@L7-GATEWAY] > /queue tree add name="instagram-download" parent="total-global" packet-mark="pkt-instagram-down" max-limit="5M" priority=7 # 6. Verifikasi [admin@L7-GATEWAY] > /queue tree print # NAME PARENT PACKET-MARK MAX-LIMIT 0 total-global global 48M/45M 1 youtube-upload total-global pkt-youtube-up 2M 2 youtube-download total-global pkt-youtube-down 5M 3 tiktok-upload total-global pkt-tiktok-up 1M 4 tiktok-download total-global pkt-tiktok-down 3M 5 facebook-upload total-global pkt-facebook-up 3M 6 facebook-download total-global pkt-facebook-down 5M 7 instagram-upload total-global pkt-instagram-up 3M 8 instagram-download total-global pkt-instagram-down 5M
VIA WINBOX
1
Menu: Queues -> Queue Tree
2
+ Add parent queue
3
Name: total-global, Parent: global
4
Max Limit: 45M/48M
5
Klik OK
6
+ Add child queue untuk YouTube
7
Name: youtube-download
8
Parent: total-global
9
Packet Mark: pkt-youtube-down
10
Max Limit: 5M, Priority: 8
11
Klik OK
12
Ulangi untuk aplikasi lain
PARAMETER QUEUE TREE
PARAMETERFUNGSICONTOH
nameNama queueyoutube-download, tiktok-upload
parentParent queue (hierarki)total-global, global
packet-markPacket mark sumberpkt-youtube-down
limit-atBandwidth dijamin (guaranteed)2M
max-limitBandwidth maksimal5M
priorityPrioritas (1-8, 1 tertinggi)8 (terendah untuk sosmed)
queueAlgoritma queuepcq-upload-default/pcq-download-default
STRATEGI LIMIT
YOUTUBE: 2M/5M
Upload kecil (komentar, like), download besar (video streaming). Priority 8 (rendah).
TIKTOK: 1M/3M
Limit ketat. Upload kecil, download video pendek. Priority 8.
FACEBOOK/IG: 3M/5M
Limit sedang. Upload foto/video, download feed. Priority 7 (sedang).
PRIORITY
1-3 untuk browsing/kerja, 4-6 untuk streaming, 7-8 untuk sosmed. Saat bandwidth penuh, priority tinggi dapat jatah duluan.
TIPS: Total limit child queue tidak harus sama dengan parent. RouterOS akan bagi bandwidth parent ke child sesuai limit-at (guaranteed). Jika bandwidth parent cukup, child dapat sesuai max-limit.
BLOCKING APLIKASI L7 ACTION

Selain limit, Layer7 juga bisa dipakai untuk block aplikasi tertentu. Contoh: block pornografi, judi online, torrent.

VIA CLI
# CARA 1: Block via firewall filter + L7 [admin@L7-GATEWAY] > /ip firewall filter add chain=forward action=drop layer7-protocol="adult" comment="Block pornografi" [admin@L7-GATEWAY] > /ip firewall filter add chain=forward action=drop layer7-protocol="gambling" comment="Block judi online" [admin@L7-GATEWAY] > /ip firewall filter add chain=forward action=drop layer7-protocol="torrent" comment="Block torrent" # CARA 2: Block via mangle + queue tree drop # Mark connection [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark="conn-block" layer7-protocol="adult" passthrough=yes # Mark packet [admin@L7-GATEWAY] > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-block" connection-mark="conn-block" passthrough=no # Queue tree drop [admin@L7-GATEWAY] > /queue tree add name="block-queue" parent=global packet-mark="pkt-block" max-limit="1k/1k" # Limit 1kbps = effectively block # Verifikasi [admin@L7-GATEWAY] > /ip firewall filter print where layer7-protocol!=""
VIA WINBOX
1
Menu: IP -> Firewall
2
Tab Filter Rules
3
+ Add rule baru
4
Tab General:
5
Chain: forward
6
Layer7 Protocol: adult
7
Tab Action:
8
Action: drop
9
Comment: Block pornografi
10
Klik OK
11
Ulangi untuk gambling, torrent
APLIKASI YANG BISA DI-BLOCK
KATEGORIL7 PATTERNAKSI
PornografiadultDROP
Judi OnlinegamblingDROP
Torrent/P2PtorrentDROP
YouTubeyoutubeLIMIT atau DROP
TikToktiktokLIMIT atau DROP
FacebookfacebookLIMIT atau DROP
InstagraminstagramLIMIT atau DROP
DROP vs LIMIT
DROP (BLOCK TOTAL)
Packet dibuang, tidak sampai ke tujuan. User tidak bisa akses sama sekali. Cocok untuk konten terlarang.
LIMIT (BATASI BANDWIDTH)
Packet sampai tapi dibatasi speed. User masih bisa akses tapi lambat. Cocok untuk mengontrol penggunaan.
TIME-BASED
Block hanya di jam tertentu. Contoh: block YouTube jam kerja (08:00-17:00), bebas di luar jam kerja.
USER-SPECIFIC
Block/limit hanya untuk user tertentu. Contoh: block TikTok untuk user A, tapi tidak untuk user B.
LIMITASI: Layer7 tidak bisa block HTTPS 100%. Untuk block HTTPS modern, kombinasikan dengan DNS filtering (block domain) atau IP address-list (block IP server).
LIMITING BANDWIDTH PER APLIKASI L7 ACTION

Selain block, Layer7 bisa dipakai untuk limit bandwidth per aplikasi. Contoh: limit YouTube max 5Mbps, TikTok max 3Mbps.

CONTOH LIMIT PER APLIKASI
APLIKASIUPLOADDOWNLOADPRIORITYALASAN
YouTube2M5M8Video streaming butuh bandwidth besar
TikTok1M3M8Video pendek, limit ketat
Facebook3M5M7Social media, limit sedang
Instagram3M5M7Foto/video, limit sedang
WhatsApp2M2M3Messaging, priority tinggi
Browsing5M10M3Kerja/belajar, priority tinggi
Streaming Music1M2M5Audio streaming, limit kecil
IMPLEMENTASI LIMIT
# Limit YouTube 5Mbps download [admin@L7-GATEWAY] > /queue tree add name="youtube-download" parent="total-global" packet-mark="pkt-youtube-down" limit-at="2M" max-limit="5M" priority=8 queue="pcq-download-default" # Limit TikTok 3Mbps download [admin@L7-GATEWAY] > /queue tree add name="tiktok-download" parent="total-global" packet-mark="pkt-tiktok-down" limit-at="1M" max-limit="3M" priority=8 # Limit WhatsApp 2Mbps (priority tinggi) [admin@L7-GATEWAY] > /queue tree add name="whatsapp-all" parent="total-global" packet-mark="pkt-whatsapp" limit-at="1M" max-limit="2M" priority=3 # Browsing priority tinggi [admin@L7-GATEWAY] > /queue tree add name="browsing-all" parent="total-global" packet-mark="pkt-browsing" limit-at="5M" max-limit="10M" priority=3
LIMIT-AT vs MAX-LIMIT
LIMIT-AT (GUARANTEED)
Bandwidth dijamin. Saat bandwidth penuh, aplikasi ini dapat minimal limit-at. Penting untuk VoIP, video call.
MAX-LIMIT (CEILING)
Bandwidth maksimal. Aplikasi tidak bisa melebihi max-limit. Saat bandwidth cukup, dapat sampai max-limit.
PCQ (FAIR SHARING)
Pakai queue type PCQ untuk fair sharing. Jika ada banyak user, bandwidth dibagi rata per connection.
PRIORITY
1-3 = prioritas tinggi (kerja, VoIP). 4-6 = sedang (streaming). 7-8 = rendah (sosmed, download).
TIPS: Untuk aplikasi penting (VoIP, video call, browsing kerja), beri limit-at + priority tinggi. Untuk aplikasi hiburan (YouTube, TikTok, sosmed), beri max-limit + priority rendah.
MONITORING LAYER7 MONITOR

Monitor performa Layer7: hit count, bandwidth per aplikasi, CPU load, dll.

VIA CLI
# 1. Cek hit count mangle [admin@L7-GATEWAY] > /ip firewall mangle print stats # CHAIN ACTION BYTES PACKETS 0 prerouting mark-connection 1.2GB 154320 1 prerouting mark-packet 1.2GB 154320 # 2. Cek queue tree usage [admin@L7-GATEWAY] > /queue tree print stats # NAME RATE BYTES 0 total-global 25M/30M 15GB 1 youtube-download 3.5M 2.5GB 2 tiktok-download 1.2M 800MB 3 facebook-download 2.1M 1.5GB # 3. Cek CPU load [admin@L7-GATEWAY] > /system resource print cpu-load: 45% free-memory: 8192KiB # 4. Monitor real-time [admin@L7-GATEWAY] > /tool torch interface=ether1 # SRC-ADDRESS DST-ADDRESS PROTO BYTES 0 192.168.10.100 142.250.x.x tcp 1.2MB 1 192.168.10.101 31.13.x.x tcp 450KB # 5. Cek log [admin@L7-GATEWAY] > /log print where topics="firewall"
VIA WINBOX
1
Menu: IP -> Firewall -> Mangle
2
Lihat kolom Bytes dan Packets
3
Menu: Queues -> Queue Tree
4
Lihat kolom Rate (bandwidth real-time)
5
Menu: System -> Resources
6
Cek CPU Load (jangan >80%)
7
Menu: Tools -> Torch
8
Monitor traffic per IP real-time
9
Menu: Tools -> Graphing
10
Lihat grafik bandwidth historis
METRIK YANG PERLU DIMONITOR
METRIKCARA CEKKETERANGAN
CPU Load/system resource printJangan >80% dengan L7 aktif
Memory Usage/system resource printFree memory harus cukup
Mangle Hit Count/ip firewall mangle print statsBerapa packet yang di-mark
Queue Rate/queue tree print statsBandwidth per aplikasi
Total Bandwidth/interface printTraffic per interface
Active Connections/ip firewall connection print count-onlyJumlah koneksi aktif
TIPS MONITORING
GRAPHING
Aktifkan graphing untuk lihat grafik bandwidth historis. Berguna untuk analisis pola penggunaan.
ALERT CPU
Script untuk notifikasi jika CPU >80%. Bisa kirim email/Telegram alert.
LOGGING
Log semua aktivitas mangle dan queue tree. Berguna untuk troubleshooting dan audit.
NETWATCH
Monitor connectivity ke server tertentu. Jika down, bisa trigger script otomatis.
PERINGATAN: Jika CPU load >80% konsisten, kurangi jumlah pattern L7 atau upgrade hardware. Layer7 sangat CPU intensive, terutama dengan banyak pattern aktif.
TROUBLESHOOTING LAYER7 SUPPORT

Masalah umum Layer7 dan solusinya.

LAYER7 TIDAK DETEKSI APLIKASI
KEMUNGKINAN PENYEBAB:
1. Pattern regex salah - test di regex101.com
2. Aplikasi pakai HTTPS (L7 tidak bisa baca isi encrypted)
3. Pattern tidak match dengan domain yang dipakai aplikasi
4. L7 protocol belum di-assign ke mangle rule
5. Mangle rule di chain yang salah (harus prerouting)
SOLUSI: Cek pattern regex. Untuk HTTPS, pakai DNS filtering atau IP address-list sebagai alternatif.
CPU OVERLOAD (>80%)
KEMUNGKINAN PENYEBAB:
1. Terlalu banyak pattern L7 aktif (>10 untuk RB941)
2. Regex pattern terlalu kompleks (backtracking)
3. Banyak client concurrent dengan traffic tinggi
4. RB941 tidak cukup powerful untuk workload
SOLUSI: Kurangi pattern L7. Sederhanakan regex. Gabungkan pattern. Upgrade hardware jika perlu.
QUEUE TREE TIDAK BEKERJA
KEMUNGKINAN PENYEBAB:
1. Packet-mark tidak ada atau salah nama
2. Mangle rule tidak mark packet (passthrough=no di mark-connection)
3. Queue tree parent salah
4. Queue tree disabled
5. Chain mangle salah (harus prerouting)
SOLUSI: Cek mangle mark packet ada. Cek passthrough=yes di mark-connection. Cek nama packet-mark match.
BLOCKING TIDAK BEKERJA
KEMUNGKINAN PENYEBAB:
1. Firewall filter rule di chain yang salah (harus forward)
2. Rule di bawah rule accept established (harus di atas)
3. L7 pattern tidak match
4. Aplikasi pakai HTTPS (L7 tidak bisa block HTTPS)
SOLUSI: Cek chain=forward. Cek urutan rule (L7 block di atas accept established). Untuk HTTPS, pakai DNS filtering.
LIMIT BANDWIDTH TIDAK AKURAT
KEMUNGKINAN PENYEBAB:
1. Parent queue max-limit terlalu kecil
2. Total limit-at child melebihi parent
3. Priority tidak di-set dengan benar
4. PCQ tidak di-configure dengan benar
SOLUSI: Cek parent max-limit cukup. Cek limit-at child tidak melebihi parent. Set priority sesuai kebutuhan.
INTERNET LAMBAT SETELAH AKTIFKAN L7
KEMUNGKINAN PENYEBAB:
1. CPU overload karena L7 inspection
2. Terlalu banyak pattern L7 aktif
3. RB941 tidak cukup powerful
4. Queue tree limit terlalu ketat
SOLUSI: Cek CPU load. Kurangi pattern L7. Upgrade hardware. Relax limit queue tree.
DIAGNOSTIC COMMANDS
# Cek semua komponen L7 > /ip firewall layer7-protocol print > /ip firewall mangle print > /ip firewall filter print > /queue tree print # Cek hit count > /ip firewall mangle print stats # Cek CPU & memory > /system resource print # Monitor traffic > /tool torch interface=ether1 > /tool traffic-monitor interface=ether1 # Cek log > /log print where topics="firewall" # Test connectivity > /ping 8.8.8.8 > /ping google.com
BEST PRACTICE LAYER7 TIPS
BATASI PATTERN L7
Maksimal 5-10 pattern L7 aktif di RB941. Setiap pattern menambah beban CPU.
GABUNG PATTERN
Gabungkan beberapa aplikasi dalam 1 pattern. Lebih efisien daripada pattern terpisah.
SIMPLIFY REGEX
Regex sederhana lebih cepat. Hindari nested groups, excessive quantifiers.
MONITOR CPU
Cek CPU load rutin. Jika >80%, kurangi pattern atau upgrade hardware.
TEST DI LAB
Test pattern dan rule di lab environment sebelum production. Hemat waktu troubleshooting.
DOCUMENTATION
Dokumentasikan semua pattern, mangle rule, queue tree. Untuk referensi dan troubleshooting.
ALTERNATIF UNTUK HTTPS
Untuk block HTTPS modern, pakai DNS filtering + IP address-list. Lebih efektif dari L7.
UPGRADE HARDWARE
Jika butuh L7 intensif, upgrade ke hAP ac^2 (717MHz, 128MB) atau CCR series.
BACKUP CONFIG
Backup config sebelum ubah rule L7. Jika ada masalah, bisa restore dengan cepat.
UPDATE ROUTEROS
Update ke versi stable terbaru untuk patch keamanan dan perbaikan bug L7.
PASSTHROUGH CORRECT
Mark connection: passthrough=yes. Mark packet: passthrough=no. WAJIB benar!
URUTAN RULE
Mark connection di atas mark packet. L7 block di atas accept established.
LAYER7 CHEATSHEET QUICK REF
LAYER7 COMMANDS
# LAYER7 PROTOCOL > /ip firewall layer7-protocol add name="youtube" regexp="(^|\.)(youtube|youtu\.be|googlevideo)\.com" # MANGLE - MARK CONNECTION > /ip firewall mangle add chain=prerouting action=mark-connection new-connection-mark="conn-youtube" layer7-protocol="youtube" passthrough=yes # MANGLE - MARK PACKET > /ip firewall mangle add chain=prerouting action=mark-packet new-packet-mark="pkt-youtube-down" connection-mark="conn-youtube" passthrough=no # QUEUE TREE - LIMIT > /queue tree add name="youtube-download" parent="total-global" packet-mark="pkt-youtube-down" max-limit="5M" priority=8 # FIREWALL FILTER - BLOCK > /ip firewall filter add chain=forward action=drop layer7-protocol="adult" comment="Block porn" # MONITORING > /ip firewall layer7-protocol print > /ip firewall mangle print stats > /queue tree print stats > /system resource print # BACKUP > /system backup save name="l7-backup" > /export file="l7-config"
ABDURROZAK.MY.ID // JARINGAN SOSIAL

s.id

Link Tree Utama

GitHub

Repositori Kode

Instagram

Galeri Visual

Threads

Diskusi Ringkas

Facebook

Jaringan Sosial

TikTok

Konten Video Pendek

YT Teacher

Edukasi & Tutorial

YT Course

Materi Pembelajaran

YT Studio

Produksi Konten

Hashnode

Artikel Teknis

WhatsApp

Komunikasi Langsung

Email

abdurrozak.skom@gmail.com