
Show HN: IP Lookup - hipaulshi
https://iplook.herokuapp.com
======
coderholic
If you're after IP details via an API you should check out
[http://ipinfo.io](http://ipinfo.io), eg:

    
    
        $ curl ipinfo.io
        {
          "ip": "67.188.232.131",
          "hostname": "c-67-188-232-131.hsd1.ca.comcast.net",
          "city": "Mountain View",
          "region": "California",
          "country": "US",
          "loc": "37.385999999999996,-122.0838",
          "org": "AS7922 Comcast Cable Communications, Inc.",
          "phone": 650
        }
    
        $ curl ipinfo.io/geo
        {
          "ip": "67.188.232.131",
          "city": "Mountain View",
          "region": "California",
          "country": "US",
          "loc": "37.385999999999996,-122.0838",
          "phone": 650
        }
    
        $ curl ipinfo.io/org
        AS7922 Comcast Cable Communications, Inc.
        
        $ curl ipinfo.io/8.8.8.8/org
        AS15169 Google Inc.
    

More details available at
[http://ipinfo.io/developers](http://ipinfo.io/developers)

~~~
nostromo
We offer something similar for free. (One of our client deployments needed it,
so we just made it free for everyone.)

[https://www.dailycred.com/api/info.json](https://www.dailycred.com/api/info.json)

This returns the current requester's location, device, and language settings.
Or you can just look for location for a specific ip like so:

[https://www.dailycred.com/api/local.json?ip=67.188.232.131](https://www.dailycred.com/api/local.json?ip=67.188.232.131)

~~~
lecle11
Interesting. Do you know how the Accept Language header is calculated? I can
imagine that it can also be used to track users as in [1]

1: [https://panopticlick.eff.org/](https://panopticlick.eff.org/)

~~~
nostromo
It's in each browser request as a header - we just echo it back because it's
not available to js.

[http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html)

------
catmanjan
For those who can't be bothered digging, uses [http://ip-
api.com/json/](http://ip-api.com/json/)

For those who don't want their web service to rely on other web services, I
recommend MaxMind's lite database, they have a fairly recent downloadable
binary of IP to geographic coodinates.

------
D9u
I've been using [http://freegeoip.net/](http://freegeoip.net/)

It's not perfect, but it seems to be good enough for my purposes.

    
    
         $ip = $_SERVER['REMOTE_ADDR'];
         $ua = $_SERVER['HTTP_USER_AGENT'];
            $ch = curl_init();
            // set url
            curl_setopt($ch, CURLOPT_URL, "freegeoip.net/csv/"    . $ip);
            //return the transfer as a string
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            // $output contains the output string
            $ip = curl_exec($ch);
            // close curl resource to free up system resources
            curl_close($ch);    
         $array = explode(',', $ip);

~~~
fiorix
Author of freegeoip.net here. It uses the db from MaxMind. Worth mentioning
that the system is not only free but also open source, available at
github.com/fiorix/freegeoip (currently written in Go)

------
tedchs
A while back I needed a no-cruft way to get my IP reliably, so put this in my
nginx config, to allow "curl example.com/ip":

http {

    
    
        # ...
    
        perl_modules /etc/nginx/perl;
    
        perl_require myip.pm;
    
        # ...
    
        server {
    
        # ...
    
          location = /ip {
    
              perl myip::handler;
    
            }
    
        # ...
    
        }

}

then in /etc/nginx/perl/myip.pm :

\---

package myip;

use nginx;

sub handler {

    
    
      my $r = shift;
    
      $r->send_http_header("text/plain");
    
      return OK if $r->header_only;
    
      $r->print($r->remote_addr() . "\n");
    
      return OK;
    

}

1;

\---

------
JoshGlazebrook
Honestly, I have been around the block trying to find a decent company that
provides either a database or api for looking up a location from an ip
address.

It seems like every company from MaxMind to IP2Location and all of the others
are accurate for some ip addresses, and severely inaccurate for others. And I
think that will only become more and more common as all of the ipv4 addresses
run out and there are hundreds to thousands behind the same ip address.

I've even tried crowdsourcing from four different ip to location sources and
even then, sometimes all four return different cities and even states for a
single ip address.

Is there any company out there that is actually fairly accurate (on a city
basis)?

~~~
sbarre
I am guessing this is why companies like Google have sourced their own info.

Geo-locating by IP will _always_ be an imperfect process because it's not
actually geolocating the IP, it's geolocating the block owner.

My downtown Toronto office geo-locates as Kansas City in some cases because
the org who owns the block is there. And I assume they are not keeping their
records up to date as we have a /8 and I think they should be registering a
sub-block or whatever it's called..

But there you go.

~~~
chrissnell
You have a /8? Are you Xerox? General Electric? :)

~~~
alextingle
There aren't that many /8s. You could just go through them all and see which
one is "in Kansas City".

------
rb2k_
I recently noticed that you could create your own "IP -> countrycode" lookup
system by using the delegation tables provided by arin/ripencc/afrinic/...

It might not be very accurate, but it's a fun little exercise:
[http://blog.marc-seeger.de/2013/09/07/ip-to-countrycode-
with...](http://blog.marc-seeger.de/2013/09/07/ip-to-countrycode-with-ruby/)

------
2bluesc
What about those of us that get easily excited over IPv6?

~~~
justincormack
Is anyone collecting this info for ipv6? Netflix has me in the wrong
continent...

------
fcambus
For a fast GeoIP JSON API, you can try Telize which is open source and has a
public API : [http://www.telize.com](http://www.telize.com)

It is built on Nginx + Lua so it has very minimal overhead.

Source code is on GitHub :
[https://github.com/fcambus/telize](https://github.com/fcambus/telize)

------
linux_devil
Are you subscribed to map box? It's fast no doubt, but why you didn't move to
free alternatives to reduce cost?

~~~
hipaulshi
you are absolutely right. switched to google map

------
Brendalyn
In general, the accuracy of geolocation is at 70-80% at the city level. We
have researched and compare the data from several providers such as
IP2Location, Maxmind, Geobytes and so on. The IP address can be freely
reallocated to any postcodes within one or multiple cities so we think that
the 70-80% is acceptable.

------
hughesey
Also available at
[http://viewdns.info/iplocation/](http://viewdns.info/iplocation/). There's an
API as well [http://viewdns.info/api/](http://viewdns.info/api/).

------
aabalkan
What is the database behind all these geo IP providers? I see many APIs
providing same functionality and results are the same. Is this database
purchased from somewhere every time you want to do this?

~~~
brodd
Maxmind, probably. ([http://www.maxmind.com/](http://www.maxmind.com/))

------
taternuts
Simple and cool! I'm starting to learn python so I'll definitely be looking
through the source, thanks for posting, flask looks like a nice little
framework to get started on

------
ftfish
If you want to take IP lookup one step further:
[https://github.com/fourtonfish/HelloSalut](https://github.com/fourtonfish/HelloSalut)

------
known
[http://geoiplookup.wikimedia.org/](http://geoiplookup.wikimedia.org/)

------
chris_wot
Lol! Optus still calls its AS Microplex! Microplex hasn't been around in a
decade and a half!

------
vomitcuddle
Maybe include information if the IP is an active Tor exit node?

------
infocollector
Where can i find a copy of the database that is driving this?

~~~
larsmak
Maxmind,
[http://dev.maxmind.com/geoip/geoip2/geolite2/](http://dev.maxmind.com/geoip/geoip2/geolite2/),
is one option. Look into their git-repo for clients to read into their
proprietary (but effective) db-format.

------
apazzolini
Mine was accurate to within a half-mile, scary!

~~~
vacri
Mine is only 100m away - but then again, that's the location of the old GPO,
which is usually used as the local "distance from X" position. I'm not sure
about elsewhere, but here in Aus, ['road'] distance from A to B is the
distance from A's post office to B's post office.

------
colbyaley
Is this on Github?

~~~
tekknolagi
It literally says "fork me on GitHub" at the top right.

~~~
nivla
>It literally says "fork me on GitHub" at the top right.

It din't show up for me either. After a bit of investigating, it looks like
Ghostery (and maybe AdBlock Plus too) sees Github ribbon as a tracker and
automatically hides it.

~~~
oneeyedpigeon
Quite ironic given the nature of the page you were looking at, and the details
that, presumably, DID show.

------
a3voices
Creepily cool!

