Skip to content

Instantly share code, notes, and snippets.

@imxari
Last active September 23, 2021 22:10
Show Gist options
  • Select an option

  • Save imxari/eb2a43defd4b7427f02f636d70a6a505 to your computer and use it in GitHub Desktop.

Select an option

Save imxari/eb2a43defd4b7427f02f636d70a6a505 to your computer and use it in GitHub Desktop.
domain-dns.sh - Get DNS records for a registered domain
#!/bin/bash
# ==================================================
#
# Script: domain-dns.sh
# By: Xari (noreply@xarihosted.co.uk)
# Github: https://github.com/imxari
#
# Synopsis: DIG a domain for DNS records and output
# Usage: ./domain-dns.sh <domain>
#
# ==================================================
# Has the domain been provided from the CLI?
if [ -z $1 ]; then
echo "[-] Error, please provide a domain to dig!"
echo "Usage: ./domain-dns.sh <domain>"
fi
# Define the records to find
RECORDS=(NS A AAAA MX TXT CNAME)
# DIG the domain
for i in "${RECORDS[@]}"
do
echo $(tput setaf 5)"<| $i Records |>"
echo $(tput setaf 2) "-------------------------------------------------------" $(tput setaf 6)
dig +nocmd +multiline +noall +answer $i $1
echo $(tput setaf 2) "-------------------------------------------------------" $(tput setaf 7)
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment