Differences
This shows you the differences between two versions of the page.
tech:linux:dns_validate [2015/04/09 06:46] |
tech:linux:dns_validate [2015/04/09 06:46] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Validate DNS with nslookup ====== | ||
+ | To validate that the correct DNS entries are in the DNS | ||
+ | |||
+ | **Validate script** (nsvalidate) | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | HOSTN=$1 | ||
+ | HOSTI=$2 | ||
+ | RHOST=`nslookup -type=A $HOSTN|grep Address|grep -v "#53$"|cut -d" " -f2` | ||
+ | if [ $HOSTI != $RHOST ]; then | ||
+ | echo "Mismatch: $HOSTN expected $HOSTI but returned $RHOST" | ||
+ | fi | ||
+ | </code> | ||
+ | |||
+ | **Run script** | ||
+ | <code bash> | ||
+ | #!/bin/bash | ||
+ | ./nsvalidate someserver1 111.111.111.111 | ||
+ | ./nsvalidate someserver2 222.222.222.222 | ||
+ | </code> | ||