Bash
public
DNS Resolution Check
Share this script safely, inspect its metadata, and copy the exact command you need.
Ready to run
One-liner
curl -fsSL https://runny.sh/r/N3ESXJ5Y4G7M | bash
Current version: 1.1 · Updated by Godmode · 2026-09-07 02:38:59.189
At a glance
Script metadata
Readable before runnable
Preview
#!/usr/bin/env bash
# DNS resolution check
# Read-only: resolves names with getent ahosts (fallback: getent hosts). Default example.com.
# Exit 0 if every name resolves, 1 if getent is missing, 2 if any name fails.
# Hosted on Runny.sh. Review the script page before you run it.
set -u
status=0
note() { printf '%s\n' "$*"; }
bump() {
case $1 in
crit) status=2 ;;
warn) [ "$status" -lt 1 ] && status=1 ;;
esac
}
if [ "$#" -eq 0 ]; then
set -- example.com
fi
note "=== DNS resolution ==="
if ! command -v getent >/dev/null 2>&1; then
note "getent: not found in PATH"
note "Result: WARNING"
exit 1
fi
for name in "$@"; do
note "Name: ${name}"
rows=$(getent ahosts "$name" 2>/dev/null || getent hosts "$name" 2>/dev/null || true)
if [ -z "${rows}" ]; then
note " CRITICAL: no A/AAAA records"
bump crit
else
printf '%s\n' "$rows" | awk '!seen[$1]++ {printf " %s\n", $0}'
note " OK"
fi
note ""
done
case $status in
0) note "Result: HEALTHY" ;;
1) note "Result: WARNING" ;;
*) note "Result: CRITICAL" ;;
esac
exit "$status"
Raw endpointhttps://runny.sh/r/N3ESXJ5Y4G7M
See something unsafe?
Report this script
Tell us why it should come down. Anyone can also report a URL at /abuse.