Skip to content

Instantly share code, notes, and snippets.

@sambauers
Last active July 12, 2016 04:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sambauers/df8948e22ad6f6d187d8 to your computer and use it in GitHub Desktop.
Save sambauers/df8948e22ad6f6d187d8 to your computer and use it in GitHub Desktop.
Does a reverse lookup on a domain name's IP address.
# Add this file to your home directory then include it in ~/.profile using `. ~/.profile-digr.sh`
digr() {
for arg; do
echo -e "\033[38;5;244m*\033[0m $arg";
for DIGR_IP in $(dig +short $arg); do
echo -e " \033[38;5;244m↳ \033[0m" $DIGR_IP;
done;
if [[ "$DIGR_IP" != "" ]]; then
for DIGR_PTR in $(dig +short -x $DIGR_IP); do
echo -e " \033[38;5;244m↵ \033[0m" $DIGR_PTR;
done;
if [[ "$DIGR_PTR" == "" ]]; then
echo -e " \033[38;5;244m↵ \033[0m \033[31mPTR NOT FOUND\033[0m";
fi;
unset DIGR_PTR;
else
echo -e " \033[31m(╯°□°)╯︵ ┻━┻ NOT FOUND\033[0m";
fi;
unset DIGR_IP;
done;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment