Poll all IPs in the local range, show everything, one’s in use and others that are not.
$ nmap -sn -v 192.168.1.* Starting Nmap 7.60 ( https://nmap.org ) at 2017-09-26 21:28 CEST Initiating Ping Scan at 21:28 Scanning 256 hosts [2 ports/host] Completed Ping Scan at 21:28, 2.98s elapsed (256 total hosts) Initiating Parallel DNS resolution of 256 hosts. at 21:28 Completed Parallel DNS resolution of 256 hosts. at 21:28, 0.01s elapsed Nmap scan report for 192.168.1.0 [host down] Nmap scan report for o2.box (192.168.1.1) Host is up (0.0040s latency). Nmap scan report for 192.168.1.2 [host down] Nmap scan report for 192.168.1.3 [host down] . . Host is up (0.0010s latency). Nmap scan report for my-groovy-computer (192.168.1.69) Host is up (0.091s latency). . . Nmap scan report for 192.168.1.254 [host down] Nmap scan report for 192.168.1.255 [host down] Read data files from: /usr/local/bin/../share/nmap Nmap done: 256 IP addresses (1 hosts up) scanned in 3.00 seconds
Just get the IPs of the ones that are down, ie. available for use.
$ nmap -sn -v 123.123.123.* | grep "host down" | awk '{print $5}' 192.168.1.0 192.168.1.2 192.168.1.3 . . . 192.168.1.253 192.168.1.254 192.168.1.255