Bash script : DNS Check match between reverse and forward lookup

Posted by Rianto Wahyudi

Basic bash lookup script to check if forward / reverse IP address is matching.

  • The script use host command, it'llĀ  automatically add DNS prefix based on /etc/resolv.conf
  • Support for hostnamesĀ  or PTR address with multiple RR
Usage: ./checkhost <IP or hostname> checkhost<IP or hostname> ...
Example: ./checkhost www pop3.iinet.net.au
This script will check if forward and reverse match

./checkhost shadow pop3.iinet.net.au
shadow <-> : Match
pop3.iinet.net.au <-> : Match
mud.starway.net.au <-> : Match

Download the script here :


NFS Monitoring Scripts

Posted by Rianto Wahyudi

I've tried few different NFS mount check, but most of them hang or freeze when the remote server is not responding. So I created a simple script to monitor and automatically mount NFS which kill it self .

I put this script on crontab which then run every 15 minutes :
cron entries :

*/15 * * * * /root/bin/check_nfs.sh

check_nfs.sh :

# Script to check if NFS is mounted properly
# Change Log :

# Script to check and monitor NFS mounted file system

# When NFS is not working, it may hang the process that try to access it.
# As a work around, we start a process in the background that will kill nfs_check script after 30 seconds
# However, if check command works then kill the process that was about to kill me ( killmyparrent.sh )


# Exit if another instance is running
if [ `ps auxwww | grep check_nfs.sh | wc -l` -gt 3 ]
echo `pgrep check_nfs.sh | wc -l`

if mount | grep -q $mnt_partition
then :

/root/bin/killmyparent.sh $ "Email Subject - eg : NFS mount failed on xxx server" "Some issue with $mnt_parition. Please check it will you !" &
killerpid=`pgrep killmyparent.sh`

# NFS file system appear to be mounted - lets check if we can access it ..
if df | grep -q $mnt_partition
then :
# df command works .. kill "killmyparent.sh" script before it kill us
kill $killerpid
exit 1;
# Wait until server is contactible and then mount the partition
until [ `ping -q -c3 -w5 $REMOTE_SERVER > /dev/null 2>&1; echo $?` -eq 0 ]
sleep 10;
mount $mnt_partition
exit $?


if [ -z $1 ]
echo "Usage $0 "
sleep 20
kill -9 $1
echo $3 | mail -s $2

Bind 9.2 RNDC Stats

Posted by Rianto Wahyudi

Installed bind DNS statistics last week by following  : http://jpastuszek.sigquit.net/2009/03/graphing-bind-query-statistics-with.html

The graphs looks pretty !

Bind DNS Statistics

DNS Statistics

success The number of successful queries made to the server or zone. A successful query is defined as query which returns a NOERROR response with at least one answer RR.
referral The number of queries which resulted in referral responses.
nxrrset The number of queries which resulted in NOERROR responses with no data.
nxdomain The number of queries which resulted in NXDOMAIN responses.
failure The number of queries which resulted in a failure response other than those above.
recursion The number of queries which caused the server to perform recursion in order to find the final answer.

Each query received by the server will cause exactly one of successreferralnxrrsetnxdomain, or failureto be incremented, and may additionally cause the recursion counter to be incremented.

Reference : http://www.networking-tips.net/?p=85

Nxdomain and NXrrset are new terms for me.


NXDOMAIN or Non-Existent Domain is a term used for the Internet domain name that is unable to be resolved using the DNS implementation owing either to domain name not yet registered or the server problem.

The reference to the NXDOMAIN is published in RFC 1035 (Domain names - implementation and specification) and also in RFC 2308 (Negative Caching of DNS Queries or referred to as DNS NCACHE).

Reference : http://it.toolbox.com/wiki/index.php/NXDOMAIN


Simple explanation  - NXRRSET means no such record set. The domain exist but record set does not exist. Look at the named cache dump below, it's clear that AAAA record for www.asx.com.au does not exist :

asx.com.au.             7293    NS      ns3.asx.com.au.
7293    NS      ns01.asx.com.au.
7293    NS      ns02.asx.com.au.
; additional
ns01.asx.com.au.        7293    A
; additional
ns02.asx.com.au.        7293    A
; glue
ns1.asx.com.au.         10893   A
; glue
ns2.asx.com.au.         10893   A
; glue
ns3.asx.com.au.         10893   A
; authauthority
www.asx.com.au.         93      \-AAAA  ;-$NXRRSET
; authanswer
7293    A
; authauthority
www9.asx.com.au.        99      \-AAAA  ;-$NXRRSET

Detailed information can be found : http://www.ietf.org/rfc/rfc2136.txt


Hello world!

Posted by Rianto Wahyudi

Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!

Filed under: Uncategorized No Comments