diff --git a/src/etc/inc/plugins.inc.d/unbound.inc b/src/etc/inc/plugins.inc.d/unbound.inc
index 52994a97c95..c6fadfe9b47 100644
--- a/src/etc/inc/plugins.inc.d/unbound.inc
+++ b/src/etc/inc/plugins.inc.d/unbound.inc
@@ -555,6 +555,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];
@@ -568,7 +573,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.
@@ -579,11 +584,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 07cc8d6764b..b14570d455f 100644
--- a/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php
+++ b/src/opnsense/mvc/app/controllers/OPNsense/Unbound/Api/SettingsController.php
@@ -170,7 +170,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 9f15e2d1adb..fd50dd57e5d 100644
--- a/src/opnsense/mvc/app/models/OPNsense/Unbound/Unbound.xml
+++ b/src/opnsense/mvc/app/models/OPNsense/Unbound/Unbound.xml
@@ -283,6 +283,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 587e0407446..e801f244560 100644
--- a/src/opnsense/mvc/app/views/OPNsense/Unbound/overrides.volt
+++ b/src/opnsense/mvc/app/views/OPNsense/Unbound/overrides.volt
@@ -198,6 +198,7 @@ $( document ).ready(function() {
{{ lang._('Domain') }} |
{{ lang._('Type') }} |
{{ lang._('Value') }} |
+ {{ lang._('TTL') }} |
{{ lang._('Description') }} |
{{ lang._('Edit') }} | {{ lang._('Delete') }} |