Skip to content

Instantly share code, notes, and snippets.

@jljouannic
Created January 31, 2018 15:09
Show Gist options
  • Save jljouannic/39fec5fb9f328bd10740e8b06fbd215d to your computer and use it in GitHub Desktop.
Save jljouannic/39fec5fb9f328bd10740e8b06fbd215d to your computer and use it in GitHub Desktop.
#!/bin/bash
#### dns_verify.sh
#
NETS="192.168.1"
IPS=$(seq 1 254) ## for Linux
#
# IPS=$(jot 254 1) ## for OpenBSD or FreeBSD
# IPS=$(seq 1 254) ## for Linux
#
echo
echo -e "\tip -> hostname -> ip"
echo '--------------------------------------------------------'
for NET in $NETS; do
for n in $IPS; do
A=${NET}.${n}
HOST=$(dig -x $A +short)
if test -n "$HOST"; then
ADDR=$(dig $HOST +short)
if test "$A" = "$ADDR"; then
echo -e "ok\t$A -> $HOST -> $ADDR"
elif test -n "$ADDR"; then
echo -e "fail\t$A -> $HOST -> $ADDR"
else
echo -e "fail\t$A -> $HOST -> [unassigned]"
fi
fi
done
done
echo ""
echo "DONE."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment