How to use NMAP to count the number of hosts on a given subnet.

#!/bin/bash
echo 4192 > /proc/sys/net/ipv4/neigh/default/gc_thresh3
nmap -sP -PI $1 -n –max_rtt_timeout 5000 –initial_rtt_timeout 5000 | tail -1 | cut -f 2 -d “(” | cut -f 1 -d ” ” 2> /dev/null

(Thanks to Gabriel for this one!)

Share this:
  • PDF
  • Yahoo! Bookmarks
  • TwitThis
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • LinkedIn
  • MySpace
  • Slashdot
  • Technorati
  • Print
  • email
  • Tumblr
  • FriendFeed
  • Google Bookmarks