• INET6_ATON( expr ) 

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, INET6_ATON()  returns NULL . 

The following examples use HEX()  to display the INET6_ATON()  result in printable form: 

mysql> SELECT HEX(INET6_ATON(’fdfe::5a55:caff:fefa:9089’)); -> ’FDFE0000000000005A55CAFFFEFA9089’ mysql> 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. 

•A trailing zone ID is not permitted, as in fe80::3%1  or fe80::3%eth0 . 

•A trailing network mask is not permitted, as in 2001:45f:3:ba::/64  or 198.51.100.0/24 . 

•For values representing IPv4 addresses, only classless addresses are supported. Classful addresses such as 198.51.1  are rejected. A trailing port number is not permitted, as in 198.51.100.2:8080 . Hexadecimal numbers in address components are not permitted, as in 198.0xa0.1.2 . Octal numbers are not supported: 198.51.010.1  is treated as 198.51.10.1 , not 198.51.8.1 . These IPv4 constraints also apply to IPv6 addresses that have IPv4 address parts, such as IPv4-compatible or IPv4-mapped addresses. 

To convert an IPv4 address expr  represented in numeric form as an INT  value to an IPv6 address represented in numeric form as a VARBINARY  value, use this expression: 

INET6_ATON(INET_NTOA( expr )) 

For example: 

mysql> SELECT HEX(INET6_ATON(INET_NTOA(167773449))); -> ’0A000509’ 

If INET6_ATON()  is invoked from within the mysql  client, binary strings display using hexadecimal notation, depending on the value of the --binary-as-hex . For more information about that option, see Section 4.5.1, “mysql — The MySQL Command-Line Client” . 

