dnslook script It ain't perfect. But had to write something to go look up nameservers at one point. Someone with more DNS brains than I can improve this. But it is mildly useful! I really didn't have time (at the time) to make it more-better ;-)
We had two mail machines in the middle of moving them, thus mail. and mxrec. All you need to do is add or remove your servers you want to query for. It works generally except for those who reject queries!
Contributed by: Unknown User anonymous2 [10/14/03 | Discuss (4) | Link to this hack]
#!/bin/bash
clear
# Remove previous run the FACIST way.
rm -rf /usr/local/sbin/dnsdump.txt
rm -rf /usr/local/sbin/NS.txt
# Obtain the NS server IP addresses only for the target domain.
dig $1 | grep IN | grep NS | awk '{print $5}' > /usr/local/sbin/NS.txt
# Get the number of lines in the file to read for puking data.
line_count=`wc NS.txt | awk '{print $1}'`
if [ "$line_count" -eq 0 ]; then
clear
echo There are no NS records in domain "$1" or lookup request refused.
dig $1
exit 0
fi
# Get the stupid IP addresses for the dopey DNS servers.
for ns in `seq $line_count`
do
read ns
resolveip "$ns" | awk '{print $6}' >> /usr/local/sbin/dnsdump.txt
done < /usr/local/sbin/NS.txt
echo --------[ Looking up by nameservers for "$1" ]----------
dig $1 | grep IN | grep NS
line_count=`wc /usr/local/sbin/dnsdump.txt | awk '{print $1}'`
for ip in `seq $line_count`
do
read ip
# This next line was to test output.
# echo "$ip"
# And now the ugly part.
echo -e\n
echo -e\n
# First the dot record
echo ------------------[ Using Nameserver IP "$ip" ]----------------------
echo -e\n
dotrec=`resolveip yoursite.com | awk '{print $6}'`
echo ----------[ Yoursite.Com should Reslove To: "$dotrec" ]
echo -e\n
echo -e\n
host yoursite.com "$ip"
echo -e\n
echo -e\n
dubdub=`resolveip www.yoursite.com | awk '{print $6}'`
echo ----------[ WWW.YourSite.Com should Resolve To: "$dubdub" ]
echo -e\n
echo -e\n
echo -e\n
host www.yoursite.com "$ip"
echo -e\n
post=`resolveip mail.yoursite.com | awk '{print $6}'`
echo ----------[ Mail.YourSite.Com should Resolve To: "$post" ]
echo -e\n
echo -e\n
echo -e\n
host mail.yoursite.com "$ip"
echo -e\n
mxrec=`resolveip mxrec.yoursite.com | awk '{print $6}'`
echo ----------[ MXRec.Yoursite.Com should Resolve To: "$mxrec" ]
echo -e\n
echo -e\n
echo -e\n
host mxrec.yoursite.com "$ip"
# Now we are done I hope
done < /usr/local/sbin/dnsdump.txt
exit 0
Only thing I would have done differently is put files in /tmp/. Otherwise its not that bad.
Not industrial strength
2003-10-14 18:32:34
anonymous2
[View]
Wow. This is a great example of bad shell scripting.
And your suggestions for improvements are ... ?
2003-11-16 12:53:21
anonymous2
[View]
Or are you only limited to destructive criticism?
It would have been nice if you could have pointed out some of the errors that, in your opinion, make this a bad script. Even better if you had taken the time to show how it could be improved upon, but your lack of foresight and judgement in these matters makes your comments totally worthless.
And your suggestions for improvements are ... ?
2003-11-19 22:11:43
anonymous2
[View]