Just convert them to binary using inet_pton(), and then go back to the line using inet_ntop().
Another solution would be to save the IP string without any conversion to the database. Field VARCHAR(39)will complete the task as the highest / longest IPv6ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff
source
share