Wednesday, March 20, 2019

Use Nmap to Scan for Unused IPs

So I have a customer who can't use DHCP, and I'm adding phones. Their IPs are all over the place, and managed through a (somewhat inaccurate) spreadsheet - what to do? Nmap to the Rescue!

sudo nmap -v -sn -n 192.168.1.0/24 -oG - | awk '/Status: Down/{print $2}'

For a slower and more accurate scan, try:

 for ip in 192.168.1.{1..254}; do { ping -c 1 -W 1 $ip ; } &> /dev/null || echo $ip & done | sort