Hi everyone,
How can i get the public IP and send it to telegram?. I need to know when that IP changes and then put it on the destination address on NAT firewall rule in order to make a port redirection for a server at my home. Thanks...
:put [/ip/cloud/get public-address]
local cAdd
set cAdd [/ip/cloud/get public-address]
:local token "--49466755:AAFG1PPSJYfug2mhMT_ArgF1ZKHg1hbKhE--"
:local chatID "--54021--"
:local pAdd [/ip/cloud get public-address]
:local text "\E2\84\B9 $[/system identity get name] $[/system resource get board-name]%0A%0APublic Address: $[/ip/cloud get public-address]%0AName: $[/ip/cloud get dns-name]%0AStatus: $[/ip/cloud get status]"
/tool fetch url="https://api.telegram.org/bot$token/sendMessage?chat_id=$chatID&text=$text" output=user
:global currentIP;
:local newIP [/ip address get [find interface="ether1"] address];
:if ($newIP != $currentIP) do={
:put "ip address $currentIP changed to $newIP";
:set currentIP $newIP;
}
:global currentIP;
:local newIP [/ip/cloud get public-address];
:local token "--49466755:AAFG1PPSJYfug2mhMT_ArgF1ZKHg1hbKh--";
:local chatID "--54021--";
:local text "\E2\84\B9 $[/system identity get name] $[/system resource get board-name]%0A%0APublic Address: $[/ip/cloud get public-address]%0AName: $[/ip/cloud get dns-name]%0AStatus: $[/ip/cloud get status]";
:if ($newIP != $currentIP) do={
/tool fetch url="https://api.telegram.org/bot$token/sendMessage?chat_id=$chatID&text=$text" output=user;
:set currentIP $newIP;
}