The Perl module IP::China provides a way to block all web accesses from China using a Perl script. Here is an example CGI script which demonstrates sending a "forbidden" response if the remote user address is from China.
#!/usr/bin/perl use warnings; use strict; use IP::China 'chinese_ip'; my $remote_addr = $ENV{REMOTE_ADDR}; if ($remote_addr) { if (chinese_ip ($remote_addr)) { print <<EOF; Content-Type: text/plain Status: 403 Sorry! EOF exit; } else { # Provide another response. } }You can test it by running it with a Chinese internet address:
REMOTE_ADDR=182.118.20.173 perl block-china.plIt will print out
Content-Type: text/plain Status: 403 Sorry!At the Github repository there is a version in C as well. This Perl module is based on GeoLite Free Downloadable Databases.
This provides an alternative method, based on the use of server configuration files for the Apache web server.
Contains some advice.
An article from 2005 describing some of the problems.