#!/bin/ksh
# Import NS Servers, version 0.1
# Author - Dennis Hosang
# Usage: ./importns.ksh domains.txt 3(ns1-3) OR 5(ns1-5)
#for DOMAIN in `cat $1`
while IFS=\, read DOMAIN NS
do
echo "BEGIN $DOMAIN"
echo "Add $DOMAIN to QIP"
echo "Create input file"
echo "Zone=$DOMAIN" > input.txt
if [[ $NS == 3 ]]; then
echo "dnsServers=QIPDNSMASTER001.hosangit.com P 0,ns1.hosangit.com S 0,ns2.hosangit.com S 0,ns3.hosangit.com S 0" >> input.txt
elif [[ $NS == 5 ]]; then
echo "dnsServers=QIPDNSMASTER001.hosangit.com P 0,ns1.hosangit.com S 0,ns2.hosangit.com S 0,ns3.hosangit.com S 0,ns4.hosangit.com S 0,ns5.hosangit.com S 0" >> input.txt
fi
echo "RefreshTime=3600" >> input.txt
echo "ExpirationTime=604800" >> input.txt
echo "RetryPeriod=1800" >> input.txt
echo "MinimumTTL=3600" >> input.txt
echo "NegativeCacheTTL=300" >> input.txt
echo "ZoneMail=IPSE-InfrastructureMgmt@hosangit.com" >> input.txt
echo "Extensions" >> input.txt
echo " Prefix of zone db file=" >> input.txt
echo " Postfix of zone db file=" >> input.txt
echo "BIND-8.X Options" >> input.txt
echo " allow-query=Any" >> input.txt
echo " allow-transfer=Any" >> input.txt
echo " allow-update=Any" >> input.txt
echo " check-names=Warn" >> input.txt
echo " notify=Yes" >> input.txt
echo " also-notify= " >> input.txt
echo " zone block of named.conf=" >> input.txt
echo "BIND-9.X Options" >> input.txt
echo " allow-notify=Use Server Value" >> input.txt
echo " allow-query=Any" >> input.txt
echo " allow-transfer=Any" >> input.txt
echo " allow-update=Use Server Value" >> input.txt
echo " notify=Yes" >> input.txt
echo " zone block of named.conf=" >> input.txt
echo "LUCENT DNS 3.X Options" >> input.txt
echo " Import External Updates=False" >> input.txt
echo " allow-query=Any" >> input.txt
echo " allow-transfer=Any" >> input.txt
echo " allow-update=Any" >> input.txt
echo " check-names=Warn" >> input.txt
echo " notify=Yes" >> input.txt
echo " also-notify=" >> input.txt
echo " zone block of named.conf=" >> input.txt
echo "LUCENT DNS 4.X Options" >> input.txt
echo " Import External Updates=False" >> input.txt
echo " allow-notify=Use Server Value" >> input.txt
echo " allow-query=Any" >> input.txt
echo " allow-transfer=Any" >> input.txt
echo " allow-update=Any" >> input.txt
echo " notify=Yes" >> input.txt
echo " also-notify=" >> input.txt
echo " zone block of named.conf=" >> input.txt
echo "WINDOWS 2000 DNS Options" >> input.txt
echo " aging=False" >> input.txt
echo " allow-transfer=Use List" >> input.txt
echo " List=" >> input.txt
echo " allow-update=No" >> input.txt
echo " no-refresh-interval=0" >> input.txt
echo " notify=Use List" >> input.txt
echo " List=" >> input.txt
echo " refresh-interval=0" >> input.txt
echo " zone-options=" >> input.txt
echo "input.txt created for $DOMAIN"
echo "Run qip-setzoneprof to import NS servers for $DOMAIN"
/qip/usr/bin/qip-setzoneprof -n $DOMAIN -u qipusr -p pass1234 -s enterprise -g 192.168.24.76 -o "HPES Internet" -f input.txt
echo "Create input2.txt for Stealth Server Setting for $DOMAIN"
echo "INSERTDOMAINHERE" > QIPDNSMASTER001-input2.txt
echo "Primary=QIPDNSMASTER001.hosangit.com" >> QIPDNSMASTER001-input2.txt
echo "Secondary=" >> QIPDNSMASTER001-input2.txt
echo "BIND-9.X Options=Use Zone Value" >> QIPDNSMASTER001-input2.txt
echo "Stealth Server=True" >> QIPDNSMASTER001-input2.txt
echo "Done creating input2.txt"
echo "Setting Stealth Server option for $DOMAIN"
/bin/sed "s/INSERTDOMAINHERE/$DOMAIN/g" QIPDNSMASTER001-input2.txt > ./output/QIPDNSMASTER001."$DOMAIN"
/qip/usr/bin/qip-setzoneserveroptions -u qipusr -p pass1234 -s enterprise -g 192.168.24.76 -o "HPES Internet" -t domain -f ./output/QIPDNSMASTER001."$DOMAIN"
echo "FINISHED with $DOMAIN"
echo "-----------------------------------------------------------------"
done <$1
####
250.26.192.in-addr.arpa,3
251.26.192.in-addr.arpa,3
252.26.192.in-addr.arpa,3
253.26.192.in-addr.arpa,3
254.26.192.in-addr.arpa,3
hosangit.com
djzah.com
####
#!/bin/ksh
#
#while read INPUT ; do
for INPUT in `cat ${1}`
do
if [[ $INPUT == *.in-addr.arpa ]]; then
IFS=. read -a Array <<< "$INPUT"
#echo "$IFS" # notice that IFS didn't change afterwards
if [[ ${Array[4]} == arpa ]]; then
domain="${Array[2]}.${Array[1]}.${Array[0]}.0/24"
elif [[ ${Array[3]} == arpa ]]; then
domain="${Array[1]}.${Array[0]}.0.0/16"
fi
else
echo "Whoops"
fi
echo $1
echo $domain
done <$1
####
./parseip.ksh[6]: read: -a: unknown option
Usage: read [-Aprsv] [-d delim] [-u fd] [-t timeout] [-n nbyte] [-N nbyte]
[var?prompt] [var ...]