Think before you speak, read before you think.

mysql内置ip转换函数

by

in

将十进制数转换为ipv4地址

MariaDB [(none)]> select inet_aton('192.168.1.23');
+---------------------------+
| inet_aton('192.168.1.23') |
+---------------------------+
|                3232235799 |
+---------------------------+
1 row in set (0.00 sec)

将ipv4地址转换为十进制数

MariaDB [(none)]> select inet_ntoa(3232235799);
+-----------------------+
| inet_ntoa(3232235799) |
+-----------------------+
| 192.168.1.23          |
+-----------------------+
1 row in set (0.00 sec)

自己常用的几个值

10.0.0.0 167772160
10.255.255.255 184549375
192.168.0.0 3232235520
192.168.255.255 3232301055


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *