• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

How to get a plesk linux and plesk windows server to run secondary dns for each other

E

egate

Guest
Firstly these are just my rough notes so there are probably error and omissions, but worked for me... etc etc..... This could easily be change for 2 windows servers.

windows 2003 web edition running plesk 7
linux fedora core 1 running reloaded

Based on http://www.atomicrocketturtle.com/m...ns&file=index&req=viewarticle&artid=17&page=1 - great stuff

Step 1) add the following line to /etc/named.conf on both servers:
include "/etc/secondaries.include";

for windows:

(d: being the apporiate drive)

in include D:\program files\SWsoft\Plesk\dns\etc\named.conf add

include "D:\program files\SWsoft\Plesk\dns\etc\secondaries.include";

Step 2) install the following 2 scripts into /var/named/run-root/etc
gen-secondaries.sh This generates the secondaries.include file for your secondary server(s)
xfer-config.sh This downloads the secondaries.include from the master server(s).
You will need to edit the line "MASTER=CHANGEME" in both files, where CHANGEME is the IP address of the master server.

for windows:
get http://unxutils.sourceforge.net/

Put files you want in c:\windows (or wherever)
Interperter needed:
sh.exe

commands needed
chmod
mv
rm
cat
wget
egrep
gawk
sleep (probably not needed)

(nb for the scripts below there are a few small changes that are needed awk -> gawk, \ ->/, \ ->\\, things like that)

gen-secondaries.sh - on a linux master for windows slave

added WIN_NAMED_ROOT
------------start---------
#!/bin/sh

MASTER=w.x.y.z
NAMED_ROOT=/var/named/run-root/etc
HTTPDOCS=/home/httpd/vhosts/default/htdocs/
WIN_NAMED_ROOT='D:\program files\SWsoft\Plesk\dns\var'

egrep "^zone" $NAMED_ROOT/named.conf |egrep -iv "arpa|\"\." | awk -F\" '{print $2}' > $NAMED_ROOT/domains

echo > $HTTPDOCS/secondaries.include
for i in `cat $NAMED_ROOT/domains`; do
echo "zone \"$i\" {" >> $HTTPDOCS/secondaries.include
echo " type slave;" >> $HTTPDOCS/secondaries.include
echo " file \"$WIN_NAMED_ROOT\slave\\$i\";" >> $HTTPDOCS/secondaries.include
echo " masters { $MASTER; };" >> $HTTPDOCS/secondaries.include
echo " allow-transfer { none; };" >> $HTTPDOCS/secondaries.include
echo "};" >> $HTTPDOCS/secondaries.include
echo >> $HTTPDOCS/secondaries.include
done

chmod 644 $HTTPDOCS/secondaries.include

---------end-----------


xfer-config.sh on windows slave
error checking has been removed as have no stat
----------start-----------------
#!/bin/sh

MASTER=w.x.y.z
FILE=secondaries.include

wget http://$MASTER/$FILE -O $FILE.tmp


mv -f $FILE.tmp $FILE
chmod 644 $FILE
----------end-------------------



gen-secondaries.sh on windows master for linux slave
changed NAMED_ROOT, awk -> gawk, .includes -> .txt (.txt files type is allowed by default on IIS)

(I had a problem in that access to my default site was not allowed, still don't know what caused it, but after a complete rebuild things where OK again - I had therefore used a hosted domain to put the secondries file into, I've now edited this post and changed it back)

---------begin------------
#!/bin/sh

MASTER=w.x.y.a
NAMED_ROOT=D:/progra~1/SWsoft/Plesk/dns/etc/
HTTPDOCS=D:/inetpub/vhosts/default/htdocs

egrep "^zone" $NAMED_ROOT/named.conf |egrep -iv "arpa|\"\." | gawk -F\" '{print $2}' > $NAMED_ROOT/domains

echo > $HTTPDOCS/secondaries.txt
for i in `cat $NAMED_ROOT/domains`; do
echo "zone \"$i\" {" >> $HTTPDOCS/secondaries.txt
echo " type slave; " >> $HTTPDOCS/secondaries.txt
echo " file \"slave/$i\";" >> $HTTPDOCS/secondaries.txt
echo " masters { $MASTER; };" >> $HTTPDOCS/secondaries.txt
echo " allow-transfer { none; };" >> $HTTPDOCS/secondaries.txt
echo "};" >> $HTTPDOCS/secondaries.txt
echo >> $HTTPDOCS/secondaries.txt
done

chmod 644 $HTTPDOCS/secondaries.txt
-----------end-------

xfer-config.sh on linux slave
Added GET_FILE
-------begin--------
#!/bin/sh

MASTER=a.b.c.d
FILE=secondaries.include
GET_FILE=secondaries.txt

rm $FILE.tmp
wget http://$MASTER/$GET_FILE -O $FILE.tmp

SIZE=`stat $FILE.tmp |grep Size |awk '{print $2}'`
if [ $SIZE = 0 ]; then
echo "ERROR! The secondary file is 0 length!"
exit 1
else
mv $FILE.tmp $FILE
chmod 644 $FILE
fi
----------end-------------


for windows scripts put in D:\program files\SWsoft\Plesk\dns\etc


Step 3) create a directory /var/named/run-root/var/slave owned by the named user.

On windows this is D:\program files\SWsoft\Plesk\dns\var\slave, no need to chown.

Step 4) Create 3 root cron jobs to generate configs, transfer files, and restart named .

0 */6 * * * /var/named/run-root/etc/gen-secondaries.sh > /dev/null 2>&1
10 */6 * * * /var/named/run-root/etc/xfer-config.sh > /dev/null 2>&1
20 */6 * * * /etc/init.d/named restart > /dev/null 2>&1


Create a file D:\program files\SWsoft\Plesk\dns\etc\dnsrestart.cmd
with the following contains

------start-----------
c:\windows\sh D:\progra~1\SWsoft\Plesk\dns\etc\gen-secondaries.sh
sleep 1
c:\windows\sh D:\progra~1\SWsoft\Plesk\dns\etc\xfer-config.sh
sleep 1
net stop named
sleep 1
net start named
--------end-----------

the sleep is probably not necessary as it just waits a second between commands.

Use Schedule Manager in System > server of plesk gui

add a job for the script
Path to executable file- D:\progra~1\SWsoft\Plesk\dns\etc\dnsrestart.cmd

run every x hours.


Step 5) add a global allow rule into the PSA database on each server for each secondary server, as root:
mysql -u admin -p psa insert misc values ('DNS_Allow_TransferXX', '<IP>');
where XX is a unique number for each secondary server, and <IP> is the ip address for your secondary.

mysql -u admin -p`cat /etc/psa/.psa.shadow` psa
insert misc values ('DNS_Allow_Transfer01','10.10.192.13');

for windows

in D:\program files\SWsoft\Plesk\MySql\bin

mysql -u admin -pYOUR_ADMIN_PASSWORD psa
insert misc values ('DNS_Allow_Transfer01','w.x.y.z');

Step 6) In the PSA control panel, log in as admin, goto Server->DNS->Add NS records for each secondary server


Cheers

Jonny

some more stuff, added some time later:

In Windows Plesk 7.5 there are 2 mysql servers, one on port 8306 & 3306. The one on 8306 is the one with the psa database. I noticed that this version also used MS DNS unless bind is installed.

gen-secondaries.sh for Freebsd (5.2) & plesk 7.5.2

#!/bin/sh

MASTER=a.b.c.d
NAMED_ROOT=/usr/local/psa/named/run-root/etc/
HTTPDOCS=/usr/local/psa/home/vhosts/default/htdocs/

egrep "^zone" $NAMED_ROOT/named.conf |egrep -iv "arpa|\"\." | awk -F\" '{print $2}' > $NAMED_ROOT/domains

echo > $HTTPDOCS/secondaries.include
for i in `cat $NAMED_ROOT/domains`; do
echo "zone \"$i\" {" >> $HTTPDOCS/secondaries.include
echo " type slave;" >> $HTTPDOCS/secondaries.include
echo " file \"$i\";" >> $HTTPDOCS/secondaries.include
echo " masters { $MASTER; };" >> $HTTPDOCS/secondaries.include
echo " allow-transfer { none; };" >> $HTTPDOCS/secondaries.include
echo "};" >> $HTTPDOCS/secondaries.include
echo >> $HTTPDOCS/secondaries.include
done

chmod 644 $HTTPDOCS/secondaries.include

On both windows and freebsd (probably linux) 7.5 plesk versions you don't need to do the insert into the psa database the line to allow transfer:

On 7.5 for FreeBSD you don't have to edit the psa database you can add the slave server in server > dns > common acl.

On 7.5 for Windows you can only add the slave server on a per domain basis domains > dns > transfer restrictions - this is obviously no good. In d:\Program Files\SWsoft\Plesk\dns\etc\named.conf you need to add the ip of the slave in the acl common-allow-transfer:

acl common-allow-transfer {
a.b.c.d;
};

thing is I don't know if plesk will wipe this change out - I've had it set for several days now without problems, but I haven't found anywhere to add it in the psa database.

I currently have a Debian box running secondary DNS and backup mx for 2 plesk servers. All the domains the box does secondary dns for I allow the box to receive email for.

if this interests you then this http://forum.sw-soft.com/showthread.php?s=&postid=116017 might too.
 
"By default access to default is not allowed, therefore used domain to put include file on.
means that this domain must remain on the server for this to work" - this was wrong an error on my server
 
Scripts

Hi Guys.

Great info - just one prob so far.

When I add the line as per step 1 on both machines my DNS server fails on both machines and the service stops.
I tracked this down to a couple of problems:

1) If the secondaries.include file does not exist on either machine when it tries to include it from named.conf then the Plesk DNS service will fail and stop. To avoid this just create a blank text file there after you setup step 1 at the following location for windows:
D:\program files\SWsoft\Plesk\dns\etc\secondaries.include

2) I editied it like file for "gen-secondaries.sh - on a linux master for windows slave" to include a line UNIX_NAMED_ROOT and updated to code so the correct path to the slave directory was defined for the zone files. For some reason it didn't seem to work without this.

Both machines working great now slaving off each other. Thanks for the post. :)

Thanks.
 
Trying to implement this solution wondering where to find sh directiory to run this .sh script on window

you mentioned to use "c:\windows\sh" but can seem to find the matching \sh direcectory on my window server running plesk.

did you installed "\sh" executables or does it come with plesk?

Thanks! egate


------start-----------
c:\windows\sh D:\progra~1\SWsoft\Plesk\dns\etc\gen-secondaries.sh
sleep 1
c:\windows\sh D:\progra~1\SWsoft\Plesk\dns\etc\xfer-config.sh
sleep 1
net stop named
sleep 1
net start named
--------end-----------
 
Just realized that it is posted....just a bad day!

Thanks for your scripts it works great!
 
Back
Top