Disable otomatis pelanggan yang telat bayar
skrip disable otomatis pelanggan yang telat bayar. Jadi kalau lewat jatuh tempo, speed mereka diturunkan jadi 512Kbps/512Kbps (bisa disesuaikan).
Cek Jatuh Tempo dari due:DD/MM/YYYY
contoh Comment winbox "nama:Bu Dedeh; paket:Unlimited; harga:100000; due:01/08/2025; no_hp:0123456789; iface:pppoe-brige3-3; Usage:2.35 GB"
🔧 Skrip Cek Jatuh Tempo + Potong
Speed
/system script
add name=cek_jatuh_tempo source={
:log info "📆 Cek jatuh tempo pelanggan (format due)..."
# === Ambil tanggal hari ini ===
:local d [/system clock get date]
:local bulan [:pick $d 0 3]
:local hari [:pick $d 4 6]
:local tahun [:pick $d 7 11]
:local bln ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
:local bulan_num ([:find $bln $bulan] + 1)
:if ($bulan_num < 10) do={ :set bulan_num ("0".$bulan_num) }
:local today ($hari."/".$bulan_num."/".$tahun)
/queue simple
:foreach i in=[find] do={
:local cmt [get $i comment]
:if ([:len $cmt] = 0) do={ :continue }
:local p [:find $cmt "due:"]
:if ($p = nil) do={ :continue }
# Ambil tanggal due (DD/MM/YYYY)
:local due [:pick $cmt ($p + 4) ($p + 14)]
:if ($due = $today) do={
:log warning ("⏰ JATUH TEMPO: ".$cmt)
# Potong speed
:if ([get $i max-limit] != "512k/512k") do={
set $i max-limit=512k/512k
}
}
}
}
⏰ SCHEDULER (WAJIB BIAR OTOMATIS)
🔄 Restore Speed Setelah Bayar
Kalau
pelanggan sudah bayar:
- Edit queue pelanggan.
- Kembalikan max-limit sesuai paket (misalnya 20M/20M).
- Ubah juga jatuh_tempo
ke bulan berikutnya di comment.
Contoh
update comment setelah bayar:
/queue simple
set Bu Dedeh_192.168.88.10
comment="nama:Bu Dedeh; paket:Unlimited; harga:100000; due:01/08/2025; no_hp:087762046511; iface:pppoe-brige3-3; Usage:2.35"
set Bu Dedeh_192.168.88.10 max-limit=20M/20M
⚡ Jadi alurnya:
- Hari H jatuh tempo → speed
otomatis dipotong ke 512Kbps.
- Setelah bayar → admin update
tanggal + restore speed normal.
Opsi
auto-disable koneksi (block access total) selain dipotong speed, supaya bisa pilih model
hukuman pelanggan yang telat bayar.
Oke 👍, saya
buatkan 2 opsi hukuman pelanggan di Mikrotik kalau lewat jatuh tempo
bulanan:
🔧 1. Opsi Potong Speed (sudah ada)
Speed
diturunkan jadi 512K/512K. (sudah saya kasih skrip ).
🔧 2. Opsi Block Total Internet
Kalau
lewat jatuh tempo → akses internet diputus, diarahkan ke halaman informasi
(misalnya portal lokal atau pesan bayar tagihan).
Skrip Block Total:
/system script
add name=cek_jatuh_tempo_block source={
:log info "🚫 Cek jatuh tempo (BLOCK TOTAL)..."
# === Ambil tanggal hari ini ===
:local d [/system clock get date]
:local bulan [:pick $d 0 3]
:local hari [:pick $d 4 6]
:local tahun [:pick $d 7 11]
:local bln ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec")
:local bulan_num ([:find $bln $bulan] + 1)
:if ($bulan_num < 10) do={ :set bulan_num ("0".$bulan_num) }
:local today ($hari."/".$bulan_num."/".$tahun)
# Bersihkan list blokir lama
/ip firewall address-list remove [find list="blokir"]
/queue simple
:foreach i in=[find] do={
:local cmt [get $i comment]
:if ([:len $cmt] = 0) do={ :continue }
:local p [:find $cmt "due:"]
:if ($p = nil) do={ :continue }
:local due [:pick $cmt ($p + 4) ($p + 14)]
:if ($due = $today) do={
:local target [get $i target]
:log warning ("🚫 TELAT BAYAR → BLOCK: ".$cmt)
/ip firewall address-list add \
list=blokir \
address=$target \
timeout=0
}
}
}
🔥 FIREWALL RULE (WAJIB)
Pasang di atas rule allow internet:
⏰ SCHEDULER (BIAR OTOMATIS)
🔄 Restore Setelah Bayar
- Hapus IP pelanggan dari address-list=blokir.
- Update comment jatuh_tempo ke bulan depan.
SCRIPT RESTORE SETELAH BAYAR
Script ini:
-
Cari queue berdasarkan IP / target
-
Hapus dari address-list
blokir -
Ganti
due:ke bulan depan -
Log biar kelihatan di Winbox
📜 Script MikroTik
🎯 TUJUAN AKHIR
Dari Flask (web admin):
-
klik “Bayar”
-
Flask:
-
Hapus IP dari
address-list=blokir -
Update
duedi comment queue
-
-
MikroTik eksekusi real-time
1️⃣ AKTIFKAN API DI MIKROTIK (WAJIB)
Masuk Winbox → IP → Services
Pastikan:
Boleh juga pakai api-ssl (8729), tapi kita mulai yang simpel dulu.
2️⃣ BUAT USER KHUSUS API (AMAN)
Di Winbox → System → Users
Buat user baru:
Komentar
Posting Komentar