The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

xmlapi addzonerecord (need to add A Record)

Discussion in 'cPanel Developers' started by TimPhin, Mar 18, 2015.

  1. TimPhin

    TimPhin Member

    Joined:
    Mar 18, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    AL
    cPanel Access Level:
    Root Administrator
    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
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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.
     
  3. TimPhin

    TimPhin Member

    Joined:
    Mar 18, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    AL
    cPanel Access Level:
    Root Administrator
    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!
     
  4. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
  5. TimPhin

    TimPhin Member

    Joined:
    Mar 18, 2015
    Messages:
    11
    Likes Received:
    0
    Trophy Points:
    1
    Location:
    AL
    cPanel Access Level:
    Root Administrator
    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
     
  6. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,666
    Likes Received:
    646
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    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:

    Guide to Standardized Hooks
    Guide to Standardized Hooks - Whostmgr Functions

    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.
     
Loading...

Share This Page