Is it possible to use $include in the DNS configuration?

Discussion in 'Installation/Configuration' started by albert, Jul 27, 2023.

  1. albert

    albert New Member

    It is interesting to have the possibility of massively changing some records such as MX or A in case of failures or migrations.
     
  2. pyte

    pyte Well-Known Member HowtoForge Supporter

    There is no need for that. You could just mass edit the entries in the Database
     
  3. albert

    albert New Member

    Is this in the pdf manual?
     
  4. pyte

    pyte Well-Known Member HowtoForge Supporter

    I don't think it is. And there would be more steps required after chaning the values in the database. May you want to elaborate what exatcly you want to change?
     
  5. pyte

    pyte Well-Known Member HowtoForge Supporter

    The API would be another method which requires some scripting efforts but should be simple enough.
    Let's assume you want to change every A record where the subdomain is "www" for all entries within ISPConfig:

    Code:
    // Get all A Records where the subdomain(name) is "www"
    $dns_records = $client->dns_a_get($session_id, array('name' => 'www'));
    
    foreach($dns_records as $record) {
    
        // Set the new Subdomainname so instead of www -> www-new
        $record['name'] = "www-new";
    
        // Get the client_id by sys_userid as it is required for dns_a_update call
        $client_id = $client->client_get_id($session_id, $record['sys_userid']);
    
        // Update the A Record with the new settings
        $client->dns_a_update($session_id, $client_id, $record['id'], $record);
    }
    
    This is not tested, but something like this should work.
     
  6. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    i don't see it working..
    bind itself is going to be working based on actual files. with precise records, not variables.

    what you may be able to do, is have something monitor for failures, and update files containing the failed ip, (also updating the serial number) and refresh / reload bind.
    or similarly monitor for failures, and update the field in the dbispconfig.dns_rr table. with an mysql event trigger watching for changes to that field, and having that trigger a script to resync the dns files.

    seems a lot of effort and potential problems doing that though.. and you're still going to have to deal with dns propagation.

    surely a better option, assuming you've already got other instances working already, is to have the mx / a record point to an, eg haproxy load balancer, which itself can monitor the backend servers to ensure they are working and available, and have that forward traffic to the working backend server..
     
    pyte likes this.
  7. pyte

    pyte Well-Known Member HowtoForge Supporter

    Thats why i described the method via API. Which is alot less hassle.

    Yes if we are talking load balancing/failover config this is not the way. But the question seemed more like a onetime thing to me than to setup high availability
     
  8. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    he states in case of failures or migrations..
    yes, migrations would be an unusual, probably onetime event.. but failures.. that could be at anytime, without warning..
    exactly what load balancing / failover is designed for. mass dns record changes are not really a suitable solution.. even with a very short TTL. there's no guarantee other dns servers with pay any attention to them.. many will ignore ttl's set to less than 10 minutes, i know there's dns servers out there that seem to ignore specified ttl's completely and only update their cache once a week.
     
    ahrasis likes this.
  9. pyte

    pyte Well-Known Member HowtoForge Supporter

    Oh i'm totally with you, thats not a great idea. As i said, i don't know what albert meant when he talked about "failures", this is very vague.
     

Share This Page