Christophe Casalegno

How to check if a dns zone is synchronized between 2 dns servers

>Hello World,

Sometime it can be useful to check if a domain is correctly synchronized on your master and slave dns servers. The easiest way to do this, is to simply compare the serial number between your 2 dns servers. That also can be useful to check about dns propagation in the internet.

For doing this we can simply use create a shell script like this :

#!/bin/sh
# Scomp : a simple dns serial comparator
# Author : Christophe Casalegno
# Email : brain@christophe-casalegno.com
# Twitter : @Brain0verride
#
# Usage : ./scomp.sh domaintotest.com firstdnserver secondnsserver
# Example : ./scomp.sh christophe-casalegno.com 8.8.8.8 8.8.4.4
# Example : ./scomp.sh digital-network.net mystra.digital-network.net baine.digital-network.net
ns1="$2"
ns2="$3"
serial='grep SOA |cut -d " " -f7'
domain=$1
a=`host -t SOA $domain $ns1 |grep SOA |cut -d " " -f7`
b=`host -t SOA $domain $ns2 |grep SOA |cut -d " " -f7`
if [ $a = $b ]
        then
                echo "$domain : synchro ok"
                echo "$ns1 serial : $a"
                echo "$ns2 serial : $b"
        else
                echo "$domain : Error"
                echo "$ns1 serial : $a"
                echo "$ns2 serial : $b"
fi

Now simply use ./scomp.sh to know if 2 dns servers (example : a master and a slave or 2 servers on Internet) are correctly synchronized.

Example :

Enjoy !

You can also directly download the script from here : scomp.sh

Christophe Casalegno
​Vous pouvez me suivre sur : Twitter | Facebook | Linkedin | Telegram | Youtube

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *