This works for me. Change ether1 to the appropriate WAN interface if that is not it.
:global ipadd;
:local thisip [/ip address get [find where interface=ether1] address];
:if ($ipadd != $thisip) do={
/tool e-mail send to="you@yourdomain.com" subject="ip change" body="New ip $thisip";
set ipadd $thisip;
}
Save as checkip (just for an example).
Then test it!
/system script
run checkip
The first time you run it, and after a reboot, it will send an email because it has no memory of variable settings before a reboot, so the variable ipadd will be empty.
Run it again. If the ip has not changed, you will not get another email.
The schedule this to run every few minutes to an hour, depending on how up-to-date you need the notice.
It shouldn’t be a problem as long as it isn’t the interface the email is sent through. How do you expect to determine the interface is down? Pinging another device works ok for that.
Unfortunately tickt me in the scheduler intervall always a mail purely although the ip has not changed. Can it be because I have two scripts with different interfaces? I know I am already on a neuerm os 6.39.1
($ Ipadd! = $ Thisip) does not work there?
Greetings from switzerland
/system script
add name=sfp1-wan-ip-send owner=m4bwema policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=“:global ipadd;
\n:local thisip [/ip address get [find where interface=sfp1-pppoe] address];\r
\n\r
\n:if ($ipadd != $thisip) do={\r
\n /tool e-mail send to="mail@mail.ch" subject="ip change" body="ip-sfp1-pppoe
\n set ipadd $thisip;\r
\n}”
add name=sfp2-wan-ip-send owner=m4bwema policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive,romon source=“:global i
\n:local thisip [/ip address get [find where interface=sfp2] address];\r
\n\r
\n:if ($ipadd != $thisip) do={\r
\n /tool e-mail send to="mail@mail.ch" subject="ip change" body="ip-sfp2
\n set ipadd $thisip;\r
\n}”