sorting output by incrementing IP in mysql
You can sort this using INET_ATON:

Query:

SELECT * FROM `ip` WHERE `subnet` LIKE '10.1.2.0/24' ORDER BY INET_ATON(ip);


Data:

mysql&gt; select * from ip;
+------------+-------------+
| ip         | subnet      |
+------------+-------------+
| 10.1.2.1   | 10.1.2.0/24 |
| 10.1.2.10  | 10.1.2.0/24 |
| 10.1.2.123 | 10.1.2.0/24 |
| 10.1.2.3   | 10.1.2.0/24 |
+------------+-------------+
4 rows in set (0.00 sec)


Test:

mysql&gt; SELECT * FROM `ip` WHERE `subnet` LIKE '10.1.2.0/24' ORDER BY INET_ATON(ip);
+------------+-------------+
| ip         | subnet      |
+------------+-------------+
| 10.1.2.1   | 10.1.2.0/24 |
| 10.1.2.3   | 10.1.2.0/24 |
| 10.1.2.10  | 10.1.2.0/24 |
| 10.1.2.123 | 10.1.2.0/24 |
+------------+-------------+
4 rows in set (0.00 sec)

mysql&gt;