Quick Nmap ping sweep and output to grep-able format

Start with laying out what range of IP addresses you want to scan. I’d suggest keeping it limited to your specific targets. Then run this as root:

nmap -sn -v -oG nmapped.txt 192.168.1.201-254

  • -sn (No port scan) .This option tells Nmap not to do a port scan after host discovery, and only print out the available hosts that responded to the scan.
  • -v: Increase verbosity level (use -vv or more for greater effect
  • -oG : Output scan in grep-able format
  • 192.168.1.201-254 : Scans IP address range 192.168.1.201 to 192.168.1.254. Change it to your target range.

Here is our what our output file reads:

Nmap 6.47 scan initiated Wed Oct 15 21:15:32 2014 as: nmap -sn -v -oG nmapped.txt 192.168.17.201-254 # Ports scanned: TCP(0;) UDP(0;) SCTP(0;) PROTOCOLS(0;) Host: 192.168.1.201 () Status: Up Host: 192.168.1.202 () Status: Up Host: 192.168.1.203 () Status: Up Host: 192.168.1.204 () Status: Down Host: 192.168.1.205 () Status: Up Host: 192.168.1.206 () Status: Up

and so on….

To grep for IP address of hosts that are up, run;

grep Up nmapped.txt | cut -d" " -f2

This should give you a nice output of all IP addresses for hosts found to be online.

grep Up nmapped.txt | cut -d" " -f2 192.168.1.201 192.168.1.202 192.168.1.203 192.168.1.205 192.168.1.206 192.168.1.207 192.168.1.208 192.168.1.209 192.168.1.214 192.168.1.215

Intro to Nmap

Introduction to grep