DNS Zones

DrWizzle

Verified User
Joined
Aug 8, 2021
Messages
107
Good evening guys & gals!

I finally got started on my project the other day, a year late, to create a site using DA. I was just wondering if there was an API that I could use so that I could have a simple PHP script to upload, run and delete when I needed to add domains to the DNS Zone file. I can do them manually here on the screen as shown in the attachment but would like a script to make things easier as it's only the name that would have to change everytime. The IP and NSs would remain the same. Creating a user for each domain would've been simpler but a lot more expensive licence wise.

The purpose here is so that the domain resolves to my nameservers. It doesn't need an account or user as the domain would simply be converted to a link to a unique page on the site displaying the name, price and contact details. That bit i've got licked and works well. It's just the inputting of the domains I'd like a hack for please!
 

Attachments

  • image_2023-01-10_155650033.png
    image_2023-01-10_155650033.png
    12.2 KB · Views: 132
Hello there.

There are api's which can be used to create accounts and packages and other stuff.
I had a quick look and there was an option to remove a subdomain so I guess it will also be possible to remove a domain.

Maybe it's best you check all options and commands for yourself, as I'm no coder.
 
Hello there.

There are api's which can be used to create accounts and packages and other stuff.
I had a quick look and there was an option to remove a subdomain so I guess it will also be possible to remove a domain.

Maybe it's best you check all options and commands for yourself, as I'm no coder.
Thanks Richard.
I'll take a look now. I'm not looking to remove domains from the DNS Zones, although once domains are sold, won't be hard to delete them in DA. Was more a case of bulk creating.
I guess another way I could do it is editing the files? What file would the DNS Zone be kept in in the DirectAdmin folder? I have a backup so don't mind having a fiddle under the hood as it were.
 
**UPDATE**

Found the correct API call in the documentation and had a play around. Used the HTTPSocket.php script from the DirectAdmin server and put together the bit of code below. Will use this in a script to create mutiple domains in my DNS Zone file without typing out everything every domain.
Note: I had to put the ssl:// part there where the DA Server Domain would be as it was causing errors.

<?php

include 'httpsocket.php';

$sock = new HTTPSocket;
$sock->connect('ssl://{DA-Domain}',2222);

$sock->set_login("admin / {admin username}","password");

$sock->set_method('POST');

$sock->query('/CMD_API_DNS_ADMIN',
array(
'action' => 'create',
'domain' => 'domain.xyz',
'ip' => '1.2.3.4',
'ns1' => 'name.server1.com',
'ns2' => 'name.server2.com'

));
$result = $sock->fetch_body();

echo $result;

?>

Cheers everyone who took a look , Looks like i've sorted it now!

Alan.
 
Last edited:
Back
Top