Skip to content

Instantly share code, notes, and snippets.

@dgibbs64
Last active February 25, 2025 15:12
Show Gist options
  • Save dgibbs64/caf22d84c9a6418449645156b27f7db5 to your computer and use it in GitHub Desktop.
Save dgibbs64/caf22d84c9a6418449645156b27f7db5 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Read the hosts from the file into an array
mapfile -t hosts < hosts.txt
# Loop through each host
for host in "${hosts[@]}"; do
echo -en "Checking DNS for $host... "
if dig +short "$host" | grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "pass"
else
echo "fail"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment