Skip to content

Instantly share code, notes, and snippets.

@deoxykev
Created February 22, 2022 16:58
Show Gist options
  • Save deoxykev/4ced671e2d4a7cc28a427446c9ddb3ac to your computer and use it in GitHub Desktop.
Save deoxykev/4ced671e2d4a7cc28a427446c9ddb3ac to your computer and use it in GitHub Desktop.
DNS monitoring service as a bash one-liner
# dns servers, comma separated test query send email on failure email client notification addr
echo -n "1.1.1.1,1.0.0.1" | xargs -d',' -I{} sh -c 'dig +timeout=5 @{} google.com | grep -q NOERROR || echo -e "To:[email protected] \nSubject:{} DNS server is unresponsive\n\nAs of $(date), {} is not responding to DNS queries for google.com." | /usr/sbin/sendmail [email protected]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment