Skip to content

Instantly share code, notes, and snippets.

@jsidhu
Created February 15, 2016 06:29
Show Gist options
  • Save jsidhu/a102bf49d256b43d73b4 to your computer and use it in GitHub Desktop.
Save jsidhu/a102bf49d256b43d73b4 to your computer and use it in GitHub Desktop.
NMAP: find free ips
nmap -v -sn -n 192.168.1.0/24 -oG - | awk '/Status: Down/{print $2}'
When you use the -v option, Nmap will print the addresses it finds as "down" in addition to the ones that are "up".
Instead of -sP, I've substituted the newer spelling -sn, which still accomplishes the same scan, but means "skip the port scan" instead of the misleading "Ping scan" (since the host discovery phase does not necessarily mean an ICMP Echo scan or Ping).
The -n option skips reverse DNS lookups, which buys you a bit of time, since you aren't interested in names but just IP addresses.
The -oG option tells Nmap to output grepable format, which is easier for awk to process. The argument "-" tells it to send this output to stdout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment