Cek IP Dinamis: Difference between revisions

From AbahDoku Wiki
No edit summary
No edit summary
Line 1: Line 1:
  :local dnsName "cctv.bele.net";
  :local dnsName "nama.dns.net";
  :local hotspotHostAddress [/ip hotspot ip-binding get [find comment="cctv.bele.net"] address];
  :local hotspotHostAddress [/ip hotspot ip-binding get [find comment="nama.dns.net"] address];
  :local dnsStaticValue [/ip dns static get [find name="cctv.bele.net"] address];
  :local dnsStaticValue [/ip dns static get [find name="cctv.bele.net"] address];
  :local bot "BOOT_TOKEN";
  :local bot "BOOT_TOKEN";
Line 6: Line 6:
  :if ($hotspotHostAddress != $dnsStaticValue) do={
  :if ($hotspotHostAddress != $dnsStaticValue) do={
   /ip dns static set [find name="cctv.bele.net"] address=$hotspotHostAddress
   /ip dns static set [find name="cctv.bele.net"] address=$hotspotHostAddress
   :local message "IP pada DNS statis telah berubah menjadi $hotspotHostAddress"
   :local message "IP pada DNS statis $dnsName telah berubah menjadi $hotspotHostAddress"
   /tool fetch url=("https://api.telegram.org/bot$bot/sendMessage\?chat_id=$chatID&text=$message") keep-result=no
   /tool fetch url=("https://api.telegram.org/bot$bot/sendMessage\?chat_id=$chatID&text=$message") keep-result=no
  } else={
  } else={
   :local message "IP DNS statis tidak berubah: $hotspotHostAddress"
   :local message "IP DNS statis $dnsName tidak berubah: $hotspotHostAddress"
   /tool fetch url=("https://api.telegram.org/bot$bot/sendMessage\?chat_id=$chatID&text=$message") keep-result=no
   /tool fetch url=("https://api.telegram.org/bot$bot/sendMessage\?chat_id=$chatID&text=$message") keep-result=no
  }
  }

Revision as of 09:31, 13 June 2023

:local dnsName "nama.dns.net";
:local hotspotHostAddress [/ip hotspot ip-binding get [find comment="nama.dns.net"] address];
:local dnsStaticValue [/ip dns static get [find name="cctv.bele.net"] address];
:local bot "BOOT_TOKEN";
:local chatID "CHAT_ID";
:if ($hotspotHostAddress != $dnsStaticValue) do={
 /ip dns static set [find name="cctv.bele.net"] address=$hotspotHostAddress
 :local message "IP pada DNS statis $dnsName telah berubah menjadi $hotspotHostAddress"
 /tool fetch url=("https://api.telegram.org/bot$bot/sendMessage\?chat_id=$chatID&text=$message") keep-result=no
} else={
 :local message "IP DNS statis $dnsName tidak berubah: $hotspotHostAddress"
 /tool fetch url=("https://api.telegram.org/bot$bot/sendMessage\?chat_id=$chatID&text=$message") keep-result=no
}