Created
September 12, 2017 21:47
-
-
Save subfission/918dffacd3c4d9430bc5c4b9d1d40ed7 to your computer and use it in GitHub Desktop.
MAC OS reverse lookup IP list
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/sh | |
# | |
# @Description: MAC OS script to quickly reverse lookup host IP's to | |
# DNS hostnames and print in a format compatible with copying | |
# to Excel. | |
# | |
# @author: Zach Jetson | |
# | |
usage() { | |
echo "Usage: $0 iplist" | |
echo "\tiplist is a text file of ips seperated by new lines" | |
exit 1 | |
} | |
if [ $# -lt 2 ]; then | |
usage | |
fi | |
while read IP ; do | |
[ -z "$IP" ] && continue | |
LOOKUP_RES=$(host $IP 2> /dev/null | sed -n 's/.*name pointer \(.*\)\./\1/p') | |
test -z "$LOOKUP_RES" && LOOKUP_RES="- not found -" | |
echo "$IP\t$LOOKUP_RES" | |
done < $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment