Skip to content

Commit

Permalink
unbound: only generate PTR record for primary domain
Browse files Browse the repository at this point in the history
  • Loading branch information
swhite2 committed Aug 2, 2022
1 parent b504bc8 commit 2115c45
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/etc/inc/plugins.inc.d/unbound.inc
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ function unbound_add_host_entries($ifconfig_details = null)
$aliases = iterator_to_array($unbound_mdl->aliases->alias->iterateItems());

if (!empty($hosts)) {
$ptr_records = [];
foreach ($hosts as $host) {
if ($host->enabled == '1') {
$tmp_aliases = array(array(
Expand Down Expand Up @@ -560,7 +561,11 @@ function unbound_add_host_entries($ifconfig_details = null)
$unbound_entries .= "local-zone: \"{$alias['domain']}\" redirect\n";
$unbound_entries .= "local-data: \"{$alias['domain']} IN {$host->rr} {$host->server}\"\n";
} else {
$unbound_entries .= "local-data-ptr: \"{$host->server} {$alias['hostname']}{$alias['domain']}\"\n";
if (current($tmp_aliases) === $tmp_aliases[0] && !in_array($host->server, $ptr_records)) {
/* Only generate a PTR record for the non-alias override and only if the IP is not already associated with a PTR */
$unbound_entries .= "local-data-ptr: \"{$host->server} {$alias['hostname']}{$alias['domain']}\"\n";
$ptr_records[] = $host->server;
}
$unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} IN {$host->rr} {$host->server}\"\n";
}
break;
Expand Down

0 comments on commit 2115c45

Please sign in to comment.