27Nov/100

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
./checkhost
Usage: ./checkhost <IP or hostname> checkhost<IP or hostname> ...
Example: ./checkhost 69.163.128.215 www pop3.iinet.net.au
This script will check if forward and reverse match

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

Download the script here :

checkhost
17Nov/101

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 :

#!/bin/bash
# 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 )

REMOTE_SERVER=remotenfsserver.example.com
mnt_partition=/remote/nfs/folder/

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

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;
fi
else
# Wait until server is contactible and then mount the partition
until [ `ping -q -c3 -w5 $REMOTE_SERVER > /dev/null 2>&1; echo $?` -eq 0 ]
do
sleep 10;
done
mount $mnt_partition
exit $?
fi

killmyparent.sh

#!/bin/bash
if [ -z $1 ]
then
echo "Usage $0 "
exit
fi
sleep 20
kill -9 $1
echo $3 | mail -s $2
15Nov/101

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 :

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

NXRRSET :

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       203.15.147.70
; additional
ns02.asx.com.au.        7293    A       203.15.147.74
; glue
ns1.asx.com.au.         10893   A       203.15.147.70
; glue
ns2.asx.com.au.         10893   A       203.15.147.70
; glue
ns3.asx.com.au.         10893   A       203.15.147.74
; authauthority
www.asx.com.au.         93      \-AAAA  ;-$NXRRSET
; authanswer
7293    A       203.15.147.66
; authauthority
www9.asx.com.au.        99      \-AAAA  ;-$NXRRSET

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

11Nov/100

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