If The MikroTik WAN IP Changes, Get a Message To The Telegram
When the IP information changes in wan interfaces (DSL
, Local, any DHCP
or VPN
client) in Mikrotik, we can use telegram application to ensure that this information can be reached by SMS.
This example has been prepared with telegram since Telegram has become a popular application in the near future. If you change the relevant URL after the “/tool fetch ”
the command to SMS API URL, the information will be sent to you as SMS.
You can reach our article about creating Telegram telebotID and TeleChatID from the link below.
http://techsoftcenter.com/how-to-create-a-telegram-bot-id-chat-id/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | :global LINE1; :global LINE2; :global LINE3; :local TELEBOTID; :local TELECHATID; :local LINE1NEWIP [/ip address get [find interface="LINE-1-TELEKOM"] address]; # dsl1 interface (pppoe client )name should be like this. :local LINE2NEWIP [/ip address get [find interface="LINE-2-TELEKOM"] address]; # dsl2 interface (pppoe client )name should be like this. :local LINE3NEWIP [/ip address get [find interface="LINE-3-TELEKOM"] address]; # dsl3 interface (pppoe client )name should be like this. :if ($LINE1NEWIP != $LINE1) do={ # if LINE1NEWIP ip , LINE1 if it is different from ip (start conditions to notify of current IP) :put "ip address $LINE1 changed to $LINE1NEWIP"; # We are writing as console log. Not required. :set LINE1 $LINE1NEWIP; # we write new ip information to global variable LINE1 /tool fetch keep-result=no url="https://api.telegram.org/$TELEBOTID/sendMessage\?chat_id=$TELECHATID&text=LINE 1 IP CHANGED $LINE1" ; # We send telegram status with fetch command. } :if ($LINE2NEWIP != $LINE2) do={ :put "ip address $LINE2 changed to $LINE2NEWIP"; :set LINE2 $LINE2NEWIP; /tool fetch keep-result=no url="https://api.telegram.org/$TELEBOTID/sendMessage\?chat_id=TELECHATID&text=LINE 2 IP CHANGED $LINE2" ; } :if ($LINE5NEWIP != $LINE3) do={ :put "ip address $LINE3 changed to $LINE3NEWIP"; :set LINE3 $LINE3NEWIP; /tool fetch keep-result=no url="https://api.telegram.org/$TELEBOTID/sendMessage\?chat_id=TELECHATID&text=LINE 3 IP CHANGED $LINE3" ; |
I hope it has been a useful article.