# Sending Your Self An E-Mail With Dsl Interface Ip Address - MikroTik Script RouterOS

    The goal
    The goal is to know yout DSL interface IP address at all time if you need to connect to your MT box for any reason. It is a simple script. (Based on Dynamic DNS Update Script for ChangeIP.com)

    The script
    Create a new script with the following source

    :global ddnsip
    :global ddnslastip
    :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
    :global ddnsinterface
    :global ddnssystem ("Version-" . [/system package get system version] )
    :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]
      }
    }
    :global ddnsip [ /ip address get [/ip address find interface=$ddnsinterface ] address ]
    :if ([ :typeof $ddnsip ] = nil ) do={
       :log info ("DDNS: No ip address present on " . $ddnsinterface . ", please check.")
    } else={
      :if ($ddnsip != $ddnslastip) do={
        :global strDate [/system clock get date]
        :global strTime [/system clock get time]
        :global strSystemName [/system identity get name]
        /tool e-mail send from=from@email_here_com to=to@email_here_com subject="DSL IP $strDate $strTime $strSystemName" body="DSL IP $ddnsip" server=mail_server_ip_address
        :log info "DDNS: Sending UPDATE!"
        :global ddnslastip "$ddnsip"
      } else={
      }
    }
    The schedule
    Create a schedule that runs the script every ten or so minutes and save.

    add comment="" disabled=no interval=10m name=schedule1 on-event="your_script_name_here" start-date=may/15/2008 start-time=09:00:00
    Since it is a simple script, you can schedule it to run every minute.

    Shorter version
    With no interface lookup.

    :global ddnsip
    :global ddnslastip
    :global str_date [/system clock get date]
    :global str_time [/system clock get time]
    :global str_system_name [/system identity get name]
    :if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }
    :global ddnssystem ("Version-" . [/system package get system version] )
    :global ddnsip [ /ip address get [/ip address find interface=ADSL ] address ]
    :if ([ :typeof $ddnsip ] = nil ) do={
       :log info ("DDNS: No ip address present on  ADSL interface, please check.")
    } else={
      :if ($ddnsip != $ddnslastip) do={
        /tool e-mail send from=from@email_here_com to=to@email_here_com subject="DSL IP $str_date $str_time $str_system_name" body="DSL IP $ddnsip" server=mail_server_ip_address
        :log info "DDNS: Sending UPDATE!"
        :global ddnslastip "$ddnsip"
      } else={
    #    :log info "DDNS: No update required."
        }
    }
    For this to work, simple rename your interface to ADSL and create a schedule as for the first script.

    Credit: wiki.mikrotik.com