#!/bin/sh #Some variables SERVER=$1 QUERY=$2 OPTIONS="+short +timeout=3" # Usage info usage() { echo "$0 " } # Display usage if not all information is supplied if [ ! $2 ]; then usage exit 2 fi # Execute command OUTPUT=`/usr/local/bin/dig ${OPTIONS} @${SERVER} ${QUERY} 2>&1` EXIT=$? # Debug info, only show when debugging (enable manually) #echo "$EXIT $OUTPUT $SERVER $QUERY" # Evaluate and display if [ ${EXIT} = 9 ]; then echo "DNS Query Timeout" exit 3 elif [ ${EXIT} != 0 -o ! "$OUTPUT" ]; then echo "DNS Failed: Error in resolving $QUERY" exit 2 else echo "DNS OK" exit 0 fi