The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.


IP::China - decide whether an internet address is from China


    use utf8;
    use IP::China 'chinese_ip';
    if (chinese_ip ('')) {
        print '你好';


This documents IP::China version 20181002 corresponding to git commit eaa98f2a850c419df39f2ea06fd3f191697cf668 released on Tue Oct 16 09:20:58 2018 +0900.

This module incorporates the MaxMind GeoLite data of date 20181002 (YYYYMMDD).


Decide whether an IP address originates from China.


The module has only one function:


    my $is_chinese = chinese_ip ('');

Given an internet protocol string (version 4), decide whether it is Chinese or not. The return value is a true value (-1) if the address is from China, and a false value (0) if the address is not from China.


The module will be periodically updated. Allocated addresses for China may change. The script to build updates is included in the git repository for this distribution.

The script also includes some errata for the MaxMind list.


The data block as follows:,1814991,6252001,,0,0

is recorded as in China (country code 1814991), but this block seems to belong to Google & not be in China, so this is discounted from the results.

SEE ALSO contains an article and some links to further information.


Ben Bullock, <>


This package and associated files are copyright (C) 2013-2018 Ben Bullock.

You can use, copy, modify and redistribute this package and associated files under the Perl Artistic Licence or the GNU General Public Licence.

This product includes GeoLite data created by MaxMind, available from The GeoLite databases are distributed under the Creative Commons Attribution-ShareAlike 3.0 Unported License. The GeoLite data is in the file block-china-data.c of the distribution.