-
-
Save m4vr0x/4ad1eeca6b2e4628deedd30ad50b89e5 to your computer and use it in GitHub Desktop.
Basic nslookup loop script for Linux
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 | |
for IP in `cat ./ips.txt` | |
do | |
printf "$IP\t" | |
LOOKUP_RES=`nslookup $IP` | |
FAIL_COUNT=`echo $LOOKUP_RES | grep "** server can't find " | wc -l`; | |
if [ $FAIL_COUNT -eq 1 ] | |
then | |
NAME='Bad FQDNS\n'; | |
else | |
NAME=`echo $LOOKUP_RES | grep -v nameserver | cut -f 2 | grep name | cut -f 2 -d "=" | sed 's/ //'`; | |
fi | |
echo $NAME | |
done | |
# one-liner | |
$ for i in `cat urls.txt`; do nslookup $i 2>/dev/null | grep Address | tail -n 1 | cut -d " " -f 3; done > ips.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment