what’s my IP?-Dropbox style


Have you every tried to use DynDNS? I have and frankly I didn’t have much fun trying to get that to work with my DSL modem at the time. It would probably work now that I have a cable modem, but why should I bother. I have a much easier way to acquire the IP address of my SSH server anywhere I am by simply using a cronjob in combination with Dropbox.

First, if you haven’t heard of Dropbox, then you must be new on computers right? Dropbox is a very popular file syncing service that can be installed on all of you favorite platforms from Linux to Mac to Android. Now this post isn’t about Dropbox directly as there is a lot to be said about Dropbox. I would caution you that if you want to use Dropbox for really sensitive information, check out SpiderOak instead. SpiderOak offers enhanced security whereas Dropbox is all about ease of access.

Anyways, to get Dropbox on your Ubuntu box:

~$ sudo apt-get install nautilus-dropbox

You will have to setup a Dropbox account and link your current computer. Once that is done you will see a dropbox folder in your home directory. Anything you put in that directory will be automatically synced with any other linked devices that you have. This includes your smartphone if you have installed the Dropbox app there. With a basic account, you get 2gb free. Beyond plenty for my shell scripts. My pictures or music is a different story :)

Now for the cronjob. First, why would you want to know your IP address? Well if you read my post on setting up an ssh server, you will know that you can do a lot of sys admin work through an ssh session. To do that remotely requires knowing the IP address of your server. If you are a budget minded dude like me you most likely do not have a static IP and must deal with the regular dynamic IP changes that your ISP dishes out. Getting your IP is easy when you are at home, but when you are abroad you need a little help. Aside from having your room-mate read it off www.whatsmyip.org, the best way to get this is to setup a script to check it for you. I set-up the following bash script as ip_add_check:

#! /bin/bash
curl ifconfig.me > /home/andy/Dropbox/ip.txt

This I made executable:

~$ chmod a+x ip_add_check

Then I copied it to my cron.hourly folder:

~$ sudo cp ip_add_check /etc/cron.hourly/

Now, every hour the cronjob will check my IP address and overwrite the ip.txt which I have in my synced Dropbox folder. With my Android in hand I will never be without my ssh servers IP address and can always get my work done.