dns_a_get returning just header information

Discussion in 'Developers' Forum' started by Turgut Kalfaoglu, Jan 26, 2025.

  1. Turgut Kalfaoglu

    Turgut Kalfaoglu Member HowtoForge Supporter

    Hi. I'm trying to get all the 'A' records of a domain, so I tried:
    $dns_records = $client->dns_a_get($session_id, $zone_id);
    where the $zone_id is the ID (not name - correcting) of a domain.
    It only returns a strange list like this, whereas there are many A records to that domain:
    Code:
    Debug: DNS records for zone XYZ.com.:
    Array
    (
       [id] => 16
       [sys_userid] => 3
       [sys_groupid] => 3
       [sys_perm_user] => riud
       [sys_perm_group] => riud
       [sys_perm_other] =>
       [server_id] => 1
       [zone] => 1
       [name] => ns1.kalfa.uk.
       [type] => A
       [data] => 178.63.47.112
       [aux] => 0
       [ttl] => 86400
       [active] => Y
       [stamp] => 2024-12-13 19:37:17
       [serial] => 2024122301
    )
    
     
    Last edited: Jan 26, 2025
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    $zone_id is not the domain; it's the ID of the zone (see database scheme of the dns_rr table). In your case, $zone_id = 1. In general, using a term like '_id' in a variable name suggests that it must be a unique number, not a text string.
     
    Turgut Kalfaoglu likes this.
  3. Turgut Kalfaoglu

    Turgut Kalfaoglu Member HowtoForge Supporter

    My mistake I'm sorry, I was indeed using the NUMBER of the domain, 16 in my case as $zone_id.
    And still not getting all the A records.
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    The way you called that function is to return a single A-Record only. Try this instead:

    Code:
    $dns_records = $client->dns_a_get($session_id, ['zone' => $zone_id]);
     
    Turgut Kalfaoglu likes this.
  5. Turgut Kalfaoglu

    Turgut Kalfaoglu Member HowtoForge Supporter

    Thank you VERY much!
     
  6. Turgut Kalfaoglu

    Turgut Kalfaoglu Member HowtoForge Supporter

    I got my script working - it changes all the A and AAAA IP addresses of a domain from an old IP to a new IP.
    It's great after migrating a domain from old server to new.
    you just run it like:
    php update-domain-ips.php mydomain.com
    is there a place where I can place it so others might use it?
     
  7. till

    till Super Moderator Staff Member ISPConfig Developer

    Turgut Kalfaoglu likes this.

Share This Page