MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat

Sat, Aug 28, 2004 12:32 am

Determining the Country Associated with an IP Address

You can use GeoIP to look up the country associated with a given IP address (you can also give it a hostname to determine the country). To create the GeoIP program geoiplookup, you can download the C source code from You will need a C compiler to compile the code. If you intend to use it on a Linux or Unix system, you will have a C compiler on the system, so just follow the instructions below to create the geoiplookup program or read the INSTALL file that comes with the file you download from the MaxMind website. If you intend to install it on a Windows system, read the READMEwin32.txt file that is in the .gz file you download.

Unzip the downloaded file, extract the contents of the resultant tar file and then change the working directory to the GeoIP directory created from the contents of the tar file.

gunzip GeoIP-1.3.6.tar.gz
tar -xvf GeoIP-1.3.6.tar
cd GeoIP-1.3.6

Then run the configure and make commands (installation instructions are in the INSTALL file created in the GeoIP directory, but are also summarized here).


You can then issue the command make check to run self-tests of the package, but this step isn't required. You should then type make install to install the software.

make test
make install

At this point you won't need the program binaries and other files in the source code directory and they can be removed with make clean. You can also remove the files created by configure by issuing the command make distclean. You can also remove the GeoIP directory and its contents, if you wish, since make install installs the package's files in /usr/local/bin, /usr/local/man, etc.

make clean
make disclean
cd ..
rm -fr GeoIP-1.3.6

When the program is installed, you will have a geoiplookup program in /usr/local/bin. You can use that program to lookup the country associated with an IP address or hostname. The country is based on the registration for the IP address, i.e. particular blocks of IP addresses will be associated with particular countries or at least areas of the world. The company using the IP address may be based in some other country, however. For example:

GeoIP Country Edition: US, United States

The company has their website,, hosted on a server with a US IP address. But if you issue the command whois, you will see the domain name is registered to a company in India (the company provides website design services). So geoiplookup gives you an indication of where a server is likely to be located, but not necessarily the location of a particular company using that server. Companies and individuals may use servers located in other countries.

   K 3/17, DLF Phase II

   Domain Name: EAPPLIQUE.COM

For an example of a lookup for an IP address, here is another example:

GeoIP Country Edition: HK, Hong Kong

[/network/Internet/IP] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo