Connect DirectAdmin server to cPanel DNS cluster servers

I'm curious to why you don't just send the full zone after each update.

After a zone write, just SAVEZONE and RELOADZONE to the DNS cluster. That way you're sure to get all of the information in the local zone out to the DNS cluster.

If it's a new zone use QUICKZONEADD.

If it's a zone deletion use REMOVEZONE.

Parsing the zone file locally can get messy. And I'm not sure if it's really necessary?
 
All:

Not discounting the work here. It is greatly need I am sure related to Migrations. I assume its only a temporary solution. To remind others please visit. https://blog.cpanel.com/coming-very-soon-dnsonly-server-licenses/
Not sure when it will come but they have been collecting data for more than a Year... I and I hope you all have assumed they will start charging...just saying..

Please return to your regularly scheduled broadcast now.
 
I'm curious to why you don't just send the full zone after each update.

After a zone write, just SAVEZONE and RELOADZONE to the DNS cluster. That way you're sure to get all of the information in the local zone out to the DNS cluster.

If it's a new zone use QUICKZONEADD.

If it's a zone deletion use REMOVEZONE.

Parsing the zone file locally can get messy. And I'm not sure if it's really necessary?

The problem is that DA calls the script, and doesn't do anything (in the UI) until it's finished, so with a larger zone that can take some time, and will look like nothing is happening. Hence the idea to minimise the interactions with the nameservers as far as possible.

The only DNS functions we have to work with are https://documentation.cpanel.net/display/DD/WHM+API+1+Sections+-+DNS

You can't send whole zones unless you delete all the records one at a time and then re-send them, which is what V1 did just to prove the concept, but it was too slow really.

The idea of this script is just to have something simple which means you can have both cPanel and DA connected to the same nameserver cluster at the same time.
 
It also works with cPanel Server(Not DNSOnly) by adding ${CPSESS} in URL.


$url = "https://".$nameserver['host'].":2087/json-api/".$command;
to:

$url = "https://".$nameserver['host'].":2087/${CPSESS}/json-api/".$command;


Many many thanks to OP.


Update: Seems it was confusion, I am getting error:

cPanel server said: {"cpanelresult":{"apiversion":"2","error":"Access denied","data":
 
Last edited:
Right I was trying to get TTL values done for the next release, but I don't think it's going to be possible due to the lack of parameters in the env variables.

I think the best thing to do is going to be to actually just parse the zone file, which I'm going to start work on. At least that way any future changes in DA won't matter, as long as the script is called and the domain is passed. It'd also then be very simple to call it directly and do single zone sync, all zone sync and so on.
 
Creating new dnz zone doesnt work.
it works only for Add Record in existing zone.

Code:
Panel server said: {"metadata":{"result":0,"version":1,"command":"dumpzone","reason":"Zone does not exist."}}

it is doesnt exist, but not creating the zone
 
To create dnz zone in dns only
i change line 24 into this

Code:
$recs_domip = getenv('DOMAIN_IP');

now the problem is, zone are created, but every record have double/duplicate entry like this

Code:
fabiayi.com.    14400   IN	A	12.12.12.12
ftp     300     IN	A	12.12.12.12
ftp     300     IN	A	12.12.12.12
mail    300     IN	A	12.12.12.12
mail    300     IN	A	12.12.12.12
pop     300     IN	A	12.12.12.12
pop     300     IN	A	12.12.12.12
smtp    300     IN	A	12.12.12.12
smtp    300     IN	A	12.12.12.12
www     300     IN	A	12.12.12.12
www     300     IN	A	12.12.12.12
fabiayi.com.    300     IN	MX	10	mail.fabiayi.com.
fabiayi.com.    300     IN	MX	10	mail.fabiayi.com.
fabiayi.com.    3600    IN	NS	as.as.
fabiayi.com.    3600    IN	NS	as.as.
fabiayi.com.    300     IN	TXT     "v=spf1 a mx ip4:139.162.48.91 ~all"
fabiayi.com.    300     IN	TXT     "v=spf1 a mx ip4:139.162.48.91 ~all"

and, when adding record to dns zone, it will remove all current record and leave some, like this

Code:
fabiayi.com.    14400   IN	A	12.12.12.12
testrecord	300     IN	A	1.1.1.1
testrecord	300     IN	A	1.1.1.1

and again, when adding more record to dns zone, it will reset to start but adding new record like this (still get duplicate record)

Code:
fabiayi.com.    14400   IN	A	12.12.12.12
addsomemore     300     IN	A	192.168.1.1
addsomemore     300     IN	A	192.168.1.1
ftp     300     IN	A	12.12.12.12
ftp     300     IN	A	12.12.12.12
mail    300     IN	A	12.12.12.12
mail    300     IN	A	12.12.12.12
pop     300     IN	A	12.12.12.12
pop     300     IN	A	12.12.12.12
smtp    300     IN	A	12.12.12.12
smtp    300     IN	A	12.12.12.12
www     300     IN	A	12.12.12.12
www     300     IN	A	12.12.12.12
fabiayi.com.    300     IN	MX	10	mail.fabiayi.com.
fabiayi.com.    300     IN	MX	10	mail.fabiayi.com.
fabiayi.com.    3600    IN	NS	as.as.
fabiayi.com.    3600    IN	NS	as.as.
fabiayi.com.    300     IN	TXT     "v=spf1 a mx ip4:139.162.48.91 ~all"
fabiayi.com.    300     IN	TXT     "v=spf1 a mx ip4:139.162.48.91 ~all"

seems like still have issue on the looping part
 
Question v3

Hi!

Any new about version 3? I'm just waiting for the new version for fixing problems to start migrating cPanel clients to DirectAdmin :)

Thanks
 
I do not understand why it works some times and why not others it mostly fails but worked on couple of occasions


I'm testing with account creation from whmcs and I terminate and recreate that account from there multiple times to simulate a new order) so at first It do not worked

I applied the line 24 fix getenv('DOMAIN_IP);

It create it to ns1 :) So I decide the I'm doing something right ... mail was created mail without the domain so I applied that fix too ...

to test again as it is not removed the record I manually remove db files and record from named conf and tried again ... I actually got only one fully successful attempt (but i got that on random)

In cases when it failed on the ns is missing domain.com.db from var named but record for the domain get created in /etc/named.conf (and some times both are not created )


I'm using 78LTS cPanel DNS only on the first and 80.20 stable on the second

P.S I tried to update curl on the hosting server as I know that default 7.29 got some issues with checking ssl on whmcs but that do chnage the situation ...
 
Apologies I've had something internally to deal with, will be back on this shortly to get a final version out :)
 
Hi guys,

We have just implemented this, but we are seeing some errors for some of the domains...

cPanel server said: {"metadata":{"result":0,"version":1,"command":"addzonerecord","reason":"API failure: (XID euqdaa) This system does not have a domain named “apamovil.com”."}}
send_to_ns running...
cPanel server said: {"metadata":{"reason":"API failure: (XID q2fdtr) This system does not have a domain named “apamovil.com”.","version":1,"command":"addzonerecord","result":0}}
send_to_ns running...
cPanel server said: {"metadata":{"reason":"API failure: (XID hcfb76) This system does not have a domain named “apamovil.com”.","version":1,"command":"addzonerecord","result":0}}

I am struggling to understand this one - for it to add the zone record, I assume it first needs to create the zone itself. Can you confirm where in the script this is done? I can't seem to find it (but maybe just missing it completely!)

Any advice would be fantastic.

Dennis
 
Hi guys,

We have just implemented this, but we are seeing some errors for some of the domains...

cPanel server said: {"metadata":{"result":0,"version":1,"command":"addzonerecord","reason":"API failure: (XID euqdaa) This system does not have a domain named “apamovil.com”."}}
send_to_ns running...
cPanel server said: {"metadata":{"reason":"API failure: (XID q2fdtr) This system does not have a domain named “apamovil.com”.","version":1,"command":"addzonerecord","result":0}}
send_to_ns running...
cPanel server said: {"metadata":{"reason":"API failure: (XID hcfb76) This system does not have a domain named “apamovil.com”.","version":1,"command":"addzonerecord","result":0}}

I am struggling to understand this one - for it to add the zone record, I assume it first needs to create the zone itself. Can you confirm where in the script this is done? I can't seem to find it (but maybe just missing it completely!)

Any advice would be fantastic.

Dennis

OK, managed to sort this, which is great.

The only thing we seem to have outstanding is an issue specifically with MX records being synced.

Anyone have any ideas?
 
this would be great if it worked with full cpanel servers, so you can create a cluster between DA and cPanel
 
this would be great if it worked with full cpanel servers, so you can create a cluster between DA and cPanel

You might be better to just use some small VPS for running cpanel DNSonly servers, then cluster both DirectAdmin and cPanel servers to this.

Works great so far!
 
I am also getting the following after setting this up:

PHP Notice: Undefined offset: 1 in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 56
PHP Notice: Undefined offset: 1 in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 57
PHP Notice: Undefined offset: 1 in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 73
PHP Notice: Undefined offset: 1 in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 74
PHP Notice: Undefined offset: 1 in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 121
PHP Notice: Undefined offset: 1 in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 123
PHP Notice: Undefined offset: 2 in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 123
PHP Notice: Undefined offset: 3 in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 123
PHP Notice: Array to string conversion in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 134
PHP Notice: Undefined index: data in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 385
PHP Warning: array_reverse() expects parameter 1 to be array, null given in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 385
PHP Warning: Invalid argument supplied for foreach() in /usr/local/directadmin/scripts/custom/dns_write_post.sh on line 387

Has anyone been able to rectify this? I have tried the "url =" changes, but these didn't work for me.
 
My experience, the script hangs on dnsonly version 82.x, but it works on DNSOnly version 80.x
 
Last edited:
It's a 'hook' file, you cannot just execute it on ssh :)
 
Back
Top