forked from seomoz/ops-pub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdlook
38 lines (32 loc) · 803 Bytes
/
dlook
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/bash
#djoslin 7/2018
#gather zone data from dns servers then search with grep.
#assumes access to dallas.
#save script somewhere on your path.
#chmod a+x dlook.
path=$(dirname "$0")
dnslist=$path/dnslist.txt
dns_server=daldnsslave10.dal.moz.com
function getrecords
{
ping -q -c1 $dns_server 2>/dev/null 1>/dev/null
if [ "$?" -eq "0" ]; then
host -l tuk.moz.com $dns_server > $dnslist
host -l dal.moz.com $dns_server >> $dnslist
else
echo "Cannot reach $dns_server. If remote, try opening VPN to dallas."
fi
}
if [ ! -f $dnslist ]; then
getrecords
else
age=`perl -e 'printf "%d\n" ,(time()-((stat(shift))[9]))/60;' $dnslist`
if [ "$age" -gt "120" ]; then
getrecords
fi
fi
if [ $1 ]; then
grep $1 $dnslist
else
echo "Enter a string to grep against all hosts in dns."
fi