MySQL
Match an IPv4 Address Against a CIDR Subnet in MySQL
Store IPv4 addresses as INT UNSIGNED and test CIDR membership with a bitmask or, much faster on a big table, an indexed BETWEEN range on network and broadcast.
Topic
Store IPv4 addresses as INT UNSIGNED and test CIDR membership with a bitmask or, much faster on a big table, an indexed BETWEEN range on network and broadcast.
Work out the network, broadcast address and prefix length of an IPv4 address inside a query, using INET_ATON(), INET_NTOA() and a little bitwise arithmetic.