Note that there are some explanatory texts on larger screens.

plurals
  1. POBind9 DNS Zone Transfer Script - Bash script to avoid duplicates
    text
    copied!<p>I created a bash script to transfer my zones between my primary and secondary DNS server. It downloads my zone list from the primary and checks for any new zones and then downloads and inserts those zone files into the zone directory and into the .local file for bind.</p> <p>The problem I have is that if the zone file does not exist, the script will enter the details into the .local regardless of if this config already exists or not.</p> <p>Can someone help me out to distinguish between zones that already exist and simply download the zone file. I have pasted my script below and if anyone has any queries on how it works, please feel free to ask. (can someone wrap the code please, it never works properly for me in any browser I try!)</p> <pre><code>#!/bin/sh NAMED="/etc/bind/named.conf.local" TMPNAMED="/tmp/zns-441245.temp" TMPZONEFILE="/tmp/zones.txt" TMP="/tmp/zns-732.temp" ZONELOCATION="/var/cache/bind" IGNORE=`cat ignore.txt` logger DNS Update script running... echo -n "Checking for new named.conf... " wget -q http://91.121.75.205:10801/named/named.conf -O $TMPNAMED if [ -e $TMPNAMED ] then echo "done." else echo "no new data!" exit fi echo -n "Generating zone names... " grep "^zone" $TMPNAMED | cut -d " " -f "2" | cut -d "\"" -f 2 &gt; $TMPZONEFILE sed '1,5d' $TMPZONEFILE &gt; $TMP mv $TMP $TMPZONEFILE echo "done. ("$TMPZONEFILE")" echo "Generating zone info... " grep -vf ignore.txt $TMPZONEFILE | while read ZONE; do echo -n "Checking for $ZONELOCATION/$ZONE.db " if [ -e $ZONELOCATION/$ZONE.db ] then echo "[ exists ]" else export updates="yes" echo "[ doesn't exist ]" echo "New zone available ($ZONE)... " echo "zone \"$ZONE\" { type slave; file \"$ZONELOCATION/$ZONE.db\"; masters { 91.121.75.205; }; allow-notify { 91.121.75.205; }; };" &gt;&gt; $NAMED fi done echo "Updating Bind configuration... " /etc/init.d/bind9 restart rm $TMPZONEFILE rm $TMPNAMED </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload