update 1 subdomain record remotely?

Discussion in 'Tips/Tricks/Mods' started by commentator, Dec 28, 2018.

  1. commentator

    commentator Member

    Is it possible to update 1 subdomain record?

    Situation
    mydomain.ext hosted dedicated with ispconfig running on it

    home.mydomain.ext is a dynamic ip with a rpi ; I want to update this record when the ip changes.
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Sure, you can do that with the remote api. see examples in remote_client folder of the ispconfig tar.gz file.
     
  3. commentator

    commentator Member

    Thank you for your reply. I can't get it working.
    I've created a remote user with username myuser and pass myit pass
    Checkbox on for Remote Access
    Remote Access IPs / Hostnames (separate by , and leave blank for any): empty
    and allow
    DNS zone functions
    DNS a functions

    If I open the page in the browser I see
    Code:
    SOAP Error: Could not connect to host
    When adding
    Code:
    'stream_context'=> stream_context_create(array('ssl'=> array('verify_peer'=>false,'verify_peer_name'=>false))),
    
    I see this
    Code:
    login_failedThe login failed. Username or password wrong. SOAP Error: The login failed. Username or password wrong.
    I'm sure username and password are correct. Even tried it without strange chars.

    Browsing the remote url shows an empty page, as it should.

    Code:
    <?php
    
    require 'soap_config.php';
    
    
    $client = new SoapClient(null, array('location' => $soap_location,
            'uri'      => $soap_uri,
            'trace' => 1,
            'exceptions' => 1));
    
    
    try {
        $session_id = $client->login($username, $password);
        echo 'Logged successfull. Session ID:'.$session_id.'<br />';
        echo "Logging out: ";
        $client->logout($session_id);
        echo "Logged out.";
    
    
    }catch (SoapFault $e) {
        echo $client->__getLastResponse();
        die('SOAP Error: '.$e->getMessage());
    }
    
    ?>
    
     
  4. Taleman

    Taleman Well-Known Member HowtoForge Supporter

    Using Internet search engines with
    Code:
    site:howtoforge.com api login
    Finds threads with example code connecting to API.
     
  5. commentator

    commentator Member

    are trying to tell me the examples mentioned by @till aren't wrking? code is copy paste from login example
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Ensure that you have set the remote username and password you added in the soap_config.php file and that the remote URL is correct as well. and As Taleman pointed out, there are quite a few posts with example code in the forum and the code from the documentation example works as well.
     
  7. commentator

    commentator Member

    hi, thanks again for your reply.
    When using the curl code it works. And on an other server it is working ok. So it looks like there is something wrong with the server. Not a problem for now as it is working from an other site.

    Is it possible to limit a remote user to change only for specific domain/dns record?
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    no, not yet.
     
  9. commentator

    commentator Member

    ok, thanks again for the reply. Would be a nice item in the future :)

    After update the ip with
    Code:
    $dns_record['data'] = <newip>
    $affected_rows = $client->dns_a_update($session_id, $client_id, $id, $dns_record);
    
    is it necessary to update timestamp and serial as well or is this automatically done?
     
  10. till

    till Super Moderator Staff Member ISPConfig Developer

    You have to update the serial in the zone with an API call after you changed the A-Record.
     
    commentator likes this.
  11. commentator

    commentator Member

    Just to be sure:
    only update zone serial , not the serial in dns record ?
     

Share This Page