Joined: 07 Jun 2006 Posts: 1488 Location: the Netherlands
Posted: Fri Jun 01, 2007 9:54 Post subject: WAN IPCheck - Send an email if WAN IP has changed
Hi, after getting a request to write a script to check your WAN ip for changes (here), and email the new ip-address to you if changed. I decided to create that script, because it seemed handy.
The attached zipfile includes the folowing:
- wanipcheck.sh
- sendmail (used for sending the notification email, I didn't made that)
Howto use this script?
Well it's easy, all you have to do is enter the variables:
Code:
INTERVAL=3600
MAIL_BINARY=/mmc/usr/sbin/sendmail
MAIL_SERVER=smtp.isp.com
MAIL_TO=emailto@isp.com
MAIL_FROM=emailfrom@isp.com
MAIL_SUBJECT="Some subject for your email"
To be able to use it, you should have an SDcard mod or JFFS2 space left to save this script and save the sendmail binary. A samba share should do too.
To start the script automatically on router boot, you could enter ./wanipcheck.sh & to your startup script or save it as eg. /mmc/etc/config/wanipcheck.startup.
For more info on this have a look at Startup scripts in the Wiki.
How does it work?
Also easy, it creates an nvram variable with the old ip-adrress and compares it to the nvram variable wan_ipaddr (which contains the current ip). If changed it sends an email (if enabled ofcourse).
The email looks like this:
Code:
WAN IP Address has changed to: 12.34.56.78
Previous known IP Address: 54.32.234.241
I hope this little script might come in handy for someone :)
P.S. If you have any additions or improvements, please post them :)
Other script:
PortCheck emails you when a connection has been made to a specific port. _________________ Firmware: DD-WRT v24-sp2 (latest available) mega
WRT320N
For those who need it, I have a build of msmtp for dd-wrt available here in case you don't have an external mmc card and need something tiny (under 100kb) to fit on the existing empty jffs space.:
Unpack this, put the contents of bin/ in /jffs/bin, contents of etc/ in /jffs/etc. Edit /jffs/etc/msmtprc.
ln -s /jffs/bin/msmtp /jffs/bin/sendmail
Adjust your programs as necessary, and they will use msmtp as if its sendmail. _________________ Brielle Bruns
The Summit Open Source Development Group
http://www.sosdg.org
Maybe I missed something, but how could sendmail be that small on DD-WRT when its a pretty heavyweight binary on all other platforms... Unless, its a stub only. Heh, oh well. msmtp still does well. _________________ Brielle Bruns
The Summit Open Source Development Group
http://www.sosdg.org
Joined: 07 Jun 2006 Posts: 1488 Location: the Netherlands
Posted: Fri Jun 22, 2007 13:32 Post subject:
Have no idea, but it does work like a charm (I already included it in the ZIP). _________________ Firmware: DD-WRT v24-sp2 (latest available) mega
WRT320N
Hello everybody.
I must tell, that I'm not an expert like you are so i beg for help.
Actualy I realy need some help, how to get this script into the router and how make it work.
With help of startup scripts I used script in wanipcheck.sh file and I put it in the command window in router settings. I have save it and try it. But it doesent work.
I've changed this settings
INTERVAL=3600
MAIL_BINARY=/mmc/usr/sbin/sendmail
MAIL_SERVER=smtp.isp.com
MAIL_TO=emailto@isp.com
MAIL_FROM=emailfrom@isp.com
MAIL_SUBJECT="Some subject for your email"
and i tried some things, but it doesent work for me. I have missed something, or I'm doing all wrong. So please help me. I need some basic instructions for dummies.
I have router BUFFALO WHR-HP-G54
with DD-WRT v23 sp2
Joined: 07 Jun 2006 Posts: 1488 Location: the Netherlands
Posted: Wed Sep 19, 2007 10:47 Post subject:
Do you have storage to save the script and the sendmail binary? Eg jffs? If not it's highly unlikely it's gonna work cause you need the sendmail binary in order to send the emails.
Something you can try is create this script using the startup script and make it download the sendmail binary from a remote website. Even better, samba/cif _________________ Firmware: DD-WRT v24-sp2 (latest available) mega
WRT320N
I guess this could be useful if you want to know when you Dynamic Host(DynDNS.org, anyone?) changes without relying on their logs. _________________ Q: How do I do ...? A: Read the tutorials or Search forums
Joined: 07 Jun 2006 Posts: 1488 Location: the Netherlands
Posted: Fri Jul 11, 2008 16:24 Post subject:
Exactly, but also if you manage your own DNS for your own domain. For example MX records. _________________ Firmware: DD-WRT v24-sp2 (latest available) mega
WRT320N
Posted: Thu Aug 21, 2008 14:33 Post subject: Re: WAN IPCheck - Send an email if WAN IP has changed
Just got my Linksys last week and came across this thread when searching for a means to email from the router. Big thanks to cyberde.
A few thoughts for others who might be using this technique:
I have commented-out the commit statements in wanipcheck.sh to reduce writes to /jffs
As bruns, queried above, sendmail isn't THE sendmail but rather mini_sendmail http://www.acme.com/software/mini_sendmail/, msmtp is more comprehensive in its capabilities and has much more documentation. Thanks to bruns too.
I tested sendmail with three external ISP mailservers and they all flagged the messages as possible spam because of missing headers which didn't happen when using msmtp.
Posted: Sat Aug 23, 2008 11:00 Post subject: things
hello
i need help in two ways..
where can i find the zip-file?
why i can´t type two script in the command window, not in one but like this: 24disconned pland and sendmail in two steps?