Automate DNS slave creation

Discussion in 'Tips/Tricks/Mods' started by jorizzzz, Sep 17, 2007.

  1. jorizzzz

    jorizzzz New Member

    i've got two servers here, each one has an installation of ISPConfig installed. Server1 is my webserver and is the master for the dns, Server2 is the slave.

    Is it possible to automate the creation of the slave entries on the second ISPConfig server? At this point, whenever a reseller of mine adds a new domain, i've got to logon the second server and add the slave entry manually.

    The updates are being pushed perfectly, all that is working. Only the creating of the slave entries is a problem at this time...

    Could somebody help me?
     
  2. mlz

    mlz Member

    This is where MyDNS would be handy, you would just point both DNS servers to the same MySQL database (replicated of course) and let it run, both would have the same zones and records files(so to speak) available. Basically you need to figure out a way to pass from Server A to Server B, the names of the domains to replicate/create in named.conf and let it do it's thing. A simple set of php scripts could do the heavy lifting, but be sure to lock down the security such that only the two machines can talk to each other.

    I would expect you would have to at least put a call into the ISPConfig code to run said script however... I'm not sure where, since I've about given up on hacks to ISPConfig 2.x hacks, everytime I do it, I upgrade and forget to back up my hacks.. :D
     
  3. grant

    grant New Member

    To have it run a script when you update something, add the script to the end of:

    /root/ispconfig/scripts/writeconf.php

    Add things write above the line that says:

    Code:
    echo "ende\n";
    And, if you're hacking about in ISPConfig's files, remember to at least keep a list of every file you've changed (or better, copy the original file to a save location, as "filename.original" and when done, copy the new one there as "filename.new" so you can run diff on them to see what changes you need to make when you upgrade).
     
  4. crayz1

    crayz1 New Member

    I am interested in this as well.

    I posted a topic in the Installation forum
    http://www.howtoforge.com/forums/showpost.php?p=87979&postcount=7

    Basically I have a web server with ISPConfig and Master/Slave DNS machines. I want the ISPConifg web server to manage the creation of DNS zones and send it to my DNS machines. I was thinking that my DNS machines both need to act as slaves to the ISPConfig web server, but when resolving name servers on the web the DNS machines would play their Master/Slave role.
     
  5. mccharlet

    mccharlet Member HowtoForge Supporter

    Hi,

    I have not solution for autocreate au dns zone
     
    Last edited: Oct 1, 2007
  6. lewis_saint

    lewis_saint New Member

    I came up with a solution to this problem a number of months ago. I have ISPConfig running on one server, and bind on its own on another. My working setup is as follows:
    1. A cronjob daily runs the following on my ISPConfig box:
    Code:
    grep "^zone" /etc/bind/named.conf | grep -v "arpa" | awk -F \" '{print $2}' | awk 'length > 1' > /etc/bind/slave-zones
    scp /etc/bind/slave-zones slave-dns@bind9box:slave-zones > /dev/null
    
    Using SSH keys, a file of all of my domains is created on the secondary box daily.

    2. A cronjob daily runs the following on my secondary box:
    Code:
    echo > /etc/bind/slave-zones.conf
    for i in `cat /home/slave-dns/slave-zones`; do
    echo "zone \"$i\" {"                      >> /etc/bind/slave-zones.conf
    echo "  type slave;"                >> /etc/bind/slave-zones.conf
    echo "  file \"slave.$i\";"         >> /etc/bind/slave-zones.conf
    echo "  masters { 123.123.123.123; };"      >> /etc/bind/slave-zones.conf
    echo "  notify no;"  >> /etc/bind/slave-zones.conf
    echo "};"                                 >> /etc/bind/slave-zones.conf
    echo                                      >> /etc/bind/slave-zones.conf
    done
    
    /etc/init.d/bind9 restart > /dev/null
    
    I have bind9 including /etc/bind/slave-zones.conf in my configuration file.

    Let me know how you get on!
     
  7. jorizzzz

    jorizzzz New Member

    This looks like a stable solution, i'll give it a go. Thanks a million times :)

    Question tho... Won't this result in a very long list on the slave server with duplicate entries? It exports the entire master server every time...
     
    Last edited: Oct 8, 2007
  8. zeeman

    zeeman New Member

    I prefer keeping dead threads dead, but to complete the last question:
    No. It doesn't:
    Code:
    echo > /etc/bind/slave-zones.conf
    Before every run the slave-zones.conf is flushed.
     

Share This Page