OPS335 A2 Summer 2015 Tips

From CDOT Wiki
Jump to: navigation, search

How to test your secondary DNS ?

test_items="scs.senecac.on.ca www.senecac.on.ca matrix.senecac.on.ca zenit.senecac.on.ca"
pri_dns_ip=142.204.33.53
sec_dns_ip=142.204.33.54

for test_item in $test_items
do
    PRI_ANS=$(nslookup -query=A $test_item $pri_dns_ip | grep -v $pri_dns_ip | grep Address | awk '{print $2}')

    #cho $PRI_ANS

    SEC_ANS=$(nslookup -query=A $test_item $sec_dns_ip | grep -v $sec_dns_ip | grep Address | awk '{print $2}')
  
    echo "Testing item: $test_item"
    echo "Test Result from Primary DNS server: $pri_dns_ip -> $PRI_ANS"
    echo "Test Result from Secondary DNS server: $sec_dns_ip -> $SEC_ANS"

    [ "$SEC_ANS" = "$PRI_ANS" ] && echo match
done

How to create a tar ball file for a list of files from a text file?

Text file: pri-dns-file-list

/etc/named.conf
/var/named/mydomain.db
/var/named/myip-rev.db

Text file: sec-dns-file-list

/etc/named.conf

Text file: mas-nis-file-list

/etc/sysconfig/network
/var/yp/Makefile
/var/yp/nisdomain/*

Text file: sla-nis-file-list

/etc/sysconfig/network
/var/yp/Makefile

Backup Script

Name: backup.sh

Contents:

if [ $# -lt 2 ]
then
    echo "Usage: backup.sh file-list file-type
    exit 1
fi
filelist=$1
type=$2
tarball_file=$(date +%Y%M%D)-${type}.tar
tar cvf ${tarball_file} -T ${filelist}

To create a tar ball file on the Primary DNS server, you can run the following command:

backup.sh pri-dns-file-list master