xmlapi addzonerecord (need to add A Record)
I am working on a project where I am trying to create a new cPanel account with a sub domain then create an A Record for the sub domain to point to the cPanel account. The domain name for the sub domain is on the same server.
I am using the CpanelInc/xmlapi-php. I have successfully created a cPanel account, but stuck on creating the A Record.
This is what I am trying, but I receive the following error:
0 Invalid DNS record: Supplied address for A record is invalid
$domain = "domain.com";
$name = "abc.domain.com.";
$type = "A";
$ip = "64.123.555.123";
$data= array( domain => $domain, name=> $name, type=> $type, ip=> $ip);
print $xmlapi->addzonerecord($domain,$data);
Am I on the right track or way off?
Thank you
-
Hello, An "A" record is already added for a subdomain during the subdomain creation. Are you attempting to modify the default "A" record that's created automatically? Thank you. 0 -
In my previous testing it looked as if I had to create a A record for the domain the sub domain cPanel was created for because they had different IP addresses (doing this in the WHM). But I just did another test via the script and does appear it automatically does it as it does work. Thank you for the quick reply Michael! 0 -
I am happy to see my response was helpful. Thank you for updating us with the outcome. 0 -
Here is a scenario I see happening for me. I may have more than one server running soon. The domain name I will be creating sub domains with will be on server A. But I may need to create an account on server B. Since the main domain is on server A, would there be a way to update the A record to the IP address on server B using addzonerecord for something else? I hope I am making sense. Thank you 0 -
Hello, You could setup a hook that runs during the account creation or subdomain creation on "Sever B" that runs a custom script designed to update the "A" record on "Server A". The following documentation should help you get started: The hook would call upon your own custom script that creates the "A" record on the remote server. An alternative would be to setup DNS clustering so that zones created on "Server B" are automatically synced. Thank you. 0
Please sign in to leave a comment.
Comments
5 comments