MariaDB IP Address Conversion Functions:
########
# IPV4:
########
-- Address To Number:
MariaDB [test]> select inet_aton('10.0.2.15');
+------------------------+
| inet_aton('10.0.2.15') |
+------------------------+
| 167772687 |
+------------------------+
1 row in set (0.001 sec)
# Number to Address
MariaDB [test]> select inet_ntoa(167772687);
+----------------------+
| inet_ntoa(167772687) |
+----------------------+
| 10.0.2.15 |
+----------------------+
1 row in set (0.001 sec)
########
# IPV6
########
-- Address To Number:
MariaDB [test]> select hex(inet6_aton('fe80::ef99:177:ff9e:e769'));
+---------------------------------------------+
| hex(inet6_aton('fe80::ef99:177:ff9e:e769')) |
+---------------------------------------------+
| FE80000000000000EF990177FF9EE769 |
+---------------------------------------------+
1 row in set (0.001 sec)
# Number to Address
MariaDB [test]> select inet6_ntoa(unhex('FE80000000000000EF990177FF9EE769'));
+-------------------------------------------------------+
| inet6_ntoa(unhex('FE80000000000000EF990177FF9EE769')) |
+-------------------------------------------------------+
| fe80::ef99:177:ff9e:e769 |
+-------------------------------------------------------+
1 row in set (0.001 sec)