Created
December 28, 2019 10:25
-
-
Save interbiznw/6e4b00c33ca7ebe6877b5d9600600be4 to your computer and use it in GitHub Desktop.
DNS Propagation checker if !=
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Purpose: DNS Propagation checker, Check and report if DNS NS are not equal to what they should be | |
# make sure DNS utilities are installed | |
if hash dig 2>/dev/null; then | |
echo "DNS utilities not installed" | |
exit | |
fi | |
# domain to check | |
DOMAIN=wp-bullet.com | |
# pushbullet API key | |
PUSHBULLET=APIKEY | |
# array of desired nameservers in order, remember . at the end | |
NSUPDATED[0]=dawn.ns.cloudflare.com. | |
NSUPDATED[1]=burt.ns.cloudflare.com. | |
# make the DNS NS check | |
WPBULLETNS=($(dig $DOMAIN NS +short)) | |
# variables for comparison checks | |
WPBULLETNSVAR=${WPBULLETNS[@]} | |
NSUPDATEDVAR=${NSUPDATED[@]} | |
# check if nameservers are NOT equal and send pushbullet notification if they do not match the desired name servers | |
if [ "$WPBULLETNSVAR" != "$NSUPDATEDVAR" ]; then | |
curl --header "Access-Token: $PUSHBULLET" \ | |
--header 'Content-Type: application/json' \ | |
--data-binary '{"body":"DNS NS Changed: '"$WPBULLETNSVAR"'","title":"'"$DOMAIN"'","type":"note"}' \ | |
--request POST \ | |
https://api.pushbullet.com/v2/pushes | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment