17 lines
354 B
Bash
Executable File
17 lines
354 B
Bash
Executable File
#!/bin/bash
|
|
|
|
SOA=""
|
|
name="$1"
|
|
|
|
while [ -z "$SOA" ]
|
|
do
|
|
SOA="$(dig SOA "$name" | awk '/^[^;].*SOA/{print $1}')"
|
|
name="$(printf "%s" "$name" | sed 's/^[^.]\+\.//')"
|
|
if [[ -z "$SOA" ]] && ! [[ "$name" =~ \. ]]
|
|
then
|
|
printf "Cannot find SOA for %s.\n" "$1" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
dig "@$(dig NS "$SOA" +short | head -n 1)" "$@"
|