INET_NTOA

SinceVersion dev

INET_NTOA

description

Syntax

VARCHAR INET_NTOA(BIGINT ipv4_num)

Takes a Int16、Int32、Int64 number. Interprets it as an IPv4 address in big endian. Returns a string containing the corresponding IPv4 address in the format A.B.C.d (dot-separated numbers in decimal form).

notice

will return NULL if the input parameter is negative or larger than 4294967295(num value of '255.255.255.255')

example

  1. mysql> select inet_ntoa(3232235521);
  2. +-----------------------------+
  3. | ipv4numtostring(3232235521) |
  4. +-----------------------------+
  5. | 192.168.0.1 |
  6. +-----------------------------+
  7. 1 row in set (0.01 sec)
  8. mysql> select num,inet_ntoa(num) from ipv4_bi;
  9. +------------+------------------------+
  10. | num | ipv4numtostring(`num`) |
  11. +------------+------------------------+
  12. | -1 | NULL |
  13. | 0 | 0.0.0.0 |
  14. | 2130706433 | 127.0.0.1 |
  15. | 4294967295 | 255.255.255.255 |
  16. | 4294967296 | NULL |
  17. +------------+------------------------+
  18. 7 rows in set (0.01 sec)

keywords

INET_NTOA, IP