Skip to content

Instantly share code, notes, and snippets.

@ramann
Created November 13, 2019 20:43
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 ramann/ab6cdc49c56c66b7c1c5bf4397de4dbc to your computer and use it in GitHub Desktop.
Save ramann/ab6cdc49c56c66b7c1c5bf4397de4dbc to your computer and use it in GitHub Desktop.
resolve list of names
#!/bin/bash
# because Qualys vm can only take names!?!
# usage: ./resolve.sh filename nameserver(optional)
for i in `cat $1`;
do
answer=$(nslookup $i $2)
resp_code=$(echo $?)
if [ $resp_code -eq "0" ]
then
name=$(echo "$answer" | grep ^Name | head -n1 | awk '{print $2}')
# ip=$(echo "$answer" | grep -A10 answer | grep Address | head -n1 | awk '{print $2}')
ip=$(echo "$answer" | grep -A10 ^Name | grep Address | head -n1 | awk '{print $2}')
echo "$i,$name,$ip"
else
echo "$i,,"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment