Permalink
Browse files

Added a script to resolve a class C network range to hostnames.

  • Loading branch information...
1 parent 1ceccaa commit f3c99ade1e6637be16a5eadc071627bb5a6059e0 @jlamoree committed Jun 10, 2011
Showing with 24 additions and 0 deletions.
  1. +24 −0 network/hostnames-by-ip.sh
View
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+. ../common/functions
+
+BASE=${1:-0}
+START=${2:-1}
+END=${3:-255}
+
+function usage {
+ echo "Usage: `basename $0` base [start] [end]"
+ echo "Example: `basename $0` 10.0.0 1 255"
+}
+
+if [ "$BASE" == 0 ]; then
+ error "Must specify base IP address."
+fi
+
+for B3 in `seq $START $END`; do
+ HOST=`dig -t PTR +noall +answer -x ${BASE}.${B3} | sed -r -e 's/.*PTR\s+([-\.a-z0-9]+)\.$/\1/i'`
+ if [ "_$HOST" != "_" ]; then
+ echo -e ${BASE}.${B3} "\t$HOST"
+ fi
+done
+

0 comments on commit f3c99ad

Please sign in to comment.