I just had the need to check a record on all NS servers of a zone to see whether they had been updated with the new zone config and returned the correct IP addresses for the name.
In the CLI this is quite a considerable amount of typing. That’s why I created a small script for it:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
#!/bin/bash set -o pipefail hostname=$1 [[ -z $hostname ]] && exit 1 querycount=$2 [[ -z $querycount ]] && querycount=1 until [[ ! -z $nameservers ]]; do [[ -z $domain ]] && domain=$hostname domain=$(echo $domain | sed -e 's/[^.]*.(.*)$/1/') nameservers=$(dig ns $domain | grep -v ; | grep NS | awk '{print $5}' | sed -e 's/^(.*)./1/') done for ns in $nameservers; do echo querying $hostname from $ns: for i in $(seq $querycount); do dig @$ns $hostname | grep -A1 'ANSWER SECTION:' | grep -v ANSWER sleep 1 done echo done |