about summary refs log tree commit diff stats
path: root/scripts/get_dns.sh
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/get_dns.sh')
-rwxr-xr-xscripts/get_dns.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/scripts/get_dns.sh b/scripts/get_dns.sh
new file mode 100755
index 0000000..2d82925
--- /dev/null
+++ b/scripts/get_dns.sh
@@ -0,0 +1,55 @@
+#! /usr/bin/env nix-shell
+#! nix-shell -p dig -p dash -i dash --impure
+# shellcheck shell=dash
+
+get_dns_types() {
+    cat <<EOF
+    A
+    AAAA
+    CAA
+    CNAME
+    DNAME
+    MX
+    NS
+    SOA
+    SRV
+    TXT
+    PTR
+    DNSKEY
+    DS
+    SSHFP
+    TLSA
+    OPENPGPKEY
+    SVCB
+    HTTPS
+EOF
+}
+
+check_type() {
+    domain="$1"
+    type="$2"
+
+    if [ "$(dig +short -t "$type" "$domain" | wc -c)" -ne 0 ]; then
+        dig +short -t "$type" "$domain" | while IFS="$(printf "\n")" read -r output; do
+            printf "(%s) %s [%s]\n" "$type" "$output" "$domain"
+        done
+    else
+        printf "(%s) <Not set> [%s]\n" "$type" "$domain"
+    fi
+}
+
+get_dns() {
+    original_domain="$1"
+
+    get_dns_types | while read -r type; do
+        check_type "$original_domain" "$type"
+    done
+
+    # DKIM
+    check_type "mail._domainkey.$original_domain" "TXT"
+
+    # DMARC
+    check_type "_dmarc.$original_domain" "TXT"
+}
+
+get_dns "$1"