I need to run a dig on domains and these domains aliases, so the result will be:
IF domain (+ doesn't have an alias) and is using my Name Servers -> then print out
IF both domain and alias are using my Name Servers -> then print out
Everything else no (including when domain is using my Name Servers and alias don't).
I have domains stored in MySQL and there's the script I am working on:
for domain in `echo "$QUERY1" | mysql -N -s -u $USER -p$PASS $DBNAME -h$HOST | awk '{print $1}'; do
lookup=$(dig $domain ns +short)
if [[ "$lookup" =~ 'XXX' ]]; then
our=1
break
else
our=0
break
fi
done
In this QUERY I am listing everything (both domains and aliases). I can of course create another query to list only aliases or only domains. It would seem that I would need to group together all the aliases of the domain and loop over the domain name + aliases list. If either one not using NS, I would have to set variable that dictates printing the domain. Let me know, what are your ideas and please share the solution, if possible.
dig
directly for all of this? It has a batch mode,dig -f filename
, which is probably exactly what you need. You can use e.g. Awk to parse the query results and generate the batch file. – Wildcard Nov 05 '16 at 02:51