IP2Location™ IPv6 Database


Free

Registration required

IP2Location™ IPv6-COUNTRY Free Edition is a complimentary version of the IP2Location™ IP-COUNTRY database for IPv6. The database can be used to lookup country by IP address from IPv6 space. It is currently available in both CSV (text) and BIN (binary) formats. For binary format, you will need to use the IP2Location API to perform local queries. It supports all valid IPv6 address range from 0000:0000:0000:0000:0000:0000:0000:0000 to FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF from 220+ countries worldwide.

You may download and implement the IP2Location™ IPV6-COUNTRY Free Edition in open source projects. For commercial redistribution rights for the IP2Location™ IPV6-COUNTRY Free Edition, please contact us by email for more details regarding your project. For all open source developers using this database, please credit us by linking back to http://www.ip2location.com.

 

Product Features
Current Version November 2014
Next Update December 2014
Database Format ASCII Text File (Comma Delimited) and BIN (API)

IP2Location™ offers several open source APIs to support application integration by using IP2Location™ Binary (.BIN) data file.

 

Database Fields
Name Type Description
ip_from DECIMAL(39,0) First IP number in netblock.
ip_to DECIMAL(39,0) Last IP number in netblock.
ipv6_from VARCHAR(40) First IPv6 address in netblock.
ipv6_to VARCHAR(40) Last IPv6 address in netblock.
country_code CHAR(2) Two-character country code based on ISO 3166.
country_name VARCHAR(64) Country name based on ISO 3166.
isp VARCHAR(255) Internet Service Provider or company's name.

 

MySQL Statement

CREATE TABLE `ip2location_ipv6`(
	`ip_from` DECIMAL(39,0),
	`ip_to` DECIMAL(39,0),
	`ipv6_from` VARCHAR(40),
	`ipv6_to` VARCHAR(40),
	`country_code` CHAR(2),
	`country_name` VARCHAR(64),
	`isp` VARCHAR(255),
	INDEX `idx_ip_from` (`ip_from`),
	INDEX `idx_ip_to` (`ip_to`),
	INDEX `idx_ip_from_to` (`ip_from`, `ip_to`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin;

LOAD DATA LOCAL INFILE 'IP2LOCATION-IPV6-FREE.CSV' INTO TABLE `ip2location_ipv6` FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n' IGNORE 1 LINES;

 

Calculate IPv6 to Decimal

Perl:

use Net::IP;

sub ipv6tono {
      my $ipv6 = shift(@_);
      my $no = new Net::IP ($ipv6);
      return $no->intip();
}

PHP:

function ip62long($ipv6){
	$ip_n = inet_pton($ipv6);
	$bits = 15;

    $ipv6long = 0;

	while($bits >= 0){
		$bin = sprintf("%08b",(ord($ip_n[$bits])));

		if($ipv6long){
			$ipv6long = $bin . $ipv6long;
		}
		else{
			$ipv6long = $bin;
		}
		$bits--;
	}
	return gmp_strval(gmp_init($ipv6long, 2), 10);
}

C# (.NET 4.0)

private static BigInteger ConvertIPv6AddressToNumber(string ipAddress)
{
    byte[] addrBytes = System.Net.IPAddress.Parse(ipAddress).GetAddressBytes();
    if (System.BitConverter.IsLittleEndian)
    {
        System.Collections.Generic.List<byte> byteList = new System.Collections.Generic.List<byte>(addrBytes);
        byteList.Reverse();
        addrBytes = byteList.ToArray();
    }
    BigInteger final;
    BigInteger[] mybigint = new BigInteger[2];
    mybigint[0] = System.BitConverter.ToUInt64(addrBytes, 8);
    mybigint[1] = System.BitConverter.ToUInt64(addrBytes, 0);
    mybigint[0] = mybigint[0] << 64;
    final = mybigint[0] + mybigint[1];

    return final;
}

 

License Information

License Agreement: General Terms and Conditions for the database licensing.

IP2Location™ is a registered trademark of HEXASOFT. All other trademarks are the property of their respective owners.