user984314
user984314

Reputation: 155

Maxmind ipv6 - How to take an IPV6 IP and convert it into a block they provide?

Maxmind provide a free ipv6 downloadable csv. They provide ip range blocks, but does anyone know how I can someones ipv6 ip and do a check within the blocks they provide?

Here is an example of a csv entry. I believe the headers are as follow:

start ip,end ip,start ip block, end ip block, ...

"2001:200::", "2001:200:ffff:ffff:ffff:ffff:ffff:ffff", "42540528726795050063891204319802818560", "42540528806023212578155541913346768895", "JP", "Japan"

Upvotes: 1

Views: 1167

Answers (1)

Greg Oschwald
Greg Oschwald

Reputation: 1735

Since you are using MySQL, you might want to import the IPv6 addresses into binary(16) columns. It should do the correct thing for comparisons, and MySQL 5.6 provides a INET6_ATON function that converts the string notation to binary.

Upvotes: 0

Related Questions