Given an IPv6 or IPv4 network address as a string, returns a binary string that represents the numeric value of the address in network byte order (big endian). Because numeric-format IPv6 addresses require more bytes than the largest integer type, the representation returned by this function has the VARBINARY data type: VARBINARY(16) for IPv6 addresses and VARBINARY(4) for IPv4 addresses. If the argument is not a valid address, or if it is NULL, INET6_ATON() returns NULL.
SELECT HEX(INET6_ATON('fdfe::5a55:caff:fefa:9089'));
'FDFE0000000000005A55CAFFFEFA9089'
SELECT HEX(INET6_ATON('10.0.5.9'));
'0A000509'
The following examples use HEX() to display the INET6_ATON() result in printable form:
SELECT HEX(INET6_ATON('fdfe::5a55:caff:fefa:9089'));
'FDFE0000000000005A55CAFFFEFA9089'
SELECT HEX(INET6_ATON('10.0.5.9'));
'0A000509'
INET6_ATON() observes several constraints on valid arguments. These are given in the following list along with examples.
INET6_ATON(INET_NTOA(expr))
A trailing zone ID is not permitted, as in fe80::3%1 or fe80::3%eth0.
SELECT HEX(INET6_ATON(INET_NTOA(167773449)));
'0A000509'