1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Nameserver setup on 2 Plesk servers

Discussion in 'Plesk for Linux - 8.x and Older' started by wintech2003@, Dec 5, 2006.

  1. wintech2003@

    wintech2003@ Guest

    0
     
    Hello,

    I have two Plesk servers, one with Plesk 8.1 for Linux and one with Plesk 8.1 for Windows.

    Currently when a customer wants to be hosted on the Linux server I tell him to use ns1.mycompany.com and ns2.mycompany.com

    If he wants to be hosted on the Windows server, I tell him to use ns3.mycompany.com and ns4.mycompany.com

    What do I have to do in order to synchronize DNS between the two servers eg. every 15 minutes, name the Linux server as ns1.mycompany.com and the Windows server as ns2.mycompany.com so that I always give ns1.mycompany.com and ns2.mycompany.com no matter on which server somebody wants to be hosted?

    In short what I want to do is that both servers host the DNS records for all domains, Windows and Linux ones.

    Any ideas on how I can do this?

    Thanks a lot,
    wintech2003
     
  2. Datalux

    Datalux Guest

    0
     
    there is a litle script i use to update my two ns server, primerie with plesk secd. no plesk.

    PHP:
    #!/usr/bin/perl
    ###############################################################################
    ## $Id: secondaryupdate.pl,v 1.1 2004/12/16 21:54:23 web0 Exp $
    ##  ------------------------------------------------------------------------ ##
    ##          SecondaryUpdate.pl - Add Zoneconfigs from PLESK dBase            ##
    ##                  Copyright (c) 2004 Dennis Paulisch                       ##
    ##                   <[url]http://www.blitzengineers.net/[/url]>                        ##
    ##  ------------------------------------------------------------------------ ##
    ##  This program is free software; you can redistribute it and/or modify     ##
    ##  it under the terms of the GNU General Public License as published by     ##
    ##  the Free Software Foundation; either version 2 of the License, or        ##
    ##  (at your option) any later version.                                      ##
    ##                                                                           ##
    ##  You may not change or alter any portion of this comment or credits       ##
    ##  of supporting developers from this source code or any supporting         ##
    ##  source code which is considered copyrighted (c) material of the          ##
    ##  original comment or credit authors.                                      ##
    ##                                                                           ##
    ##  This program is distributed in the hope that it will be useful,          ##
    ##  but WITHOUT ANY WARRANTY; without even the implied warranty of           ##
    ##  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            ##
    ##  GNU General Public License for more details.                             ##
    ##                                                                           ##
    ##  You should have received a copy of the GNU General Public License        ##
    ##  along with this program; if not, write to the Free Software              ##
    ##  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA ##
    ##  ------------------------------------------------------------------------ ##
    ###############################################################################

    # Needed Perl Modules
    use strict;
    use 
    warnings;
    use 
    DBI;

    ######## CONFIGURATION ########################################################

    my $dbname      "psa";                                 # PLESK Database
    my $username    " ";                        # User for query only the DNS->Domain
    my $pw          " ";                             # Password
    my $dbhost      " ";                      # PLESK DB Host
    my $masters     " ";                      # IP Of Primary Master Nameserver
    my $namedreload "/etc/init.d/bind9 reload";            # Command to Reload the Named Config
    my $configfile  "/etc/bind/named.plesksec";   # Named Include File

    ###############################################################################
    print "\n";
    print 
    "SecondaryUpdate Started\n";

    ### MAIN ######################################################################

    # Define Variables
    my $sql$dbconnect$select$date) = ();
    my @domain = ();

    # Open Database Connection
    $dbconnect DBI->connect("DBI:mysql:database=$dbname:host=$dbhost""$username""$pw", { PrintError => 0RaiseError => })
                 or die 
    "Can't connect to sql server. Reason: $DBI::errstr";

    # Query the Primary Domains from PLESK Database
    $sql="select displayName from domains";
    $select=$dbconnect->prepare($sql);
    $select->execute
    or die "Can't execute statement $sql: Reason: $DBI::errstr\n";

    # Get the current Date and Time
    $date=gmtime();

    # Write Zone Config
    open (ZONEFILE">$configfile") || die("Could not write file!");

    print 
    ZONEFILE "####         Zone Config created by SecondaryUpdate.pl          ####\n";
    print 
    ZONEFILE "####          File Created: $date            ####\n";
    print 
    ZONEFILE "#### Written by Dennis Paulisch <[url]http://www.blitzengineers.net[/url]> ####\n\n\n";

    while( @
    domain $select->fetchrow_array)
    {
        print 
    "- $domain[0] added\n";
        print 
    ZONEFILE "zone \"$domain[0]\" in {\n";
        print 
    ZONEFILE "    masters {$masters;};\n";
        print 
    ZONEFILE "    type slave;\n";
        print 
    ZONEFILE "    file \"slave/$domain[0].db\";\n";
        print 
    ZONEFILE "};\n";
        print 
    ZONEFILE "\n";
    }
    close (ZONEFILE);

    print 
    "\nfinished...\n";

    # Close DB Connection
    $select-> finish;
    $dbconnect->disconnect;

    system($namedreload " >/dev/null");

    ### END #####################################################################
    exit 0;

    maybe it can help you
     
  3. Datalux

    Datalux Guest

    0
     
    german install doc

    Secondary.pl Install HowTo:
    ===========================

    1.) MySQL Zugang Extern

    Auf dem Server mit Plesk:
    Einen MySQL User anlegen z.b.: secondaryns.
    Dieser User sollte keine Berechtigung haben. Nur unter Datenbankspezifische Rechte, sollten
    die Tabellenspezifische Rechte auf Select "Domains" gesetzt werden.
    Natürlich sollte dieser auch nur von einem Bestimmen Host sich anmelden dürfen.


    2.) Secondary Nameserver

    Secondary.pl in einen sicheren Verzeichnis unterbringen z.b. unter "/root"
    secondary.pl mit "chmod 755 secondary.pl" ausführbar machen.

    Jetzt kann secondary.pl Konfiguriert werden. z.B. mit VI Folgende Abschnitte anpassen

    ######## CONFIGURATION ########################################################

    my $dbname = "psa"; # PLESK Database
    my $username = "secondarydns"; # User for query only the DNS->Domain
    my $pw = "xxxxxxx"; # Password
    my $dbhost = "xxx.xxx.xx.xxx"; # PLESK DB Host
    my $masters = "xxx.xxx.xx.xxx"; # IP Of Primary Master Nameserver
    my $namedreload = "/etc/init.d/named reload"; # Command to Reload the Named Config
    my $configfile = "/var/lib/named/etc/named.plesksec"; # Named Include File

    ###############################################################################

    Wenn named im chroot läuft muss einfach noch mit "touch //etc/named.plesksec" eine Dummy datei angelegt werden
    das sonst Bind nicht mehr neustartet.

    Jetzt am besten erstmal Testen ob die Einstellungen auch funktioniert
    ./secondary.pl aufrufen und Meldungen beachten.
    Nun kann man nochmals die Datei anschauen die unter $configfile in der Konfiguration angelegt wurden.


    Wenn alles funktioniert hat, einfach in der /etc/named.conf folgende Zeilen am Ende einfügen

    ## PSA SECONDARY ZONES
    include "/etc/named.plesksec";
    ## /PSA

    Danach named wieder mit "/etc/init.d/named restart" neustarten.

    Nun kann man z.b. das script mit Crontab zu geregelten Zeiten starten lassen. Das Script veranlasst
    named bei dem durchlauf seine Konfiguration neu einzulesen.


    -------------------------------
    Dennis Paulisch
    <http://www.blitzengineers.net
     
  4. wintech2003@

    wintech2003@ Guest

    0
     
    Thank you Datalux.

    It's a good thing I know some German :D
    I had a 2 week lesson for Mittlestufe at the CDC Centers in Radolfzell :cool:

    I will check it tonight and let you know.

    Thanks again.
     
  5. society

    society Guest

    0
     
  6. wintech2003@

    wintech2003@ Guest

    0
     
    So with this script I can setup two BIND servers (with no control panel) name them ns1.mycompany.com and ns2.mycompany.com and setup this script on each one to fetch the DNS Records from my Plesk servers.

    Then I can have as many Plesk servers as I want only by creating a new .pl file for each server (and of course different named include files as destination)

    Very nice :))) actually that is a better solution that the one I was looking for in my first post since with this one I can have as many Plesk servers as I want.

    society: Do you know if I can fetch DNS Records from a Windows Plesk 8.1 server with the same script?

    Again thanks a lot :)
     
  7. society

    society Guest

    0
     
    Hmmm i dont know ;-)
    I never saw the windows version. maybe try it out
     
  8. dimensions

    dimensions Basic Pleskian

    24
    57%
    Joined:
    Aug 28, 2002
    Messages:
    50
    Likes Received:
    0
    Can someone translate this in english please...I am stumped
     
  9. wintech2003@

    wintech2003@ Guest

    0
     
    society:

    I used the script, and it created the Named Include File successfully.

    Now my ns1 server fetches the records from the Plesk server and so It can also respond for the domains of the plesk server :)

    Great :)


    dimensions: I will post an english version of the instructions tomorrow.
     
  10. society

    society Guest

    0
     
    Great ;-)
     
  11. wintech2003@

    wintech2003@ Guest

    0
     
    dimensions, here is a (bad :p ) translation of the German instructions.
    I hope they will help you:

    Secondary.pl Install HowTo:
    ===========================

    1.) MySQL Access Rights

    On your Plesk server:
    Create a MySQL user eg.: secondarydns
    Using phpmyadmin, grant this user the SELECT option only for the table domains of the psa database.
    Also for maximum security you should set the hostname from which this user will logon.

    2.) Secondary Nameserver

    Copy secondary.pl to a secure directory eg. "/root"
    Make secondary.pl executable by issuing the following command "chmod 755 secondary.pl"

    Now you can configure secondary.pl using vi in the following area

    ######## CONFIGURATION ##################################################
    ######

    my $dbname = "psa"; # PLESK Database
    my $username = "secondarydns"; # User for query only the DNS->Domain
    my $pw = "xxxxxxx"; # Password
    my $dbhost = "xxx.xxx.xx.xxx"; # PLESK DB Host
    my $masters = "xxx.xxx.xx.xxx"; # IP Of Primary Master Nameserver
    my $namedreload = "/etc/init.d/named reload"; # Command to Reload the Named Config
    my $configfile = "/var/lib/named/etc/named.plesksec"; # Named Include File

    ##################################################
    #############################

    I you run a chrooted version of BIND issue the command "touch //etc/named.plesksec" to create
    a Dummy file.

    Now you can test your script configuration by issuing the command:
    ./secondary.pl
    If everything went fine, you must also be able to view the created file under $configfile

    Now you can add the following lines to your /etc/named.conf file

    ## PSA SECONDARY ZONES
    include "/etc/named.plesksec";
    ## /PSA

    Finally restart named by issuing "/etc/init.d/named restart"

    You can also set the script to run with crontab. The script will automatically restart
    named every time it is run in order for it to re-read it's configuration.
     
  12. Datalux

    Datalux Guest

    0
     
    was ist den neu in der neuen Version des scripts??

    [what is new on the new Version of the script]

    (never touch a running system) :D
     
  13. society

    society Guest

    0
     
    Umlaut Domains und alias Domains
     
  14. wintech2003@

    wintech2003@ Guest

    0
     
    I'm a bit confused... :confused:

    Is it normal that when using nslookup to query the secondary DNS server (the one that fetches the DNS records from Plesk) for a domain that is hosted on the Plesk server that I get a Non-authoritative answer?
     
  15. wintech2003@

    wintech2003@ Guest

    0
     
    Had to check everything from the beginning and now everything runs fine :)

    I'm getting authoritative responses for all plesk domains from my secondary server :cool:
     
  16. society

    society Guest

    0
     
    Great... nice to hear that it works
     
  17. xtreme2490

    xtreme2490 Guest

    0
     
    I'm getting in var/log/messages

    Feb 5 21:09:31 zeus named[19189]: dumping master file: slave/tmp-XXXXpqtY7O: open: file not found
    Feb 5 21:09:31 zeus named[19189]: transfer of 'kleuterschoolvennen.be/IN' from 85.158.211.6#53: failed while receiving responses: file not found
    Feb 5 21:09:31 zeus named[19189]: transfer of 'kleuterschoolvennen.be/IN' from 85.158.211.6#53: end of transfer

    My secondaryupdate.pl contains :

    my $dbhost = "85.158.211.6"; # PLESK DB Host
    my $masters = "85.158.211.6"; # IP Of Primary Master Nameserver
    my $namedreload = "/etc/init.d/named reload"; # Command to Reload the Named Config
    my $configfile = "/var/named/run-root/var/named.plesksec"; # Named Include File

    In /etc/named.conf i've added
    ## PSA SECONDARY ZONES
    include "named.plesksec";
    ## /PSA

    Can someone help.

    Both servers are Plesk 8.1.0 on FC4
     
  18. society

    society Guest

    0
     
    Do you have a working Bind on the Secondary Server?
    Exists the slave Directories?
     
  19. nulleffect

    nulleffect Guest

    0
     
    Why don't you just setup a VPS for dedicated nameservers, use the one VPS for both boxes DNS?
     
Loading...