Created
May 21, 2012 18:56
-
-
Save kkenny/2763963 to your computer and use it in GitHub Desktop.
Check for double domain
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# (C) 2012, Kameron Kenny | |
# ExactTarget | |
nl(){ | |
echo "" | |
} | |
print_help(){ | |
nl | |
echo "Usage: $0 -n x.x.x -d domain.local" | |
nl | |
echo "Arguments: " | |
echo " -n | --net) x.x.x - First three octets of network address" | |
echo " -d | --domain) domain.local - will be turned into domain.local.domain.local" | |
nl | |
} | |
if [[ -z "$1" ]]; then | |
print_help | |
exit 1; | |
fi | |
while [[ -n "$1" ]] | |
do | |
case "$1" in | |
-h) print_help; exit 0;; | |
--help) print_help; exit 0;; | |
-n) network=$2; shift;; | |
--net) network=$2; shift;; | |
-d) d=${2}.${2}; shift;; | |
--domain) d=${2}.${2}; shift;; | |
*) print_help; exit 0;; | |
esac | |
shift | |
done | |
if [[ -z "$d" ]]; then | |
echo "ERROR: You need to set a domain to be checked..." | |
print_help | |
exit 1; | |
fi | |
if [[ -z "$network" ]]; then | |
echo "ERROR: You need to set a network to check..." | |
print_help | |
exit 1; | |
fi | |
for i in {1..254}; do | |
ip=${network}.${i}; | |
cmd=$(nslookup ${ip} | grep "${d}") | |
if [[ -n "$cmd" ]]; then | |
echo "${ip}" | |
echo "----------------" | |
nslookup ${ip} | |
echo "" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment