Skip to content

Instantly share code, notes, and snippets.

@mattbailey
Created November 8, 2012 19:25
Show Gist options
  • Save mattbailey/4040952 to your computer and use it in GitHub Desktop.
Save mattbailey/4040952 to your computer and use it in GitHub Desktop.
netscan.sh
ips=$(nmap -sP 192.168.1.0/24 2>/dev/null | grep 'scan report' | awk '{print $NF}' |sed 's/(//;s/)//')
for ip in $ips
do
mac=$(arp $ip | cut -f 4 -d' ')
ptr=$(dig -x $ip| grep PTR |tail -n 1|awk '{ print $NF}')
if [ $ptr == 'PTR' ]
then
ptr="none"
fi
echo "$ip,$mac,$ptr;"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment