Sending your self an e-mail with DSL interface IP address

From MikroTik Wiki
Revision as of 09:03, 13 June 2008 by Tplecko (talk | contribs)
Jump to: navigation, search

Create a new script with the following source:


:global ddnsip :global ddnslastip :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" } #:log info "v-ddnslastip= $ddnslastip" :global ddnsinterface :global ddnssystem ("Version-" . [/system package get system version] ) #:log info "v-ddnssystem= $ddnssystem" :local int :foreach int in=[/ip route find dst-address=0.0.0.0/0 active=yes ] do={ :if ([:typeof [/ip route get $int routing-mark ]] != str ) do={ :global ddnsinterface [/ip route get $int interface] # :log info "v-ddnsinterface= $ddnsinterface" } } :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ] #:log info "v-ddnsip= $ddnsip" :if ([ :typeof $ddnsip ] = nil ) do={ :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.") } else={ :if ($ddnsip != $ddnslastip) do={ :global datum [/system clock get date] :global vrijeme [/system clock get time] /tool e-mail send from=from@email.here.com to=to@email.here.com subject="DSL IP $datum $vrijeme" body="DSL IP $ddnsip" server=195.29.150.2 :log info "DDNS: Sending UPDATE!" :global ddnslastip "$ddnsip" } else={ # :log info "DDNS: No update required." } } <math>Insert formula here</math> Next, create a schedule that runs the script every ten or so minutes and save.