MIKROTIK / OTOMASI & VPN

Expired Otomatis (PPPoE & Hotspot)

Pelanggan PPPoE diisolir otomatis di tanggal jatuh tempo dan dibuka lagi setelah tanggal diperpanjang; voucher hotspot habis setelah masa aktifnya.

PANDUAN Cara memakai Expired Otomatis (PPPoE & Hotspot)

Tidak perlu lagi mengisolir pelanggan satu per satu setiap tanggal tagihan, atau menghapus voucher hotspot yang masa aktifnya habis.

SEBELUM MULAI

  • Jam & tanggal router harus benar (generator Jam & NTP).
  • PPPoE + isolir: pasang dulu generator Isolir Pelanggan (profil ISOLIR).
  • Hotspot: user profile per paket sudah ada (mis. 1hari, 7hari, 30hari).

CARA MENGISI

  • PPPoE: isi tanggal isolir tiap pelanggan di kolom Atur tanggal, atau tulis exp:2026-12-25 di comment secret.
  • Hotspot: daftar user profile dan masa aktifnya.

SETELAH SCRIPT DIJALANKAN

  • PPPoE: setelah pelanggan bayar, ganti tanggalnya (exp: di comment) ke bulan depan. Paling lambat 1 jam kemudian profil lama kembali otomatis; atau jalankan /system script run sk-expired-ppp.
  • Hotspot: comment user berisi exp:<tanggal>/<jam> setelah login pertama.
  • System > Scripts & Scheduler: sk-expired-*.
Baru pertama kali? Cara menempel script ke MikroTik & arti istilah

HASIL / SCRIPT

Expired Otomatis (PPPoE & Hotspot)

    # ===================================================
    #  EXPIRED OTOMATIS PPPoE
    #  Dibuat 2026-11-25 oleh SatuKonfig (satukonfig.com)
    #  Tempel di Winbox > New Terminal (RouterOS v6 & v7)
    # ===================================================
    
    # --- script cek jatuh tempo (dijalankan tiap jam) ---
    /system script add name=sk-expired-ppp source=":local skHari do={ :local y; :local m; :local d; :if ([:pick \$t 4 5] = \"-\") do={ :set y [:tonum [:pick \$t 0 4]]; :set m [:pick \$t 5 7]; :set d [:pick \$t 8 10] } else={ :set m ([:find \"janfebmaraprmayjunjulaugsepoctnovdec\" [:pick \$t 0 3]] / 3 + 1); :set d [:pick \$t 4 6]; :set y [:tonum [:pick \$t 7 11]] }; :if ([:typeof \$m] = \"str\") do={ :if ([:pick \$m 0 1] = \"0\") do={ :set m [:pick \$m 1 2] }; :set m [:tonum \$m] }; :if ([:pick \$d 0 1] = \"0\") do={ :set d [:pick \$d 1 2] }; :set d [:tonum \$d]; :if (\$m <= 2) do={ :set y (\$y - 1) }; :local era (\$y / 400); :local yoe (\$y - \$era * 400); :local mp (\$m + 9); :if (\$m > 2) do={ :set mp (\$m - 3) }; :local doy ((153 * \$mp + 2) / 5 + \$d - 1); :return (\$era * 146097 + \$yoe * 365 + \$yoe / 4 - \$yoe / 100 + \$doy - 719468) }; :if ([:len [/ppp profile find name=\"ISOLIR\"]] = 0) do={ :log error \"SatuKonfig expired: profil ISOLIR belum ada, pasang generator Isolir Pelanggan dulu\"; :error \"profil ISOLIR belum ada\" }; :local now [\$skHari t=[/system clock get date]]; :local off \"\"; :local back \"\"; :foreach s in=[/ppp secret find where comment~\"exp:\"] do={ :local c [/ppp secret get \$s comment]; :local u [/ppp secret get \$s name]; :local p [:find \$c \"exp:\"]; :local e [\$skHari t=[:pick \$c (\$p + 4) (\$p + 14)]]; :local pv [:find \$c \" prev:\"]; :if (\$now >= \$e) do={ :local pr [/ppp secret get \$s profile]; :if (([:typeof \$pv] = \"nil\") && (\$pr != \"ISOLIR\")) do={ /ppp secret set \$s profile=\"ISOLIR\" comment=(\$c . \" prev:\" . \$pr); /ppp active remove [/ppp active find name=\$u]; :set off (\$off . \" \" . \$u) } }; :if ((\$now < \$e) && ([:typeof \$pv] = \"num\")) do={ /ppp secret set \$s profile=[:pick \$c (\$pv + 6) [:len \$c]] comment=[:pick \$c 0 \$pv]; /ppp active remove [/ppp active find name=\$u]; :set back (\$back . \" \" . \$u) } }; :if ([:len \$off] > 0) do={ :log info (\"SatuKonfig expired: diisolir\" . \$off) }; :if ([:len \$back] > 0) do={ :log info (\"SatuKonfig expired: dibuka lagi\" . \$back) }" comment="SatuKonfig expired:"
    /system scheduler add name=sk-expired-ppp start-time=00:05:00 interval=1h on-event=sk-expired-ppp comment="SatuKonfig expired:"
    
    # --- atur tanggal isolir pelanggan (exp: lama diganti, comment lain tetap) ---
    :do { :local s [/ppp secret find name="budi"]; :local c [/ppp secret get $s comment]; :local p [:find $c "exp:"]; :if ([:typeof $p] = "num") do={ :set c ([:pick $c 0 $p] . [:pick $c ($p + 15) [:len $c]]) }; :if ([:len $c] > 0) do={ :set c (" " . $c) }; /ppp secret set $s comment=("exp:2026-12-25" . $c) } on-error={ :put "budi: secret tidak ditemukan" }
    
    # --- jalankan sekali sekarang ---
    /system script run sk-expired-ppp

    Contoh isian di form hanya contoh; sesuaikan dengan jaringan Anda. Backup dulu sebelum menempel: /system backup save name=sebelum-satukonfig. Cara lengkap ada di Panduan di atas.