May 302013

There are times when I need to do things and I don’t trust using public access, hotspots, etc. So basically what I did was set up a vpn on my home network and I can then connect to it from anywhere. This has the advantage of encrypting my communications while in a public place. One of the problems was that my ISP will randomly change the ip address. Granted there are numerous services that will do dynamic dns….but that just has the potential to attract unwanted traffic. So, what I did was basically wrote a small 1 line script that dumps my ip once a day to my dropbox account (encrypted).  Either the script can be run (via crontab) or you can simply add the entire line to crontab:

# By Ed Wiget
# get and log ip address
# lynx using --dump option just shows contents
# first sed removes beginning and trailing white space from lines
# second sed removes blank lines
# gpg encrypts the file for [email protected] and saves it to /path/to/encrypted.file.asc
# then we log that we completed the task
lynx --dump | sed 's/^[ \t]*//;s/[ \t]*$//' | sed '/^$/d' | gpg -ea -r > /path/to/encrypted.file.asc | logger "external ip encrypted"

Add it to your users crontab using ‘crontab -e’:

# encrypted version hourly
0 * * * * lynx --dump | sed 's/^[ \t]*//;s/[ \t]*$//'  | sed '/^$/d'  | gpg -ea -r >  /path/to/encrypted.file.asc | logger "external ip encrypted"

So now I can get my ip address from an encrypted file by simply using:

gpg -d /path/to/encrypted.file.asc

This site uses Akismet to reduce spam. Learn how your comment data is processed.