Created
July 17, 2024 13:45
-
-
Save micalm/4c3c3a06a687772485abcefc6275c8f2 to your computer and use it in GitHub Desktop.
Revisions
-
micalm created this gist
Jul 17, 2024 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,25 @@ #!/bin/bash if [ -z "$1" ]; then echo "Usage: host <domain>" exit 1 fi DOMAIN="$1" # Perform the DNS lookup for the domain IP=$(host $DOMAIN | awk '/has address/ { print $4 }') if [ -z "$IP" ]; then echo "No IP address found for $DOMAIN" exit 1 fi # Perform the reverse DNS lookup for the IP HOSTNAME=$(host $IP | awk '/domain name pointer/ { print $5 }' | sed 's/\.$//') if [ -z "$HOSTNAME" ]; then echo "$DOMAIN => $IP" else echo "$DOMAIN => $IP => $HOSTNAME" fi