I am storing IP addresses in a table in their packed binary form (4 bytes for IPv4 and 16 bytes for IPv6). My question is, is there a way to search for IP addresses via SQL?
I used php (inet_pton) to convert them to binary. I wasn't aware of any MySQL function available for this. My dilemma comes from when searching for part of an IP address. Say if the IP address is 192.168.1.101 and the user searches for 101.
Since inet_pton wouldn't work for a string/integer like 101, is there an alternative for searching for packed ip addresses? I'm open to suggestions.