This script uses ping to fetch the remaining available IP addresses in the local network. You can specify the local network, the number of IP addresses to fetch, and whether consecutive IP addresses are required.
available-ip -h
Subnet masks support both the traditional representation and the CIDR representation.
available-ip -n 192.168.10.1/24
or
available-ip -n 192.168.10.1/255.255.255.0
The following command retrieves five IP addresses from the 192.168.10.1/24 network.
available-ip -n 192.168.10.1/255.255.255.0 5
If the number is specified as 0, all available IP addresses will be fetched.
available-ip -n 192.168.10.1/255.255.255.0 0
The following command retrieves two consecutive IP addresses from the 192.168.10.1/24 network.
available-ip -n 192.168.10.1/255.255.255.0 -c true 2
The following command sets the timeout for single IP fetch to 2 seconds.
available-ip -t 2
MIT © llnut