IP to country converter?

Does anyone know an effective way to find the country of origin from an IPaddress?

I’v tried a few different java programs, but they all dont know my origin, yet other binary program do.

Google for geolocation/geolocation there are quite some free ones which offer a simple webservice which you could easily use

for example:
http://www.hostip.info/use.html

your from:

Lol, this app also doesnt know that my IP is AU.

Does anyone know the method WC3Banlist uses, as its results are accurate.

A very quick and dirty (and about 95% accurate) method is to resolve the IP, and look at the TLD.

Ofcourse .org .com and .net are in use by ISPs, but very often the TLD can be traced to a country.

It’s how uTorrent does it…

cool thanx guys for the suggestions.
I found a solution, that works with my IP address. Seems to be decent enough.

Can I ask how you did it? The way I did it was I downloaded a mapping file (mapped an ip range to iso), then I parsed that into a lookup table. I couldn’t help but think there must have been a better way as the mapping file was 2.6Mb so the lookup table used a large chunk of memory!

Yeah that sounds about right.

The original file before its cut down to only the needed data is “IpToCountry.csv” which is 6+meg uncompressed, about 1+Meg compressed

seems accurate enough. I only use it server side, and send the country location to the client, so size doesnt really bother me.

To speedup lookup time, you could convert all IPs to an int, and build a tree structure. Then you’re guaranteed to find the country in 32 steps.