Quick Nmap ping sweep and output to grep-able format

grep hacking linux nmap ping scan security

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

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

The author would love to hear your comments. Let us discuss at Twitter @qasimchadhar.