Syntax
INET6_ATON(expr)
Purpose
You can call this function to convert a specified IPv6 or IPv4 address into a binary string that represents the address value in the network byte order which is most significant byte (MSB) first.
An IPv6 address in the numeric format requires more bytes than the maximum integer type. Therefore, this function returns a VARBINARY value. VARBINARY(16) indicates an IPv6 address, and VARBINARY(4) indicates an IPv4 address. It returns NULL if the argument is not a valid address.
Limits on arguments of the INET6_ATON() function:
Zone IDs are not allowed at the end of an address, as in fc50::3%1 or fc50::3%eth1.
Network masks are not allowed at the end of an address, as in 2002:45f:3:ba::/64 or 198.51.100.0/24.
Only a classless address can be used to represent the value of an IPv4 address. A classful address such as 198.51.1 will be rejected.
Port numbers are not allowed at the end of an address, as in 198.51.100.2:8082.
Hexadecimal characters are not allowed in an address, as in 198.0xa0.1.2.
Octal numbers are not supported. For example, 198.51.010.1 is considered 198.51.10.1 rather than 198.51.8.1.
These limits on IPv4 addresses also apply to IPv6 addresses containing an IPv4 address part, such as IPv4-compatible IPv6 addresses or IPv4-mapped addresses.
To convert an IPv4 address specified by expr of the INT data type into an IPv6 address of the VARBINARY data type, use the following syntax:
INET6_ATON(INET_NTOA(expr))
Examples
obclient> SELECT HEX(INET6_ATON('fdfe::5a55:caff:fefa:9089'));
+----------------------------------------------+
| HEX(INET6_ATON('fdfe::5a55:caff:fefa:9089')) |
+----------------------------------------------+
| FDFE0000000000005A55CAFFFEFA9089 |
+----------------------------------------------+
1 row in set