always know your home IP address

Having ssh access to my home machine is a tool I rely on regularly. Sometimes I need a file. Sometimes I want to grep some files. Sometimes I want to start a big download of something so it's ready when I get home.

The problem with most home Internet access plans is that you have a dynamic IP address. There are services (such as no-ip) which allow you to not only get around this, but also have a real URL you can use to access your home machine.

But if you want to keep things simple, here's a quick solution. Just have a script run on your home machine regularly which gets the IP and puts it somewhere.

In this example, I use a free service, jsonip, to get my external IP address, and Dropbox, which will sync the output to my work computer. You can also easily have the file transferred somewhere with scp, or e-mailed.

Here's the code:

#!/usr/bin/env bash

wget http://jsonip.com/ -O /home/shawn/Dropbox/info/home_ip.txt

Since I use Dropbox on all my computers, I can always get my home IP if it changes.

Just schedule it to run via cron every so often, depending on how frequently your ISP changes your IP. Here's an example to run it every six hours:

0 */4 * * * /home/shawn/bin/get_home_ip.sh

Comments !

blogroll

social