TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Show HN: IP Lookup

72 pointsby hipaulshiover 11 years ago

21 comments

coderholicover 11 years ago
If you&#x27;re after IP details via an API you should check out <a href="http://ipinfo.io" rel="nofollow">http:&#x2F;&#x2F;ipinfo.io</a>, eg:<p><pre><code> $ curl ipinfo.io { &quot;ip&quot;: &quot;67.188.232.131&quot;, &quot;hostname&quot;: &quot;c-67-188-232-131.hsd1.ca.comcast.net&quot;, &quot;city&quot;: &quot;Mountain View&quot;, &quot;region&quot;: &quot;California&quot;, &quot;country&quot;: &quot;US&quot;, &quot;loc&quot;: &quot;37.385999999999996,-122.0838&quot;, &quot;org&quot;: &quot;AS7922 Comcast Cable Communications, Inc.&quot;, &quot;phone&quot;: 650 } $ curl ipinfo.io&#x2F;geo { &quot;ip&quot;: &quot;67.188.232.131&quot;, &quot;city&quot;: &quot;Mountain View&quot;, &quot;region&quot;: &quot;California&quot;, &quot;country&quot;: &quot;US&quot;, &quot;loc&quot;: &quot;37.385999999999996,-122.0838&quot;, &quot;phone&quot;: 650 } $ curl ipinfo.io&#x2F;org AS7922 Comcast Cable Communications, Inc. $ curl ipinfo.io&#x2F;8.8.8.8&#x2F;org AS15169 Google Inc. </code></pre> More details available at <a href="http://ipinfo.io/developers" rel="nofollow">http:&#x2F;&#x2F;ipinfo.io&#x2F;developers</a>
评论 #6759435 未加载
评论 #6760499 未加载
catmanjanover 11 years ago
For those who can&#x27;t be bothered digging, uses <a href="http://ip-api.com/json/" rel="nofollow">http:&#x2F;&#x2F;ip-api.com&#x2F;json&#x2F;</a><p>For those who don&#x27;t want their web service to rely on other web services, I recommend MaxMind&#x27;s lite database, they have a fairly recent downloadable binary of IP to geographic coodinates.
D9uover 11 years ago
I&#x27;ve been using <a href="http://freegeoip.net/" rel="nofollow">http:&#x2F;&#x2F;freegeoip.net&#x2F;</a><p>It&#x27;s not perfect, but it seems to be good enough for my purposes.<p><pre><code> $ip = $_SERVER[&#x27;REMOTE_ADDR&#x27;]; $ua = $_SERVER[&#x27;HTTP_USER_AGENT&#x27;]; $ch = curl_init(); &#x2F;&#x2F; set url curl_setopt($ch, CURLOPT_URL, &quot;freegeoip.net&#x2F;csv&#x2F;&quot; . $ip); &#x2F;&#x2F;return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); &#x2F;&#x2F; $output contains the output string $ip = curl_exec($ch); &#x2F;&#x2F; close curl resource to free up system resources curl_close($ch); $array = explode(&#x27;,&#x27;, $ip);</code></pre>
评论 #6761162 未加载
评论 #6761348 未加载
tedchsover 11 years ago
A while back I needed a no-cruft way to get my IP reliably, so put this in my nginx config, to allow &quot;curl example.com&#x2F;ip&quot;:<p>http {<p><pre><code> # ... perl_modules &#x2F;etc&#x2F;nginx&#x2F;perl; perl_require myip.pm; # ... server { # ... location = &#x2F;ip { perl myip::handler; } # ... }</code></pre> }<p>then in &#x2F;etc&#x2F;nginx&#x2F;perl&#x2F;myip.pm :<p>---<p>package myip;<p>use nginx;<p>sub handler {<p><pre><code> my $r = shift; $r-&gt;send_http_header(&quot;text&#x2F;plain&quot;); return OK if $r-&gt;header_only; $r-&gt;print($r-&gt;remote_addr() . &quot;\n&quot;); return OK; </code></pre> }<p>1;<p>---
JoshGlazebrookover 11 years ago
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.<p>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.<p>I&#x27;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.<p>Is there any company out there that is actually fairly accurate (on a city basis)?
评论 #6759406 未加载
rb2k_over 11 years ago
I recently noticed that you could create your own &quot;IP -&gt; countrycode&quot; lookup system by using the delegation tables provided by arin&#x2F;ripencc&#x2F;afrinic&#x2F;...<p>It might not be very accurate, but it&#x27;s a fun little exercise: <a href="http://blog.marc-seeger.de/2013/09/07/ip-to-countrycode-with-ruby/" rel="nofollow">http:&#x2F;&#x2F;blog.marc-seeger.de&#x2F;2013&#x2F;09&#x2F;07&#x2F;ip-to-countrycode-with...</a>
2bluescover 11 years ago
What about those of us that get easily excited over IPv6?
评论 #6760062 未加载
fcambusover 11 years ago
For a fast GeoIP JSON API, you can try Telize which is open source and has a public API : <a href="http://www.telize.com" rel="nofollow">http:&#x2F;&#x2F;www.telize.com</a><p>It is built on Nginx + Lua so it has very minimal overhead.<p>Source code is on GitHub : <a href="https://github.com/fcambus/telize" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fcambus&#x2F;telize</a>
linux_devilover 11 years ago
Are you subscribed to map box? It&#x27;s fast no doubt, but why you didn&#x27;t move to free alternatives to reduce cost?
评论 #6772355 未加载
Brendalynover 11 years ago
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.
hugheseyover 11 years ago
Also available at <a href="http://viewdns.info/iplocation/" rel="nofollow">http:&#x2F;&#x2F;viewdns.info&#x2F;iplocation&#x2F;</a>. There&#x27;s an API as well <a href="http://viewdns.info/api/" rel="nofollow">http:&#x2F;&#x2F;viewdns.info&#x2F;api&#x2F;</a>.
aabalkanover 11 years ago
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?
评论 #6759749 未加载
taternutsover 11 years ago
Simple and cool! I&#x27;m starting to learn python so I&#x27;ll definitely be looking through the source, thanks for posting, flask looks like a nice little framework to get started on
ftfishover 11 years ago
If you want to take IP lookup one step further: <a href="https://github.com/fourtonfish/HelloSalut" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;fourtonfish&#x2F;HelloSalut</a>
knownover 11 years ago
<a href="http://geoiplookup.wikimedia.org/" rel="nofollow">http:&#x2F;&#x2F;geoiplookup.wikimedia.org&#x2F;</a>
chris_wotover 11 years ago
Lol! Optus still calls its AS Microplex! Microplex hasn&#x27;t been around in a decade and a half!
vomitcuddleover 11 years ago
Maybe include information if the IP is an active Tor exit node?
infocollectorover 11 years ago
Where can i find a copy of the database that is driving this?
评论 #6759994 未加载
apazzoliniover 11 years ago
Mine was accurate to within a half-mile, scary!
评论 #6759774 未加载
评论 #6759468 未加载
评论 #6759527 未加载
评论 #6759922 未加载
colbyaleyover 11 years ago
Is this on Github?
评论 #6759282 未加载
a3voicesover 11 years ago
Creepily cool!