Christophe CasalegnoAutoimmune warrior, Entrepreneur & Bio/Hacker

brain@127.0.0.1:~$ cat post.html

How to check whether a domain is correctly synchronised between two DNS servers

Historical archive · Superseded toolScomp has been replaced by SxSerialCheck. This article preserves the original code and explanations.

>Hello World,

Sometimes it can be useful to check whether a domain is correctly synchronised on your master and slave DNS servers. The simplest way to do that is to compare the zone’s serial numbers on the two DNS servers. You can also use this method to see how the domain’s DNS propagation is progressing across the Internet.

To do that, we can write a very simple 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 run ./scomp.sh to find out whether two DNS servers are correctly synchronised.

Example:

Enjoy !

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

--
Christophe Casalegno
https://all.bo

Leave a comment

Add a comment
Christophe Casalegno Brain 0verride

Keep it simple
and direct!