Matt Coneybeare

MC

Getting Home With a Dynamically Allocated IP

| Comments

I recently had my Comcrap Cable shut off for downloading too much. Apparently, my ‘unlimited’ service did not protect me at all because I use cable. Basically, since the whole neighborhood shares one main cable connection, if I ‘overuse’ bandwidth, I am affecting other peoples service too. Its better anyway… AT&T DSL is faster in my dense neighborhood anyway.
The only problem I had to deal with after the switch was getting back into my Server at home. Comcrap uses a dynamic IP, but it only changes once… if ever. AT&T changes your IP several times a week. If I want to access my home machine and the IP has changed, I have no way to do so until I get home. There are services you can pay for that will monitor your external IP and such and such, but I wanted an easier way out. I setup my home machine to send its IP out and store it on another server, then I setup an alias from my laptop to read that server:
On the Home Server (sendip.sh):
1
2
3
4
5
#!/bin/bash

curl www.whatismyip.com/automation/n09230945.asp > /tmp/homeip.txt
scp /tmp/homeip.txt server_username@example_server:/path/to/homeip.txt
rm /tmp/homeip.txt
A cronjob setup on the Home Server:
0,15,30,45 * * * * /Content/Other/Scripts/sendip.sh
This calls my script every 15 minutes. The script gets the IP from whatismyip.com, writes it to a temp file, sends the temp file to my server and then deletes the temp file. I also setup a alias on my remote machine that reads this file and lets me ssh back home!
alias home='ssh home_username@`curl http://example_server.com/path/to/homeip.txt`'
I sent my homeip.txt file to a webserver so I use curl to read it, but you can use whatever you want in your alias to read that file.
I hope this helped somebody… there may be better ways but this works and takes 5 lines.

Comments

My name is Matt Coneybeare, I design and develop for iOS (iPhone, iPad and iPod Touch), Mac OS X and the Web out of New York. In 2008 I started a software company called Urban Apps that has made some pretty popular apps such as Ambiance and Hourly News. My current Stack Overflow reputation is about 27k.

I was a Rockstar a decade ago, but then went back to school and collected a Bachelor's Degree in Computer Science from U.C. Berkeley. Now I am settled down with my beautiful wife Di and our two doggies Hamachi and Foxy. While coding, I walk several miles/day on my Treadmill Desk. When not at my desk, I love exploring New York City as a Yelp Elite, or training for marathons.

Contact information

Name
Matt Coneybeare
Email
Website
Twitter
Instagram
GitHub
LinkedIn
Google+