DNS - Zone transfer template

Discussion in 'Installation/Configuration' started by Rein van 't Veer, Oct 18, 2015.

  1. Hi,
    I've been looking for a way to automate my zone transfers and created a script on my super small vps server see below. (just sharing to the community).

    Code:
    #!/bin/bash
    
    ns1ip="78.46.201.44"
    bindlogfile=/var/log/bind.log
    slavezonefile=/etc/bind/named.conf.slave-zones
    # Check if any non autoritive notifies have been received in the last 5 minutes
    # This is how a not authoritative line looks like
    # 17-Oct-2015 20:12:02.175 notify: client 78.46.201.44#9854: received notify for zone 'reinencaressa.be': not authoritative
    # try to grep and get the line in the file that contains "not authoritative"
    addtozonefile=$(grep "not authoritative" $bindlogfile | grep $ns1ip | cut -d\' -f2)
    
    for domain in ${addtozonefile[@]}; do
        # Do nothing if the zone already exists
        if grep -q $domain "$slavezonefile"; then
            echo "Zone already exists"
        else
            # Add domain to slave zone
    cat <<EOT >> $slavezonefile
    zone "$domain" {
        type slave;
        masters { $ns1ip; };
        file "/etc/bind/slaves/$domain";
    };
    EOT
    rndc reconfig
        fi
    done
    exit
    This script will check my logfile for non authoritative entries in the log file and act accordingly.

    Now I want to add my ns2 server ip in the allow-transfer for every domain so that I can actually transfer after sending the notify.

    I've been looking on the net and found that it was implemented to add into the template at version 3.0.4 but cannot find what I exactly need to put in to add the ns2 ip in the allow-transfer automatically with the dns wizard.

    Anyone an idea?
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    The field in the wizard config field is named "xfer", just add like this:

    xfer=192.168.1.1

    Btw: Why do you do zone transfers manually with that script? ISPConfig has a builtin mirroring feature for zone transfers that supports any number of dns servers.
     
  3. i'm not aware? ^^ can you give me some pointers?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Add 2 dns servers as slaves to your ispconfig master. Then go to system > Server services in ispconfig, edit the second server and set the first dns server in the field" Is mirror of server" and press safe. That's all. You can add also a ns3, ns4 etc. this way. ISPConfig takes care to mirror all dns records of the first server to the other ones automatically.
     
  5. does the second dns server need to have ispconfig as well than? it's just an extremely light (128mb ram, 64 mb swap machine), so no install of ispconfig worthy
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Yes.
    This is an ispconfig slave without interface, so 128MB are enough. It just has to run mysql (switch off innodb to use less ram) and php-cli. See dns node install instructions in multiserver setup guide.
     
  7. i'll look into this for sure... I just presumed there was no way around installing all on ispconfig :)
     
  8. ressel

    ressel Member

    I use the ispconfig mirror function for several years. Today i have 5 NS in total. Works perfect.
     
  9. yes, got this working perfectly as well, topic can be closed :)
     
    ressel likes this.

Share This Page