diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc index 015067a7bba..f8c27a6a083 100644 --- a/src/etc/inc/plugins.inc.d/unbound.inc +++ b/src/etc/inc/plugins.inc.d/unbound.inc @@ -550,6 +550,11 @@ function unbound_add_host_entries($ifconfig_details) } } + if (empty($host->ttl)) + $ttl = 3600; + else + $ttl = $host->ttl; + foreach ($tmp_aliases as $alias) { $override_is_main = $alias === $tmp_aliases[0]; @@ -563,7 +568,7 @@ function unbound_add_host_entries($ifconfig_details) /* Handle wildcard entries which have "*" as a hostname. Since we added a . above, we match on "*.". */ if ($alias['hostname'] == '*.') { $unbound_entries .= "local-zone: \"{$alias['domain']}\" redirect\n"; - $unbound_entries .= "local-data: \"{$alias['domain']} IN {$host->rr} {$host->server}\"\n"; + $unbound_entries .= "local-data: \"{$alias['domain']} $ttl IN {$host->rr} {$host->server}\"\n"; } else { if (($override_is_main || $tmp_aliases[0]['hostname'] === '*') && !in_array($host->server, $ptr_records, true)) { /* Only generate a PTR record for the non-alias override and only if the IP is not already associated with a PTR. @@ -574,11 +579,11 @@ function unbound_add_host_entries($ifconfig_details) } else { syslog(LOG_WARNING, 'PTR record already exists for ' . $alias['hostname'] . $alias['domain'] . '(' . $host->server . ')'); } - $unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} IN {$host->rr} {$host->server}\"\n"; + $unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} $ttl IN {$host->rr} {$host->server}\"\n"; } break; case 'MX': - $unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} IN MX {$host->mxprio} {$host->mx}\"\n"; + $unbound_entries .= "local-data: \"{$alias['hostname']}{$alias['domain']} $ttl IN MX {$host->mxprio} {$host->mx}\"\n"; break; } diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php index 269beccab94..3afa969aada 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php @@ -175,7 +175,7 @@ public function searchHostOverrideAction() { return $this->searchBase( 'hosts.host', - ['enabled', 'hostname', 'domain', 'rr', 'mxprio', 'mx', 'server', 'description'], + ['enabled', 'hostname', 'domain', 'rr', 'mxprio', 'mx', 'server', 'ttl', 'description'], 'hostname', null, SORT_NATURAL | SORT_FLAG_CASE diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/forms/dialogHostOverride.xml b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/forms/dialogHostOverride.xml index 8f9afc0e3cd..b79e83cea2e 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/forms/dialogHostOverride.xml +++ b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/forms/dialogHostOverride.xml @@ -35,6 +35,12 @@ text Host name of MX host, e.g. mail.example.com + + host.ttl + + text + TTL of the host, e.g. 3600 + host.server diff --git a/src/opnsense/mvc/app/models/OPNsense/Unbound/Unbound.xml b/src/opnsense/mvc/app/models/OPNsense/Unbound/Unbound.xml index 008643593e4..ea87a99a67b 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Unbound/Unbound.xml +++ b/src/opnsense/mvc/app/models/OPNsense/Unbound/Unbound.xml @@ -275,6 +275,9 @@ /^(?:(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])\.)*(?:[a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$/i A valid domain must be specified. + + N + Y A diff --git a/src/opnsense/mvc/app/views/OPNsense/Unbound/overrides.volt b/src/opnsense/mvc/app/views/OPNsense/Unbound/overrides.volt index 8b2ff1ef2bd..4a32d5c8dc4 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Unbound/overrides.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Unbound/overrides.volt @@ -199,6 +199,7 @@ $( document ).ready(function() { {{ lang._('Domain') }} {{ lang._('Type') }} {{ lang._('Value') }} + {{ lang._('TTL') }} {{ lang._('Description') }} {{ lang._('Edit') }} | {{ lang._('Delete') }}