On Dec 13, 2010, at 7:48 PM, Levan, Jerry wrote:

> 
> Anyway last week I learned that MacOSX client has all of the software
> needed for running a VPN and found a tutorial that explained how to 
> set the rascal up.
> 
> It noted the problem with dynamic dns addresses and suggested several
> sites that can 'solve' the problem.
> 
> I decided that I would reinvent the wheel using the hardware at hand.
> 
> My external IP does not change very often so an instantaneous response
> was not necessary.
> 
> My solution was simple and did not involve installing any background
> daemons and registering for another account somewhere else in the
> world.
> 
> A one line crontab entry:
> 
> 0 6-22/4  * * * snmpwalk -Ov -OQ -c public router ipAdEntAddr | mail -s "IP 
> Address" [email protected]
> 
> You can adjust the frequency of the mail to your paranoia level.
> 
> The cronjob sends the list of ip addresses of my airport extreme base station 
> to one
> of my mail accounts. It is perfectly clear which of the IPs is the external 
> IP of the
> router.
> 
> When the router ip changes a quick cut from the mail and paste on my off the 
> local net devices will 
> point the vpn client to the new address.
> 
> Again the url of the tutorial for setting up the VPN: 
> http://blog.theilluminatedengineer.com/?p=136
> 
> The comments offer additional clues.
> 
> Task complete!
> 
> Jerry
> 

I thought I might try to send email only when the router IP changes...

Here is the shell script that I am fiddling with...
***********************************************
#!/bin/sh
#
# New file: Dec 14, 2010
# Send mail to me if the router IP list changes
# Jerry LeVan
#
old='/tmp/ip.old'
new='/tmp/ip.new'

# get the current ip list of the router
snmpwalk -Ov -OQ -c public router ipAdEntAddr | sort > $new 

# check to set if the old ip file exists
if [[ -a $old ]] 
  then 
    # old file exists 
     if  ( diff $old $new > /dev/null )  
        then
          # echo they are the same do nothing 
          exit 0
        else 
          # echo they are diff 
           cp $new $old
           # echo sending notification 
           mail -s "Router IP Has Changed" [email protected] < $new 
        fi 
    else
     # old file did not exist
     cp $new $old
     # echo old did not exist sending notification
     mail -s "Router IP " [email protected] < $new 
fi
*********************************************
I am executing this file every 10 minutes with a cron table entry:
0-59/10 *       *       *       *       /usr/local/bin/checkip.sh

Jerry_______________________________________________
MacOSX-admin mailing list
[email protected]
http://www.omnigroup.com/mailman/listinfo/macosx-admin

Reply via email to