#!/bin/bash
#
# by: Brian Butler (20100907)
#
# Grading script for the cachingdns lab
# this script is to be installed and run on desktopX.example.com
# output is logged to syslog

# Set environment and declare global variables
. /usr/local/lib/labtool.shlib
trap on_exit EXIT
LOG_FACILITY=local0
LOG_PRIORITY=info
LOG_TAG=cachingdnsLab
DEBUG=false
ERROR_MESSAGE="FAILED."
PATH=/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
userInput="no"
set -o pipefail

# Check to make sure we are running as root
check_root

# Check to make sure we are running on the correct host
check_host "desktop"

# Verify dns queries are forwarding from serverX to instructor.example.com
stationNum="$(hostname -s | grep -o "[0-9]*")"
serverNum="$[ 100 + $stationNum ]"
echo -n "Checking dns forwarding on 192.168.0.${serverNum}... "
(host -ta www3.example.com 192.168.0.${serverNum} 2>&1 | log) || exit 1

echo "PASSED."

exit 0
