Koleksi Script PPPoE MikroTik
Kumpulan perintah terminal untuk PPPoE pada router MikroTik Anda.
1. Update IP PPPoE pada semua secret PPPoE yang sudah ada
Terminal Winbox
{
:local localIp "192.168.50.1";
:local prefixIp "192.168.50.";
:local startOctet 2;
:log info "Memulai proses update IP PPPoE Secret...";
:foreach user in=[/ppp secret find] do={
:if ($startOctet <= 254) do={
:local remoteIp ($prefixIp . $startOctet);
/ppp secret set $user local-address=$localIp remote-address=$remoteIp;
:set startOctet ($startOctet + 1);
} else={
:log warning "Update dihentikan: Alokasi IP sudah mencapai batas maksimal (192.168.50.254).";
}
}
:log info "Proses update IP PPPoE Secret selesai.";
/ppp active remove [find]
}
2. Mengubah Semua User PPPoE ke Profil 100K
Terminal Winbox
/ppp secret
:foreach i in=[find] do={
set $i profile="100K"
}
/ppp active remove [find]
3. Set untuk Password PPPoE sama semua
Terminal Winbox
/ppp secret set [find service=pppoe] password="12345" /ppp active remove [find]
4. Set untuk Password PPPoE sama dengan User
Terminal Winbox
/ppp secret :foreach i in=[find service=pppoe] do={set $i password=[get $i name]}
/ppp active remove [find]
5. Menghapus semua local-address dan remote-address (PPPoE)
Terminal Winbox
/ppp secret set [find] local-address="" remote-address="" /ppp active remove [find]
6. Script Proses-Isolir
Terminal Winbox
/system script add name="Proses-Isolir" source="
# Script Isolir Pelanggan PPPoE berdasarkan Komentar
:local commentTag \"BELUM LUNAS\";
:local isolirProfile \"ISOLIR\";
:foreach secretId in=[/ppp secret find comment=\$commentTag] do={
:local username [/ppp secret get \$secretId name];
# 1. Ubah profil pelanggan menjadi ISOLIR
/ppp secret set \$secretId profile=\$isolirProfile;
# 2. Cari pelanggan di tab Active
:local activeId [/ppp active find name=\$username];
# 3. Jika pelanggan sedang online, kick dari aktif
:if ([:len \$activeId] > 0) do={
/ppp active remove \$activeId;
:log warning message=(\"PPPoE Isolir: Pelanggan \" . \$username . \" ditendang (kick) karena status Belum Lunas.\");
} else={
:log info message=(\"PPPoE Isolir: Profil pelanggan \" . \$username . \" diubah ke Isolir (Status Offline).\");
}
}
:log info message=\"Proses pengecekan pelanggan BELUM LUNAS selesai.\";
"
7. Script Isolir Otomatis via Terminal
Terminal Winbox
:foreach i in=[/ppp secret find comment="BELUM LUNAS"] do={:local u [/ppp secret get $i name]; /ppp secret set $i profile="ISOLIR"; /ppp active remove [find name=$u]}
8. Scheduler Isolir 1 Hari
Terminal Winbox
/system scheduler
add name="Auto-Kick-Isolir" interval=1d start-time=01:00:00 on-event="{
:foreach i in=[/ppp secret find profile=\"ISOLIR\"] do={
:local u [/ppp secret get \$i name];
:local a [/ppp active find name=\$u];
:if ([:len \$a] > 0) do={
/ppp active remove \$a;
:log warning message=(\"Auto Kick Harian: \" . \$u . \" diputus (Profil ISOLIR)\");
}
}
}" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive
9. Scripts Kick-Active-Isolir
Terminal Winbox
/system script add name="Kick-Active-Isolir" policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source={
:foreach secretId in=[/ppp secret find profile="ISOLIR"] do={
:local username [/ppp secret get $secretId name];
:local activeId [/ppp active find name=$username];
:if ([:len $activeId] > 0) do={
/ppp active remove $activeId;
:log warning message=("PPPoE Kick: Pelanggan " . $username . " (Profil ISOLIR) diputus paksa dari sesi aktif.");
}
}
:log info message="Eksekusi kick pelanggan ISOLIR selesai.";
}