Skip to content

Instantly share code, notes, and snippets.

@Rudis1261
Created May 10, 2018 17:25
Show Gist options
  • Save Rudis1261/5afbb70714273d0c55c457bce2d70562 to your computer and use it in GitHub Desktop.
Save Rudis1261/5afbb70714273d0c55c457bce2d70562 to your computer and use it in GitHub Desktop.
A script I used to compare my old DNS v.s my new DNS to ensure all the records match
#!/bin/bash
domain=$1
server=$2
dig +nocmd +multiline +noall +answer "${domain}" ANY "${server}" | awk '{print $1, $3, $4, $5}' | sort -u -k1
dig +nocmd +multiline +noall +answer "${domain}" MX "${server}" | awk '{print $1, $3, $4, $5}' | sort -u -k1
dig +nocmd +multiline +noall +answer "www.${domain}" ANY "${server}" | awk '{print $1, $3, $4, $5}'| sort -u -k1
dig +nocmd +multiline +noall +answer "mail.${domain}" ANY "${server}" | awk '{print $1, $3, $4, $5}' | sort -u -k1
dig +nocmd +multiline +noall +answer "mail._domainkey.${domain}" ANY "${server}" | awk '{print $1, $3, $4, $5}' | sort -u -k1
dig +nocmd +multiline +noall +answer "_acme-challenge.${domain}" ANY "${server}" | awk '{print $1, $3, $4, $5}' | sort -u -k1
@Rudis1261
Copy link
Author

Usage:

chmod +x test_dns_records.sh
#./test_dns_records.sh <domain_name> <dns_server>
./test_dns_records.sh example.com ns.dns.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment