DirectSlave - solution to add and remove zones on slave without DirectAdmin

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
Yep, I also got it on a small VPS.
There was still a slight problem. After I updated perl things worked a lot better, but we discovered a bug.
Roman is really a very cool and great guy. We have skyped several hours this evening, fixing my problem with this and I was glad to be of help to him to test a bugfix.
So I guess a new version will come out soon with the fixes in it.
Thanks again Roman!
 

pucky

Verified User
Joined
Sep 9, 2006
Messages
795
At first i did not get this resolved so I used master2slave which also needed some minor adjustments.

Since this week I have contact via PM with the author Roman and we are going to fix the issue with Directslave.
Directslave works in combination with the DA multi server setup. I needed directslave we wanted to use a VPS without Directadmin as secondary nameserver. If you don't have DA, you don't have DA multi server setup either.:)
Directslave can be used with the multi server setup so that was the easyest solution.
Correct, you can use this with DA & Debian server not running DA? I read that Jeffs script had to be modified for Debian based boxes.
Do you have to be running the same OS across boxes? And can it run in tandum with a Debian, Freebsd, RH6 server with no DA os install?

It would be nice to see DA create a DNS ONLY module just like Cpanel offers for Free! :wink: :wink:
 
Last edited:

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
Roman uses Freebsd himself so I'm sure it must be working with FreeBSD too. I've got them on a couple of Centos machines.
 

roman_m

Verified User
Joined
May 5, 2005
Messages
130
Location
Ukraine, Kiev
>Do you have to be running the same OS across boxes? And can it run in tandum with a Debian, Freebsd,
>RH6 server with no DA os install?

Yes, it will. All your need to run DirectSlave is just any system with perl5 installed + perl5 additional modules (listed in README file included it DirectSlave distirib). Follow README steps and you get it to work in couple of minutes.

>It would be nice to see DA create a DNS ONLY module just like Cpanel offers for Free! :wink: :wink:

That's why I made this project -)
 

pucky

Verified User
Joined
Sep 9, 2006
Messages
795
>Do you have to be running the same OS across boxes? And can it run in tandum with a Debian, Freebsd,
>RH6 server with no DA os install?

Yes, it will. All your need to run DirectSlave is just any system with perl5 installed + perl5 additional modules (listed in README file included it DirectSlave distirib). Follow README steps and you get it to work in couple of minutes.

>It would be nice to see DA create a DNS ONLY module just like Cpanel offers for Free! :wink: :wink:

That's why I made this project -)
And we thank you and appreciate it. Ill try to install it when i remove DA from a VPS server i have out there.
 

redjersey

Verified User
Joined
Apr 22, 2013
Messages
93
Location
Toronto, Canada
Hi,

finally have all the perl modules installed on a 2gb vps (I was trying to install those modules on a 128mb with burstable 256mb vps, but always got the cannot allocate memory error, long story anyways...)

so I'm ready to install this on my 2gb vps as a slave.

Before doing so I have a few questions and please bear with me, I'm a newbie, a long time cpanel user but a first time directadmin user! :p

1. So in order to run:
# chown -R $uid:$gid /usr/local/directslave

I'll first have to create a new user in slave right? or can I just use:
# chown -R named:named /usr/local/directslave

2. regarding the configuration file:
I should change the mode to slave right? I read the README file and it says in order to set it as "slave" I'll have to setup axfr on directadmin, so how am I going to do that? I read the directadmin section:
http://help.directadmin.com/item.php?id=230

it says how to disable axfr but not the other way around.

3. I have logged into my directadmin master and enabled multi servers. So I guess the next step would be to add a remote server, which the remote server ip is actually my slave vps ip right (the one that has directslave) and for the username and password, should I put my root username and password there?

4. # /usr/local/directslave/bin/pass admin yourhardtoreadpassword
so "admin" and "yourhardtoreadpassword" are they the username and password of my directadmin login?

thanks in advance :)
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
I will try to answer your questions accordingly.

1.) You can just use # chown -R named:named /usr/local/directslave
I did too and this works fine. Remember to also use uid and guid named in directslave.conf.

2.) Correct, you have to set your slave server as "slave".
Enabling afxr is just opposite to enabling it. So if disabling is setting allow-transfer tot "none", enabling is putting an ip in there. Suppose your master server is 123.45.67.89, then in your named.conf you should put:
Code:
allow-transfer { 123.45.67.89; };
to enable afxr.
Do the same on the master server, but in that case, put the ip of the slave server in there.

3.) No, don't use root!
The username used for the multiserver setup is normally admin. So you could put your admin username and password in there. I did not test if another username works, but you should not use root in any case if possible.
Remember to use the /user/local/directslave/bin/pass utility to get an encrypted password on the slave server to put in directslave.conf. The connection is in fact going to your DA server, so this is in fact the answer to question 4.

4.) yes.

Your welcome.:)
 

redjersey

Verified User
Joined
Apr 22, 2013
Messages
93
Location
Toronto, Canada
thanks, however I'm still not able to make it work. Let's assume my directadmin master ip is 111.111.111.111 and my slave vps ip is 222.222.222.222 (the one has directslave installed, without running directadmin)

Here is what I did:
1. in slave vps, copy directslave to /usr/local so now it's like: /usr/local/directslave
2. run this in slave: chown -R named:named /usr/local/directslave
3. changed /usr/local/directslave/etc/directslave.conf to the following:
Code:
background	1
server_type     Fork
host            222.222.222.222 (again, my slave ip)
port            1580 (i have this port opened on slave)
debug           0 

uid             named
gid             named

pid             /usr/local/directslave/run/directslave.pid
access_log	/usr/local/directslave/log/access.log
error_log	/usr/local/directslave/log/error.log
action_log	/usr/local/directslave/log/action.log

mode            slave
named_workdir   /etc/named/secondary
named_conf	/etc/named/secondary/named.conf
retry_time	1200
rndc_path	/usr/sbin/rndc

allow           111.111.111.111/32 (I used this: http://ip2cidr.com/ and enter my directadmin ip address to get the CIDR)

auth            admin:$1$xxxxxxxxx
4. on slave's /etc/named.conf I have added allow-transfer { 111.111.111.111; }; inside option { }
on master's /etc/named.conf I have added allow-transfer { 222.222.222.222; }; inside option { }
then restart named on both servers

5. on slave's /etc/named.conf I have added include "/etc/named/secondary/named.conf";
6. on slave's machine run:
/usr/local/directslave/bin/pass admin yourhardtoreadpassword
which admin and yourhardtoreadpassword is the admin and username of my master's directadmin password

7. but when I run this on slave:
/usr/local/directslave/bin/directslave

I've got this in my error.log:
Code:
Process Backgrounded
2013/05/01-18:30:51 main (type Net::Server::HTTP -> MultiType -> Net::Server::Fork) starting! pid(19838)
Binding to TCP port 1580 on host 222.222.222.222 with IPv4
2013/05/01-18:30:51 Can't connect to TCP port 1580 on 222.222.222.222 [Address already in use]
  at line 68 in file /usr/local/share/perl5/Net/Server/Proto/TCP.pm
2013/05/01-18:30:51 Server closing!
also when I tried to test the connection by using the multi server setup, I got the following:
222.222.222.222 Apache/2.2.15 Unable to get api result. Check your configuration options.
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
Looks good. However, DA does not run on port 1580.
Did you try the same but then using port 2222?

on slave's /etc/named.conf I have added include "/etc/named/secondary/named.conf";
I presume the /etc/named/secondary directory's do exist and you also did:
chown -R named:named /etc/named/
 

redjersey

Verified User
Joined
Apr 22, 2013
Messages
93
Location
Toronto, Canada
in config I have changed:

host *
port 2222

and when I run again I've got this in error.log

Code:
Process Backgrounded
2013/05/01-18:57:42 main (type Net::Server::HTTP -> MultiType -> Net::Server::Fork) starting! pid(19910)
Resolved [*]:2222 to [0.0.0.0]:2222, IPv4
Binding to TCP port 2222 on host 0.0.0.0 with IPv4
Setting gid to "25 25"
Setting uid to "25"
so what is this port? I thought in the port field I have to enter a port number which is opened on the slave? but instead I have to put 2222? so is it mean that 2222 has to be opened on both master and slave?

also I just tested the connection by using the multi server setup in DA and I still got the same error:222.222.222.222 Apache/2.2.15 Unable to get api result. Check your configuration options.
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
Port 2222 is the port which is used by Directadmin for admin and users to connect with the DA control panel, so on the master, this port is open anyway, at least incoming.
This port should be opened incoming and outgoing on both the DA and the slave server.

I would not do that. You can better put the ip of your slave vps there, as you had before.

So at this point, the connection from the slave to the master is working.

Now we only have to look at the connection from (DA) master to slave. Did you make a new entry for multi server setup in DA? Because as far as I know, you can't change the port in an existing one. You can also uncheck the "domain check" if it's a on-da slave server only. So only "transfer" would be selected.

Mostly the error you got, points to a problem with connection or password. I hope you put your DA admin password in there, not the encrypted one you made on the VPS, but plaintext.
Also, check your firewall if both incoming and outgoing port 2222 tcp is allowed.

P.s. please don't forget to restart directslave on the vps after making changes.
For example: killall -9 directslave
and then start directslave again.
 
Last edited:

redjersey

Verified User
Joined
Apr 22, 2013
Messages
93
Location
Toronto, Canada
almost!!!!!!!

I deleted the existing multi setup server entry, created a new one, now I got the DirectSlave Connection OK!!!!

I then created a dummy domain name using DA, then in my
/etc/named/secondary/named.conf in slave, I got:

zone "magicjohnson.com" { type slave; file "/etc/named/secondary/magicjohnson.com.db"; masters { 111.111.111.111; }; max-retry-time 1200; min-
retry-time 1200; };

but in my secondary directory, I only have one file named.conf, but not the magicjohnson.com.db. isn't the master suppose to send the magicjohnson.com.db to my slave's /etc/named/secondary/ directory?

I checked my DA's /etc/named folder it's nothing.
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
Oke so the connection is ok, it's just the copying then.

You should have the magicjohnson.com.db present on your slaveserver in /etc/named/secondary.
This domain (if that is your testdomain) should not be in /etc/named on your DA server, but in /var/named. At least if you are using Centos or Fedora as operating system.

isn't the master suppose to send the magicjohnson.com.db to my slave's /etc/named/secondary/ directory?
Yes it should. So the DA connection is ok, but it seems something still goes wrong on the afxr command for transferring the domains.

Best way is to check your logfiles on both DA server (/var/named/messages) and slave server, just after creating a dummy domain, to see what is going wrong.
It's probably some little setting or typo in your standard /etc/named.conf on one of the servers.
 

redjersey

Verified User
Joined
Apr 22, 2013
Messages
93
Location
Toronto, Canada
I don't know what caused this. I added another dummy domain patrickewing.com using my directadmin. I monitored my /var/log/messages on both slaves and master. no error, I then checked my /etc/named/secondary/ directory on slave, nothing there, but if I restart my named service on slave, patrickewing.com.db appears.

I really don't know what caused the issue, but as soon as I run service named restart on slave, the .com.db appears.
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
Oke then the only issue is that named is not restarted. This normally points to an rndc problem, because directslave uses rndc to restart named.

Try a manual "rndc reload" command and see if there is an error.
 

redjersey

Verified User
Joined
Apr 22, 2013
Messages
93
Location
Toronto, Canada
Hi,

I guess I know what caused the problem.
First, I have fixed the rndc issues, so if I run the rndc reload command I got the msg saying reloaded successfully.

however when I added a dummy domain, I still don't see the .com.db file, not until I manually run the "rndc reload" again.
I put some traces inside the /bin/directadmin reload function, and instead of using system() (which won't return any output), I used the backticks.
I restarted directspace and I have tried:

Code:
 my $output1 = `$config->{rndc_path} reload $domain`;
 my $output2 = `$config->{rndc_path} reload`;
both output1 and output 2 didn't give me any output.

when I setup directspace, I used named as the uid and gid to execute. So I guess named didn't have rights to execute rndc reload. (But I really don't know why, as if I delete domain on directadmin, the .com.db is gone. So why named can unlink .com.db but not create .com.db??)

Anyways, I then changed my uid and gid to root, however /usr/sbin/rndc reload $domain still not working.

I manually logged into root and run:
rndc reload wallmart.com (which I used directadmin to add this dummy wallmart.com domain)
rndc: 'reload' failed: not found

still not working.

and finally, I made some changes to the reload function as follows:

Code:
sub reload($) {
    my $domain = shift;
    return if($config->{rndc_path} eq "none");
    &action_log (" prepare to run rndc reload for domain: $domain "); //I added this line

    my $rndcresult = `$config->{rndc_path} reload`; //I removed the system() and added this line too
    &action_log (" reload result: $rndcresult");

    return 1;
}
and now it's working fine :)

Note:
1. even though when executing "rndc reload", I got the output of "server reload successful", my .com.db does take a min or so in order to show up under my /etc/named/secondary directory
2. not sure why when I run this using root: /usr/sbin/rndc reload mydomain.com will give me this: "rndc: 'reload' failed: not found" and it can't load up the .com.db
3. I'm not sure if executing "rndc reload" everytime when there is a change on bind, is good or not

but at least now is fine :) Thanks Richard for helping me on this issue. I have been struggling on this issue for quite some time (if you look at the other thread: master2slave you will know what I'm talking about). Again, thanks Richard :eek: :eek:
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
You're welcome.

I'm glad you figured out the rest. I had some help from Roman himself on my rndc reload issues.
He made some changes to the code with me, and put that in the release which should be online. However I don't remember all changes, so it could be not every changes was added.

On the sub reload routine I only got this:
Code:
sub reload($) {
    my $domain = shift;
    return if($config->{rndc_path} eq "none");
    system("$config->{rndc_path} reload");
    return 1;
}
That worked perfectly on my Centos system.

Fine to hear you got it working too now.:)
 

redjersey

Verified User
Joined
Apr 22, 2013
Messages
93
Location
Toronto, Canada
both of our reload functions didn't include the domain as a parameter:

$config->{rndc_path} reload

instead of:

$config->{rndc_path} reload $domain

so I guess $config->{rndc_path} reload $domain doesn't work (i'm using centos 6 32bit)
 

Richard G

Verified User
Joined
Jul 6, 2008
Messages
4,221
Location
Maastricht
both of our reload functions didn't include the domain as a parameter:
Correct, because it shouldn't.
An rndc reload is a reload of the named service like "service named reload".

On our VPS it's Centos 5.9 64-bit but that should make no difference.
 

RayManZ

Verified User
Joined
Nov 8, 2004
Messages
97
I'm still getting the following error:
Use of uninitialized value in length at /usr/local/directslave/bin/directslave line 109.

I got the lib file in the lib dir. I can't figure out where it goes wrong. Any ideas?
 
Top