Multi server setup not syncing after CMD_API_DNS_ADMIN?action=rawsave&..

JeffreydeV

Verified User
Joined
Dec 20, 2010
Messages
11
Location
Denmark
Hello,

We have 3 standalone nameservers running on directadmin which we control using the api.
What we did was add a simple master slave setup (ns1 is the master, ns2 and ns3 the slaves) using multi server setup (only on ns1).

This works perfectly, however we are currently working on a functionality where we want to move domains from 1 IP to another IP which is why we thought the rawsave function would come in handy (simple string replace, old IP for new IP). We have everything set up as it should work and we do get the correct records on ns1 however the changes are not reflected to ns2 and ns3.

Ofcourse a rewrite on named (in data/task.queue) doesn't work since that only rewrites local domains (of which there are non because they are standalone/dedicated nameservers).

Is this a bug or working as intended? Does anyone have any suggestions on how I can push all zones from ns1 to ns2 and ns3?

Thank you.

Best regards,

Jeffrey
 
That's actually mantained by named itself, named should notify the other nodes.

I'm not sure is related (i guess so) but i have set this script:
/usr/local/directadmin/scripts/custom/dns_write_post.sh
Code:
#!/bin/bash

/usr/sbin/rndc reload

exit 0;

Regards
 
(simple string replace, old IP for new IP)
Please correct me if I'm wrong, but as far as I know, slave zones won't get updated if the serialnumber of the master zone does not change.
The serial changes on every dns change. So probably you have to look how to fix that if the script from Sellerone won't be of help.
 
Thanks for the quick response guys.
Code:
/usr/sbin/rndc reload
Unfortunatly this doesn't help me.

What I have found out so far:

When editing the zone using a rawsave it doesn't update the other nameservers. When changing a single line using the API it does.
I was thinking maybe it has something to do with the SOA since when I am updating the IP I didn't try and change the SOA. So if named uses this to compare and update it would make sense as in why it doesn't update. Although when I edit the zone file manually and update the SOA then restart named or run rndc reload or echo a rewrite action task.queue it also doesn't update.

I'm starting to consider if I should save the raw dns data, then add a txt record and remove it again using the single line API functionality...
However this seems like a very dirty solution... :confused:

edit:

After looking at it again after about 15 minutes. the zone was transfered to nameserver 2 and 3 also. I'm assuming it is because of the SOA change and just needs some time to sync.
 
Last edited:
The sync should take no time actually, i probably missunderstood the raw change meaning, as far as i understood now you're changing the .db file directly, that would be the problem with the SOA.

Why aren't you changing using the API's?

Regards
 
What I meant was that I edit the zone using the CMD_API_DNS_ADMIN?action=rawsave command.
This is the same as going into the machine and using vi to edit it afaik. It doesn't seem to trigger any automatic process.

To fix the SOA problem I have created the following dns_raw_save_post.sh, perhaps it can help other people out in the future (hello future me :cool:).

Code:
#!/bin/bash

# update SOA, this basically gets the current SOA and adds 1.
FILE=/var/named/$domain.db
ZONE=$(cat $FILE | tr '\n' ' ')
if [[ $ZONE =~ \([^\)]*?(201[0-9]+)[^\)]*\) ]]
then
    SOA=${BASH_REMATCH[1]}
    NEWSOA=$((SOA + 1))

    sed -i "s/${SOA}/${NEWSOA}/g" $FILE
fi

# rewrite, this perhaps can be changed by rndc reload command
echo "action=rewrite&value=named" >> /usr/local/directadmin/data/task.queue

exit 0;
 
I see your point :)

Thanks for sharing your solution, i'm going to send this to John to add a featre to update the SOA on rawsave.

Regards
 
Yep :)

John responded, he's out of town those days but it sound like a bug to him too, once he will be back he will look into it and probably fix it for next release.

Regards
 
Hi guys,

I've looked over the code, and for DA to change the raw data, it wouldn't follow the purpose of that feature.
The action=rawsave is supposed to do just that, save exactly what is given to it.

So if you need a newer serial number, it should already be updated on the sending server, before passing it to the remote rawsave.

Looking at the DA Multi-Server Setup code that sends the zone to the remote box (using rawsave), the cluster portion grabs the local zone file after it's already been written.
So it should be reading in the new zone, with the updated serial... which should then be sending the new serial to the remote box.

So let me know what I'm missing in terms of serials not being updated.
It should be done by the sending box, before sending it to rawsave.
If you're using some other script, and the MSS isn't the one doing the send, then that's likely why.

John
 
Just tested the MSS to make sure, and both the local zone file and the raw remote zone file both got the same updated serial, so not sure what the issue is yet.
 
Back
Top