Custom DNS records via script?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Pedja
    Senior Member
    • Mar 2004
    • 329

    Custom DNS records via script?

    I need an option to set DNS records for specific DNS zone via script on my web site on cpanel account. More precise, I have domain hosted on cpanel account, and want to provide an option to setup subdomains but only as DNS records. I also control WHM where cpanel is located.

    Anyone knows some good resource?
  • AndrewT
    Administrator
    • Mar 2004
    • 3653

    #2
    Unfortunately cPanel does not provide any way to do this.

    Comment

    • Pedja
      Senior Member
      • Mar 2004
      • 329

      #3
      I know, but I hoped someone hacked it a bit


      Here is my attempt, which failed:

      Code:
      <?php
      
      
      			$url = 'https://user:pass@whm.domain.com:2087/cgi/zoneeditor.cgi';
      
      			$ch = curl_init();
      
            curl_setopt($ch, CURLOPT_URL, $url);
            curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt');
            curl_setopt($ch, CURLOPT_POST, 1);
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query(array(
      					'zone'=> 'test.domain.com.db',
      					'prog'=> 'savezone',
                'line-1-1' => '; cPanel first:11.23.6-STABLE_27545 latest:11.23.6-NIGHTLY_27537 Cpanel::ZoneFile::VERSION:1.2 mtime:1231186329' ,
                'line-2-1' => '; Zone file for test.domain.com', 
                'line-3-1' => '$TTL 14400',
      					'line-4-1' => 'test.domain.com.',
      					'line-4-2' => '14400',
      					'line-4-3' => 'IN',
      					'line-4-4' => 'SOA',
      					'line-4-5' => 'ns1.domain.com.',
      					'line-4-6' => 'office.domain.com.',
      					'line-4-7' => '(',
      					'line-4-8' => '2009010503',
      					'line-4-9' => '14400',
      					'line-4-10' => '7200',
      					'line-4-11' => '3600000',
      					'line-4-12' => '86400',
                'line-4-13' => ')',
      					'line-5-1' => '',
      					'line-6-1' => 'test.domain.com.',
      					'line-6-2' => '14400',
      					'line-6-3' => 'IN',
      					'line-6-4' => 'NS',
      					'line-6-5' => 'ns1.domain.com.',
      					'line-7-1' => 'test.domain.com.',
      					'line-7-2' => '14400',
      					'line-7-3' => 'IN',
      					'line-7-4' => 'NS',
      					'line-7-5' => 'ns2.domain.com.',
      					'line-8-1' => '',
                'line-9-1' => 'test.domain.com.',
      					'line-9-2' => '14400',
      					'line-9-3' => 'IN',
      					'line-9-4' => 'A',
      					'line-9-5' => '75.126.144.69',
      					'line-10-1' => '',
      					'line-11-1' => 'localhost',
      					'line-11-2' => '14400',
      					'line-11-3' => 'IN',
      					'line-11-4' => 'A',
      					'line-11-5' => '127.0.0.1',
      					'line-12-1' => '',
      					'line-13-1' => 'test.domain.com.',
                'line-13-2' => '14400',
      					'line-13-3' => 'IN',
      					'line-13-4' => 'MX',
      					'line-13-5' => '0',
      					'line-13-6' => 'test.domain.com.',
      					'line-14-1' => '',
      					'line-15-1' => 'mail',
      					'line-15-2' => '14400',
      					'line-15-3' => 'IN',
      					'line-15-4' => 'CNAME',
      					'line-15-5' => 'test.domain.com.',
      					'line-16-1' => 'www',
      					'line-16-2' => '14400',
                'line-16-3' => 'IN',
      					'line-16-4' => 'CNAME',
      					'line-16-5' => 'test.domain.com.',
      					'line-17-1' => 'wwa',
      					'line-17-2' => '14400',
                'line-17-3' => 'IN',
      					'line-17-4' => 'CNAME',
      					'line-17-5' => 'test.domain.com.',
      					'line-18-1' => 'ftp',
      					'line-18-2' => '14400',
      					'line-18-3' => 'IN',
      					'line-18-4' => 'A',
      					'line-18-5' => '75.126.144.69',
      					'submit' => 'Save'
            )));
            
            $data = curl_exec($ch);
      			$info = curl_getinfo($ch);
      echo "<pre>";
      print_r ($data);
      print_r ($info);
      
      echo "</pre>";
      
      ?>

      Comment

      • ZYV
        Senior Member
        • Sep 2005
        • 315

        #4
        Looks reasonable. Where exactly does it fail, what are the error messages coming from WHM? Does it authenticate successfully or not?

        You may wish to look into

        This class can be used to manage CPanel hosting accounts. It connects to a CPanel management API Web server and and can execute several types of operations on hosting accounts: Create or kill an account, Retrieve the list of existing accounts, Suspend and unsuspend accounts, Retrieve the list of available packages, Retrieve the CPanel API version The class is based on the code of the original...


        for inspiration.

        Comment

        • ZYV
          Senior Member
          • Sep 2005
          • 315

          #5
          Maybe reconsider your approach having this read?

          Comment

          • Pedja
            Senior Member
            • Mar 2004
            • 329

            #6
            It won't help. I want to be able to set subdomains but point them to arbitrary dNS (basically, all I need is to set NS records for each subdomain). I do not need to open accounts, and for the most domains I do not even need to host them at Dathorn.

            Yes, I still did not manage to make working script to do that.

            Comment

            Working...