Next Previous Contents

3. Requirements

Your system must be running a web server such as Apache on a Linux server for the iptables functionality of this package. It also must have php4 (or higher) installed. If you use another operating system that uses the same iptables functionality as Linux, then this might work for you as well. I've found that the 2.6.x Linux kernel is needed for this package because it uses the iprange module with iptables. If you've been able to get iprange to work with iptables on a 2.4.x kernel, then you are in luck. I personally gave up and upgraded to the 2.6.x kernel. I think some of the newer 2.4 kernels can use the iprange module.

Without iptables running or if you use another type of operating system that doesn't use iptables, you can still use part of this package as long as you have php running on your system. The iptocountry.php program will be very useful in helping you to determine the country an ip address belongs to as well as the countries that are immediately before and after the ip range of the particular country.

3.1 File Requirements

If you've downloaded the complete countryip.tar.gz package, then you have this documentation and the 3 php files needed. You will also need one more file which contains all of the country and ip address info.

You have your choice of two different databases.

One can be downloaded from http://ip-to-country.webhosting.info. This file is called ip-to-country.csv and can be found in the downloads section of their website. On the website, the downloadable file is called ip-to-country.csv.zip.

The other one can be found at http://www.maxmind.com. This file is called GeoIPCountryWhois.csv once it is unzipped. In it's zipped format when you download it, it is called GeoIPCountryCSV.zip. It's also found as GeoIP-lite on the site. This is the free download. You can also use their more accurate GeoIP file from their paid service. Be sure to get the .csv version and not the binary version.

Whichever file you choose, be sure to unzip it and copy it to the directory you will be using for this package.

The file you download from one of these two souces is used just one time during the initial setup. The information database is built from the file and is used for the operation of the programs in this package.

However, once you begin using this package, you will want to check periodically for new updates to the database file that you choose to use. Both database files are updated approximately every month or so.

NOTE: For the rest of this documentation, the country database file you have chosen to use will be referred as the ".csv database file".

3.2 Summary of setup

Here's a brief summary of what you need to do to get this entire package running:

  1. Download and unpack or unzip this package into its own directory.
  2. Download either the IP-TO-COUNTRY or the MaxMind database file and unpack it in the same directory as this package.
  3. Run the countryiptsetup.php program from this package to set up all the database files that are used by countryiptables.php and iptocountry.php
  4. Run countryiptables.php to select the countries you wish to block.
  5. Use iptables to install your newly selected countries into the kernel so that Linux can block them for you.
  6. Configure Linux so that your settings will be preserved if the computer gets rebooted.

Optionally (or instead): Run iptocountry.php to look up countries according to their IP address.

For a much more detailed installation description, keep reading...


Next Previous Contents