Monday, July 16, 2007

IP address to country lookup howto

Using the web, you would find sites that can provide you the country location of a particular IP address. Those site are making use of an IP address to country lookup mechanism incorporated with their site.

Now, how you can do it without going to those IP to country lookup converter sites?

GeoIP is one way to do it.

It is a C library that enables the user to find the country that any IP address or hostname originates from. It uses a file based database that is accurate as of March 2003. This database simply contains IP blocks as keys, and countries as values. This database should be more complete and accurate than using reverse DNS lookups

Here's a way on how install and use it using fedora box. As root:

# yum -y install GeoIP

Let us test the software and lookup the country of this particular IP .

# geoiplookup

GeoIP Country Edition: US, United States

Remember that we have tackled issues that covers calling OS binaries, bash scripts, and/or perl scripts from a web page? You can make use of that to achieve this web-based IP to country lookup.

Have a nice day!


Sign up for PayPal and start accepting credit card payments instantly.
ILoveTux - howtos and news | About | Contact | TOS | Policy