I've recently started started using a VPN for the first time in years, and was using WhatIsMyIP to sanity check that I was indeed seeing the net via a different IP than that provided by my ISP. However, there were a few things I wasn't too happy about:
- I was concerned that my repeated queries to that site might be detected as abusive.
- Alternatively, I might be seeing cached results from an earlier query on a different network setup.
- As someone happiest using the Unix command line, neither switching to a browser window, nor using curl and parsing the HTML output, were ideal.
So, I spent a few hours knocking up my own variation of this type of service, doubtless the gazillionth implementation clogging up the internet, which you can find here. While it's still pretty basic, there are a couple of features that I haven't noticed in other implementations:
- A Geo-IP lookup is done, to identify the originating country, region, city and latitude and longitude. This data is obtained via a Google API, so it's probably as accurate as these things get - which isn't very much, at least at the lat/long level. (The main motivation for adding this functionality was to help analyse if my VPN can be abused to break region restrictions on sites like Hulu ;-)
- To make things more convenient for non-browser uses, multiple output formats are supported (HTML, plain text, CSV, XML and JSON), which can be specified either by an old-school format=whatever CGI argument, or a more RESTful way using the HTTP Accept header.
Here are a couple of examples of usage:
[john@hamburg ~]$ curl -H "Accept: text/plain" "http://report-ip.appspot.com"
IP Address: x.x.x.x
Content-Type: ; charset="utf-8"
User-Agent: curl/7.21.3 (x86_64-redhat-linux-gnu) libcurl/7.21.3 NSS/188.8.131.52 zlib/1.2.5 libidn/1.19 libssh2/1.2.7
[john@hamburg ~]$ curl "http://report-ip.appspot.com/?format=json"
"Content-Type": "; charset="utf-8"",
"User-Agent": "curl/7.21.3 (x86_64-redhat-linux-gnu) libcurl/7.21.3 NSS/184.108.40.206 zlib/1.2.5 libidn/1.19 libssh2/1.2.7"
I've created a project on GitHub, so you can see how minimal the underlying Python code is. The README has some notes about what extra stuff I might add in at some point, in the event I can be bothered.
As the live app is just running off an unbilled App Engine instance, it won't take much traffic before hitting the free quota limits. As such, in the unlikely event that someone out there wants to make use of this, you might be better off grabbing the code from the repo and deploying it to your own App Engine instance.