From ecf2f6eff91d956fec35521a001efd847096437d Mon Sep 17 00:00:00 2001 From: Djerk Geurts Date: Fri, 2 Oct 2020 23:46:27 +0100 Subject: [PATCH] Update build_bind.inc.php Forwarding zone solution. Add ona servers are forwarding, this will ensure the named config is added to these servers. Add master servers, these will be the forwarding servers. Ensure ona has an A record for the master server as the forwarding statement needs an IP address not a FQDN. --- build_bind.inc.php | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/build_bind.inc.php b/build_bind.inc.php index e82ce0c..fd067de 100644 --- a/build_bind.inc.php +++ b/build_bind.inc.php @@ -228,15 +228,27 @@ function build_bind_conf($options="") { // what is the role for this server. switch (strtolower($sdomain['role'])) { case "forward": - //TODO: fixme.. this needs IPs like slaves do.. no file - $text .= "zone \"{$domain['fqdn']}\" in {\n type forward;\n file \"/{$options['path']}/named-{$domain['fqdn']}\";}\n"; + // get the IP addresses for the master domain servers for this domain (these will be the forwarders) + list($status, $rows, $records) = db_get_records($onadb, 'dns_server_domains', array('domain_id' => $domain['id'], 'role' => 'master'), ''); + + $text .= "zone \"{$domain['fqdn']}\" in {\n type forward;\n forwarders { "; // \n };\n};\n\n"; + // Add each master as a forwarder + foreach ($records as $master ) { + // Lookup a bunch of crap.. this should be done better. + list($status, $rows, $rec) = ona_get_host_record(array('id' => $master['host_id'])); + list($status, $rows, $rec) = ona_get_dns_record(array('id' => $rec['primary_dns_id'])); + list($status, $rows, $rec) = ona_get_interface_record(array('id' => $rec['interface_id'])); + $text .= $rec['ip_addr_text']."; "; + } + $text .= " };\n"; + $text .= "};\n\n"; break; + case "master": $text .= "zone \"{$domain['fqdn']}\" in {\n type master;\n file \"/{$options['path']}/named-{$domain['fqdn']}\";\n};\n\n"; break; case "slave": - // get the IP addresses for the master domain servers for this domain list($status, $rows, $records) = db_get_records($onadb, 'dns_server_domains', array('domain_id' => $domain['id'], 'role' => 'master'), '');