Magazine Humeur

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

Publié le 12 avril 2017 par Christophe_casalegno

>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 :
How to check if a dns zone is synchronized between 2 dns servers

Enjoy !

You can also directly download the script from here : scomp.sh
-
Christophe Casalegno
https://twitter.com/Brain0verride


Retour à La Une de Logo Paperblog

A propos de l’auteur


Christophe_casalegno 1901 partages Voir son profil
Voir son blog

l'auteur n'a pas encore renseigné son compte l'auteur n'a pas encore renseigné son compte l'auteur n'a pas encore renseigné son compte

Magazines