fetching all DNS entries for a domain

Discussion in 'ISPConfig 3 Priority Support' started by Turgut Kalfaoglu, Feb 10, 2025.

  1. Turgut Kalfaoglu

    Turgut Kalfaoglu Member HowtoForge Supporter

    Hi there. I'm trying to get all the A records of a domain on the system using PHP.
    For example, I'd like to get mail.xyz.com, webmail.xyz.com, ns.xyz.com, xyz.com, etc.

    I thought it would be:
    $dns_records = $client->dns_a_get($session_id, array('name' => $domain_name));
    foreach ($dns_records as $record) {
    (process the DNS records)
    but it seems to leave out lots of records when I do that..
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    You must search by zone, not name. The field 'zone' contains the 'id' of the DNS zone. So first, use the API to get the DNS zone, the zone has a field 'id'. Then use a query like this:

    $dns_records = $client->dns_a_get($session_id, array('zone' => $zone['id']));

    Searching by name can not work as all records containing the DNS short syntax do not have the name of the zone at all, example 'ns1'. Also, take care to append the dot when you select DNS records for a zone or any other fully qualified domain name. So its 'domain.tld.' and not just 'domain.tld' in DNS.
     
    Turgut Kalfaoglu likes this.
  3. Turgut Kalfaoglu

    Turgut Kalfaoglu Member HowtoForge Supporter

    Thank you so much!
     
    till likes this.

Share This Page