Skip to content

Instantly share code, notes, and snippets.

@oko
Created February 11, 2018 20:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save oko/97ed2095bc200f471340981e5c7e61fc to your computer and use it in GitHub Desktop.
Save oko/97ed2095bc200f471340981e5c7e61fc to your computer and use it in GitHub Desktop.
crappy zone checker to verify DNS records are transferred correctly
#!/bin/bash
set -eu
if [[ ! -z "${DEBUG:-""}" ]]; then set -x; fi
ZONE="$1"
NEW="$2"
DIG="dig +short $ZONE"
DIGN="$DIG $NEW"
check_rrtype() {
RRTYPE="$1"
OLD="$($DIG "$RRTYPE" | sort)"
NEW="$($DIGN "$RRTYPE" | sort)"
if [[ "$OLD" == "$NEW" ]]; then
echo "$RRTYPE records validated"
else
echo ================================================================================
set +e
diff <(echo "$OLD") <(echo "$NEW")
set -e
echo ================================================================================
echo "$RRTYPE records did not validate!"
exit 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment