babipanghang
New member
- Joined
- Jul 20, 2014
- Messages
- 4
Having bought a VPS that came with only one IP available, i was looking for a way to be able to have a secondary DNS server controlled from within directadmin. There are off course the necessary secondary DNS services available, but each one that i found required manual entry of the zones to mirror.
Decided to give buddyns a try, and was happy to discover that they offer an API that i could use. Time to do some scripting.
First of all, you need to log in to buddyboard, and get to the account tab. Scroll all the way down, there should be a button there to request an API key. Click it, your key should appear there. Keep it secret like a password. You might want to copy it to your clipboard now.
Next step, log into your server with ssh and fire up your favourite text editor, and enter the following lines:
Be sure to replace xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your API key and 123.123.123.123 with your server's IP.
Now save that file as /usr/local/directadmin/scripts/custom/domain_create_post.sh
This script will automatically be called by directadmin each time a domain is added. When called, it adds the new domain to buddyns.
Next, create a new file and enter the following:
Again, replacing xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx with your API key.
Save that file as /usr/local/directadmin/scripts/custom/domain_destroy_post.sh
This script does the opposite of the first one, removing the domain from buddyns when it is removed from directadmin.
Last but not least, close your text editor and execute the following lines:
That should do the trick. You can find a log of the automatic buddyns updates at /var/log/dnsupdate.log.
Decided to give buddyns a try, and was happy to discover that they offer an API that i could use. Time to do some scripting.
First of all, you need to log in to buddyboard, and get to the account tab. Scroll all the way down, there should be a button there to request an API key. Click it, your key should appear there. Keep it secret like a password. You might want to copy it to your clipboard now.
Next step, log into your server with ssh and fire up your favourite text editor, and enter the following lines:
Code:
#!/bin/bash
curl -sH 'Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -XPOST -F "name=$domain" -F 'master=123.123.123.123' https://www.buddyns.com/api/v2/zone/ >> /var/log/dnsupdate.log
Now save that file as /usr/local/directadmin/scripts/custom/domain_create_post.sh
This script will automatically be called by directadmin each time a domain is added. When called, it adds the new domain to buddyns.
Next, create a new file and enter the following:
Code:
#!/bin/bash
curl -sH 'Authorization: Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' -XDELETE https://www.buddyns.com/api/v2/zone/$domain >> /var/log/dnsupdate.log
Save that file as /usr/local/directadmin/scripts/custom/domain_destroy_post.sh
This script does the opposite of the first one, removing the domain from buddyns when it is removed from directadmin.
Last but not least, close your text editor and execute the following lines:
Code:
chmod 755 /usr/local/directadmin/scripts/custom/domain_create_post.sh
chmod 755 /usr/local/directadmin/scripts/custom/domain_destroy_post.sh
That should do the trick. You can find a log of the automatic buddyns updates at /var/log/dnsupdate.log.