Community discussions

MikroTik App
 
nishadul
Member Candidate
Member Candidate
Topic Author
Posts: 161
Joined: Thu Dec 13, 2012 12:04 pm
Location: Bangladesh

Mikrotik send current/connected IP to my email address

Sat Mar 30, 2013 3:00 pm

Hi friend,

My Mikrotik ROS version 3.30, I have a PPP0e internet connection, that is show dynamic ip and it have changed after some hour. I want Mikrotik ROS send me current/connected IP address by email after some hour. Is it possible, If so please give me details how to possible it.

Best regards,
Nishadul
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Mikrotik send current/connected IP to my email address

Mon Apr 01, 2013 11:18 am

If your mikrotik router makes the pppoe connection, you should add a script like this:
:local ipadd [/ip address get [find interface=pppoe-modem  ] address ];
:local msg (" My ip is: $ipadd");
/tool e-mail send to="email@gmail.com" subject="My Ip" body=$msg  server=[:resolve smtp.gmail.com] tls=yes;
You do not have the required permissions to view the files attached to this post.
Last edited by nick3dos on Mon Apr 01, 2013 1:47 pm, edited 1 time in total.
 
User avatar
Caci99
Forum Guru
Forum Guru
Posts: 1075
Joined: Wed Feb 21, 2007 2:26 pm
Location: Tirane
Contact:

Re: Mikrotik send current/connected IP to my email address

Mon Apr 01, 2013 12:52 pm

You might want to check the dynamic dns update scripts. Instead of using IP to connect to your router, you
can connect to it by assigning a domain name which updates through scripts.
There are a lot of webpages which do offer a domain name for free. I have used changeip in several cases,
but you can pick any other and try it out.

https://www.google.com/search?q=dynamic ... 8&oe=utf-8
 
nishadul
Member Candidate
Member Candidate
Topic Author
Posts: 161
Joined: Thu Dec 13, 2012 12:04 pm
Location: Bangladesh

Re: Mikrotik send current/connected IP to my email address

Tue Apr 02, 2013 10:06 am

If your mikrotik router makes the pppoe connection, you should add a script like this:
:local ipadd [/ip address get [find interface=pppoe-modem  ] address ];
:local msg (" My ip is: $ipadd");
/tool e-mail send to="email@gmail.com" subject="My Ip" body=$msg  server=[:resolve smtp.gmail.com] tls=yes;
I have make a script as like your suggestion but mikrotik do not send email after changed the ip. see the attach file.

When I am exit from winbox then script automatically stop but why stop I do not understand, my server is continue running.
You do not have the required permissions to view the files attached to this post.
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Mikrotik send current/connected IP to my email address

Tue Apr 02, 2013 10:14 am

First of all you have to be sure to write your email settings in mikrotik:
/tool e-mail
set address=0.0.0.0 from=username@gmail.com password=pass port=\
    25 starttls=no user=username
 
nishadul
Member Candidate
Member Candidate
Topic Author
Posts: 161
Joined: Thu Dec 13, 2012 12:04 pm
Location: Bangladesh

Re: Mikrotik send current/connected IP to my email address

Tue Apr 02, 2013 12:22 pm

First of all you have to be sure to write your email settings in mikrotik:
/tool e-mail
set address=0.0.0.0 from=username@gmail.com password=pass port=\
    25 starttls=no user=username
Email setting, see the attach file, Is it OK,
When I am exit from winbox then script automatically stop but why stop I do not understand, my server is continue running.
You do not have the required permissions to view the files attached to this post.
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Mikrotik send current/connected IP to my email address

Wed Apr 03, 2013 9:37 am

When I am exit from winbox then script automatically stop but why stop I do not understand, my server is continue running.
If you want your script to run automatically you should add a scheduler to this.
This is how to add it if your script named: email and want to run it every 6 hours.
/system scheduler
add disabled=no interval=06:00:00 name=email on-event=email policy=\
    reboot,read,write,policy,test,password,sniff,sensitive start-date=\
    jan/01/1970 start-time=03:30:00
 
nishadul
Member Candidate
Member Candidate
Topic Author
Posts: 161
Joined: Thu Dec 13, 2012 12:04 pm
Location: Bangladesh

Re: Mikrotik send current/connected IP to my email address

Wed Apr 03, 2013 3:19 pm

When I am exit from winbox then script automatically stop but why stop I do not understand, my server is continue running.
If you want your script to run automatically you should add a scheduler to this.
This is how to add it if your script named: email and want to run it every 6 hours.
/system scheduler
add disabled=no interval=06:00:00 name=email on-event=email policy=\
    reboot,read,write,policy,test,password,sniff,sensitive start-date=\
    jan/01/1970 start-time=03:30:00

Please see my attach file, my setting is Ok or Not because I am not finding backup mail to my mail account.
Please confirm it.
You do not have the required permissions to view the files attached to this post.
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Mikrotik send current/connected IP to my email address

Wed Apr 03, 2013 5:11 pm

I just run the below srcipt and the email arrived with the backup file.
Run this first, if email not arrive check again with a gmail account like i did.
add name=test_mail policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api source="#make the backup file\r\
    \n/system backup save name=[/system identity get name];\r\
    \n#wait 2 seconds\r\
    \n:delay 2;\r\
    \n#get name date and time\r\
    \n:local name [/system identity get name];\r\
    \n:local date [/system clock get date];\r\
    \n:local time [/system clock get time];\r\
    \n#make subject massage\r\
    \n:local sub (\$name . \" - \" . \$time . \" - \" . \$date);\r\
    \n#make body massage\r\
    \n:local bod (\"See attached file for System Backup\");\r\
    \n#send e-mail\r\
    \n/tool e-mail send to=\"username@gmail.com\" subject=\$sub body=\$bod  server=[:resolve smtp.gmail.com] tls=yes file=([/system identity get name] . \\ \".backup\");\r\
    \n#show info message in log\r\
    \n:log info \"Finish sending e-mail\";\r\
    \n"
 
nishadul
Member Candidate
Member Candidate
Topic Author
Posts: 161
Joined: Thu Dec 13, 2012 12:04 pm
Location: Bangladesh

Re: Mikrotik send current/connected IP to my email address

Thu Apr 04, 2013 8:24 am

I just run the below srcipt and the email arrived with the backup file.
Run this first, if email not arrive check again with a gmail account like i did.
add name=test_mail policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive,api source="#make the backup file\r\
    \n/system backup save name=[/system identity get name];\r\
    \n#wait 2 seconds\r\
    \n:delay 2;\r\
    \n#get name date and time\r\
    \n:local name [/system identity get name];\r\
    \n:local date [/system clock get date];\r\
    \n:local time [/system clock get time];\r\
    \n#make subject massage\r\
    \n:local sub (\$name . \" - \" . \$time . \" - \" . \$date);\r\
    \n#make body massage\r\
    \n:local bod (\"See attached file for System Backup\");\r\
    \n#send e-mail\r\
    \n/tool e-mail send to=\"username@gmail.com\" subject=\$sub body=\$bod  server=[:resolve smtp.gmail.com] tls=yes file=([/system identity get name] . \\ \".backup\");\r\
    \n#show info message in log\r\
    \n:log info \"Finish sending e-mail\";\r\
    \n"
I have try as per your suggestion, see the attach file and confirm me is it ok. but mikrotik does not send mail to my mail account.
You do not have the required permissions to view the files attached to this post.
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Mikrotik send current/connected IP to my email address

Thu Apr 04, 2013 9:27 am

I am sure it will not send you like this...

The script i gave you, is auto generated with export command from terminal.

Remove the last script you add first.
You have to open the terminal and write: system scripts and hit enter and after that copy paste the script in the terminal.

If everything is ok you should see the scripts without the "\n" characters.

After this try to run it again.

If the script run is ok you should see in your log file the line: "Finish sending e-mail"...
 
nishadul
Member Candidate
Member Candidate
Topic Author
Posts: 161
Joined: Thu Dec 13, 2012 12:04 pm
Location: Bangladesh

Re: Mikrotik send current/connected IP to my email address

Thu Apr 04, 2013 2:12 pm

I am sure it will not send you like this...

The script i gave you, is auto generated with export command from terminal.

Remove the last script you add first.
You have to open the terminal and write: system scripts and hit enter and after that copy paste the script in the terminal.

If everything is ok you should see the scripts without the "\n" characters.

After this try to run it again.

If the script run is ok you should see in your log file the line: "Finish sending e-mail"...
If I paste your script in terminal then script name will show in /system/script or NOT ? because I am not exparte with mikrotik
Last edited by nishadul on Thu Apr 04, 2013 2:20 pm, edited 1 time in total.
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Mikrotik send current/connected IP to my email address

Thu Apr 04, 2013 2:20 pm

yes
 
nishadul
Member Candidate
Member Candidate
Topic Author
Posts: 161
Joined: Thu Dec 13, 2012 12:04 pm
Location: Bangladesh

Re: Mikrotik send current/connected IP to my email address

Thu Apr 04, 2013 2:22 pm

yes
Can I delete this script any time from /system/script
when I wrote system scripts in terminal then firstly use "/" or not
Last edited by nishadul on Thu Apr 04, 2013 2:30 pm, edited 1 time in total.
 
User avatar
nick3dos
Member Candidate
Member Candidate
Posts: 189
Joined: Fri Apr 29, 2011 11:03 pm
Location: Greece

Re: Mikrotik send current/connected IP to my email address

Thu Apr 04, 2013 2:30 pm

yes
Can I delete this script any time from /system/script
You can't have two scripts with the same name.

Or you can delete the old one Or you can name the new one with other name (test_email2)...
 
nishadul
Member Candidate
Member Candidate
Topic Author
Posts: 161
Joined: Thu Dec 13, 2012 12:04 pm
Location: Bangladesh

Re: Mikrotik send current/connected IP to my email address

Thu Apr 04, 2013 2:33 pm

yes
Can I delete this script any time from /system/script
You can't have two scripts with the same name.

Or you can delete the old one Or you can name the new one with other name (test_email2)...
when I write system scripts in terminal, firstly use "/". as like /system scripts or NOT

Who is online

Users browsing this forum: Ahrefs [Bot], BillyVan, Google [Bot], infabo, makvladd, oxigeno20, pe1chl, Renfrew, RobertsN and 116 guests