What Is My IP?

I recently have been experiencing issues at work where one of my two ISP’s would go down. I have a Cisco firewall that handles the fail over to my backup connection, so most of my users were unaffected.

The only users who even noticed were those who frequented websites who had additional security featues enabled to prevent against session hijacking. The constant ISP failover behaved like a multi-homed network that would randomly serve web pages across more than one Internet provider on a page by page basis.

This was a bit tricky to debug, so my first step was to create a php script that would let me know what is my external ip address, whatsmyip.me . I felt the need to create my own as many of the existing services that tell you your IP address are covered in advertisements and I just wanted a tool that would return the external IP address and nothing more. Also, most of them do a terrible job at detecting proxies and return incorrect information.

whatsmyip.me is a single php script and the code is below:

<?PHP
function whatsMyIP()
{ 
  foreach (array('HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR') as $key)
  {
      if (array_key_exists($key, $_SERVER) === true)
      {
        foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip)
          {
              if (filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE) !== false)
              {
                  return $ip;
              }
          }
      }
    }
}
 
$users_ip = whatsMyIP();
echo $users_ip; // Output IP address [Ex: 123.12.41.42]
?>

I also put this on github under “What Is My IP”

The way this script works by analyzing the php $_SERVER variable ( an array containing information such as headers, paths, and script locations created by the webserver) and returning the most reliable IP address possible. Please note, the only address you can really trust is REMOTE_ADDR, because it is the source IP of the TCP connection and cant be changed by spoofing/changing an http header. While it is technically possible to bidirectionally spoof IP addresses at the Border Gateway level, but you would have to have control over an ISP to do so.

After I had the webservice to accurately give me my ip address, i created a single bash file that would echo my IP address every 15 seconds for the next 24 hours.

MPB:dconroy$ for i in `seq 1 5760`;do  date;curl http://whatsmyip.me;sleep 15; done

If your linux box is in a different timezone, you can use the TZ environment variable to report back the correct time. In my case i just added ‘TZ=America/New_York’ directly before ‘date’.

Using this, I was able to pinpoint the exact windows where my ISP would drop making my technical support calls much more productive. This is what I love about linux and raspberry pi’s – if the tool you are looking for doesnt exist, build one!

Read More

Unboxing Kano: A Computer You Make Yourself

November 20th 2013, Alex Klein reached out to me about a kick starter project he was about to launch for a product he created, Kano. His idea was simple:

“We’ve created a simple, fun computer and coding kit, inspired by Lego. It’s designed for all ages, all over the world”

By the next day (18 hours, to be exact) he and his team had already reached their initial funding goal of $100,000.

Those of you who have read my blog before know how much I love Raspberry Pi’s. I still believe they are one of the best tools to learn linux. But what Alex and his team has done is special, they’ve created ‘A computer anyone can make’. This kit bridges the gap between the novice computer enthusiast and IT crowd who normally build computers.

I apologize now for how long overdue this post is, but I still wanted to share my unboxing experience with my readers here, and also offer my 1000% seal of approval on this truly amazing piece kit.

The packaging is very deliberate – every step is educational and exciting. The kit contains everything you need regardless if you are interested in building, gaming, or programming. If you know anyone, regardless of age, who is interested in technology, there is no better gift than a Kano. Their blog is also fantastic and is updated regularly.

 

Special thanks again to team at Kano and Lizzy at Brew PR for sending me a kit to review.

Read More

My Universal Translator (PiTranslate) Featured on Make Magazine

This is a prototype I completed last year, but have been working closely with Make Magazine and Radioshack to create this great step by step guide for their Weekend Project Campaign. Check out the guide here, and the amazingly awesome video below:

Read More