Daily Shaarli

All links of one day in a single page.

April 28, 2024

Sorted list of IPv4 addresses of LXC containers

This is a one-liner that I find useful when deciding a free IPv4 address to assign a new container:

$ lxc network list-leases lxdbr0 | grep STATIC | sort -t "." -n -k4
| taipei    | 00:16:3e:9c:dd:28 | 10.252.116.3   | STATIC  |
| hunan     | 00:16:3e:f7:4f:b2 | 10.252.116.4   | STATIC  |
| xian      | 00:16:3e:b0:54:12 | 10.252.116.5   | STATIC  |
| samarkand | 00:16:3e:e8:79:60 | 10.252.116.6   | STATIC  |
| karachi   | 00:16:3e:e5:4c:47 | 10.252.116.7   | STATIC  |
| lahore    | 00:16:3e:f1:73:ab | 10.252.116.8   | STATIC  |
| muscat    | 00:16:3e:9a:89:05 | 10.252.116.9   | STATIC  |
| antioch   | 00:16:3e:92:79:ca | 10.252.116.11  | STATIC  |
| delhi     | 00:16:3e:22:9c:d0 | 10.252.116.13  | STATIC  |
| bahrain   | 00:16:3e:4b:b6:ee | 10.252.116.14  | STATIC  |
| lusail    | 00:16:3e:fd:1f:49 | 10.252.116.15  | STATIC  |
| pergamon  | 00:16:3e:0e:9c:82 | 10.252.116.16  | STATIC  |

The one-liner is simplified by the fact that only the IP address field contains dots, so we can use them as delimiters for sort without first having to sort on the column delimiters.