Skip to content

Instantly share code, notes, and snippets.

@keck
Created January 24, 2019 16:35
Show Gist options
  • Save keck/8685b88f8a361e29200c85d1a5d5d236 to your computer and use it in GitHub Desktop.
Save keck/8685b88f8a361e29200c85d1a5d5d236 to your computer and use it in GitHub Desktop.
#!/bin/bash
COMMON_SUBDOMAINS=(www mail smtp pop imap blog en ftp ssh login)
if [[ "$2" == "x" ]]; then
dig +nocmd "$1" +noall +answer "${3:-any}"
wild_ips="$(dig +short "*.$1" "${3:-any}" | tr '\n' '|')"
wild_ips="${wild_ips%|}"
for sub in "${COMMON_SUBDOMAINS[@]}"; do
dig +nocmd "$sub.$1" +noall +answer "${3:-any}"
done | grep -vE "${wild_ips}"
dig +nocmd "*.$1" +noall +answer "${3:-any}"
else
dig +nocmd "$1" +noall +answer "${2:-any}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment