blob: a2d29448fe90600c2d08601e8d23d07f02d9711f (
plain)
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
39
|
#!/bin/sh
# DNs Drill
# Usage: dnd, dnd -c, dnd 192.168.0.1, dnd 8.8.8.8
cache=false
if resolvectl status >/dev/null 2>&1; then
resolved=1
else
resolved=
fi
while getopts c opt; do
case $opt in
c)cache=true;;
\?)exit 1;;
esac
done
shift $((OPTIND-1))
if [ "$1" ]; then
ns="@$1"
echo "$1"
else
ns=
echo "default"
fi
for domain in www.google.com www.baidu.com github.com gitlab.com codeberg.org www.douyu.com flylightning.xyz mirrors.flylightning.xyz git.flylightning.xyz mail.flylightning.xyz one.sjsu.edu discord.com www.youtube.com mail.google.com mail.yahoo.com en.wikipedia.org zh.wikipedia.org archlinux.org gitlab.archlinux.org aur.archlinux.org wiki.archlinux.org wiki.gentoo.org unix.stackexchange.com stackoverflow.com superuser.com www.reddit.com kyun.host panel.ihostart.com virt.crunchbits.com; do
if [ "$resolved" ]; then
# awk substr and length:
# https://stackoverflow.com/a/14840991
# https://unix.stackexchange.com/a/305192
resolvectl --cache="$cache" query "$domain" | awk -v domain="$domain" '/Information acquired via protocol DNS in/{printf("%s %s\n",domain,substr($NF,0,length($NF)-1))}'
else
# "$ns" will "Error: error in making qname", so use $ns
drill -- "$domain" $ns | awk -F: -v domain="$domain" '/^;; Query time: /{printf("%s%s\n",domain,$2)}'
fi
done
|