I've rescripted the Country IP Ranges Generator in PHP (aka as Country Blocking or CIPRG), a few bugs have been fixed and the script is now powered by an SQLite database, which allows lists to be generated múch faster. 🙂

Major bugfix: countries with spaces (like United Kingdom) coudln't be generated with the country blocking script.
Everybody is free to use and change the script to suit your needs, but leave the link to ce3c.be -visible for visitors- in the script. The script uses S77.net's ip-to-country database, which can be found at Software77.net.

CIPRG v0.8.1


  • The CIPRG can be used to generate the ipranges for a certain (or multiple) countries.
  • You may use the PHP script for generating blocklists (which you can eventually add in PeerGuardian).
  • The script may be used by webhosts or people who want to block certain countries from their service.
  • The script uses an SQLite-database to save the IP ranges in and can be auto-updated whenever you wish (eventually by using a cronjob).
  • It is able to return lists in an IPv4 dotted address or a proper address and the format (eg. Peerguardian blocklist) can be easily adjusted.
  • This script also contains s77.handler.php, which will download the ip-to-country database from Software77.net, it's very easy to make new handlers to fetch another ip2country database.
  • Proxies may be used too and can be set with just one line of code: define('PROXY', 'xx.xx.xx.xx:1234');


  • PHP using Safemode Off: the script can be used now using PHP versions < 5
  • SQLite: for the databse and the class
  • cURL: needed to update the ip-to-country database


CHMOD your working dir, s77.tmp and ip2cdb to 777 if needed (those files may be named elseway and are defined in index.php). Normally the database should update itself when you try to generate a blocklist.


Don't worry, I didn't forget to add the download-link 😉

Download CIPRG v0.8.1 (link down, ask to reup if needed)