#!/bin/bash get_tool_name() { echo "DNS Health Check" } get_tool_description() { echo "Comprehensive health check of a domain's DNS configuration" } execute_tool() { result="" if [ -n "$domain" ]; then if [[ "$domain" == *$'\n'* ]]; then for single_domain in $domain; do process_domain "$single_domain" done else process_domain "$domain" fi else result="No domains specified." fi echo -e "$result" } process_domain() { local single_domain="$1" result+="\e[1mDomain:\e[93m $single_domain\e[0m\n" # Check for A Record a_record=$(dig +short A "$single_domain") if [ -n "$a_record" ]; then result+="\e[1mA Record:\e[0m $a_record\n" else result+="\e[1mA Record:\e[0m \e[31mMissing\e[0m\n" fi # Check for MX Record mx_records=$(dig +short MX "$single_domain" | cut -d " " -f 2) if [ -n "$mx_records" ]; then result+="\e[1mMX Records:\e[0m $mx_records\n" else result+="\e[1mMX Records:\e[0m \e[31mMissing\e[0m\n" fi # Check for TXT Record (SPF) spf_record=$(dig +short TXT "$single_domain" | grep "v=spf1") if [ -n "$spf_record" ]; then result+="\e[1mSPF Record:\e[0m $spf_record\n" else result+="\e[1mSPF Record:\e[0m \e[31mMissing\e[0m\n" fi # Check for TXT Record (DMARC) dmarc_record=$(dig +short TXT "_dmarc.$single_domain" | grep "v=DMARC1") if [ -n "$dmarc_record" ]; then result+="\e[1mDMARC Record:\e[0m $dmarc_record\n" else result+="\e[1mDMARC Record:\e[0m \e[31mMissing\e[0m\n" fi # Check for TXT Record (DKIM) # Check DKIM records dkim_record=$(dig +short TXT "default._domainkey.$single_domain") if [ -n "$dkim_record" ]; then result+="\e[1mDKIM Record:\e[0m $dkim_record\n" else result+="\e[1mDKIM Record:\e[0m \e[31mNo DKIM record found\e[0m\n" fi # Check DNS Resolution Delay dns_resolution_delay=$(ping -c 5 "$single_domain" | tail -1 | awk '{print $4}' | cut -d '/' -f 2) if [ -n "$dns_resolution_delay" ]; then result+="\e[1mDNS Resolution Delay:\e[0m $dns_resolution_delay ms\n" fi }