Commit 8724a537 authored by Stephen Morris's avatar Stephen Morris
Browse files

[1213] Compare zones after update instead of just the SOA serial

parent f5b0e46b
......@@ -23,3 +23,6 @@ rm -f ns1/named.memstats
rm -f nsx2/bind10.run
rm -f nsx2/zone.sqlite3
rm -f client.dig
rm -f server.dig
......@@ -81,6 +81,6 @@ do_rndc $SERVER_NAME $SERVER_IP notify example
# Wait for the client to update itself.
wait_for_update $CLIENT_NAME $CLIENT_IP $old_client_serial
# Has updated, get the latest serial of the client and server - they
# Has updated, compare the client and server's versions of the zone s- they
# should be the same.
compare_soa $SERVER_NAME $SERVER_IP $CLIENT_NAME $CLIENT_IP
compare_zones $SERVER_NAME $SERVER_IP $CLIENT_NAME $CLIENT_IP
......@@ -94,19 +94,18 @@ do_rndc () {
| sed "s/^/I:$name /"
}
# wait_for_update
# \brief Wait for update
#
# Given a serial number and a server, poll the nameserver until the SOA serial
# number is different from that given. The poll takes place every five seconds
# for a minute.
#
# $1 - Name of the server
# $2 - IP address of the server
# $3 - Serial number to check against
# \arg $1 - Name of the server
# \arg $2 - IP address of the server
# \arg $3 - Serial number to check against
#
# Returns:
# 0 - Serial number is different (requires another poll to obtain it)
# 1 - Serial number has not changed
# \return 0 if the serial number is different (requires another poll to obtain
# it), 1 if the serial number has not changed.
wait_for_update() {
# If the following checks fail, the code is wrong.
......@@ -115,7 +114,8 @@ wait_for_update() {
if [ $? -ne 0 ];
then
echo "R:FAIL wait_for_update - name or ip address of system not supplied"
return 1
return 1t
fi
name=$1
......@@ -133,7 +133,8 @@ wait_for_update() {
# Now poll the server looking for the new serial number
for i in 1 2 3 4 5 6 7 8 9 10 11 12
echo "I:waiting for SOA serial of $name to change from $serial"
for i in `seq 1 12`
do
if [ $i -gt 1 ];
then
......@@ -153,15 +154,15 @@ wait_for_update() {
# update_server_zone
# \brief Update server zone
#
# Reloads the example. zone in the BIND 9 IXFR server and waits a maximum of
# one minute for it to be served.
#
# $1 - Name of the server (ns1, nsx2 etc.)
# $2 - IP address of the server
# $3 - Zone file to load
# $* - Command to execute (which may be multiple tokens)
# \arg $1 - Name of the server (ns1, nsx2 etc.)
# \arg $2 - IP address of the server
# \arg $3 - Zone file to load
# \arg $* - Command to execute (which may be multiple tokens)
update_server_zone() {
# If the following checks fail, the code is wrong.
......@@ -263,3 +264,59 @@ compare_soa() {
return 0
}
# \brief Compare client and server zones
#
# Checks the zones of two systems and reports if they are not identical.
#
# The check is simplistic. The zones are listed via "dig" and comment lines,
# blank lines and spaces/tabs are removed, then the output sorted. The two
# files are then compared. They should be identical.
#
# \arg $1 Name of the IXFR server
# \arg $2 IP of the IXFR server
# \arg $3 Name of the IXFR client
# \arg $4 IP of the IXFR client
#
# \return 0 if the zones are the same, 1 if not.
compare_zones() {
# If the following checks fail, the code is wrong.
check_name_ip $*
if [ $? -ne 0 ];
then
echo "R:FAIL compare_zones - name or ip address of server not supplied"
return 1
fi
server_name=$1
shift
server_ip=$1
shift
check_name_ip $*
if [ $? -ne 0 ];
then
echo "R:FAIL compare_zones - name or ip address of client not supplied"
return 1
fi
client_name=$1
shift
client_ip=$1
shift
$DIG @$client_ip example. axfr | grep -v '^;' | grep -v '^$' \
| sed -e 's/ //g' -e 's/\t//g' > client.dig
$DIG @$server_ip example. axfr | grep -v '^;' | grep -v '^$' \
| sed -e 's/ //g' -e 's/\t//g' > server.dig
diff client.dig server.dig
if [ $? -ne 0 ];
then
echo "R:FAIL client $client_name zone not same as server $server_name zone"
return 1
fi
return 0
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment