diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/forms/dialogDHCPrange.xml b/src/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/forms/dialogDHCPrange.xml index 4f0e5c3f4..1a20803f8 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/forms/dialogDHCPrange.xml +++ b/src/opnsense/mvc/app/controllers/OPNsense/Dnsmasq/forms/dialogDHCPrange.xml @@ -27,8 +27,8 @@ range.constructor dropdown - - Interface to use to calculate the proper range, when selected, a range may be specified as a suffix (e.g. ::1, ::400) + + Interface to use to calculate a DHCPv6 or RA range. Start address can then be specified as a suffix (e.g. ::, ::1 or ::400). false @@ -60,7 +60,7 @@ dropdown Priority of the RA announcements. - + false @@ -69,7 +69,7 @@ range.ra_mtu text - + Optional MTU to send to clients via Router Advertisements. If unsure leave empty. false @@ -80,7 +80,7 @@ text 60 - + Time (seconds) between Router Advertisements. false @@ -91,7 +91,7 @@ text 1200 - + The lifetime of the route may be changed or set to zero, which allows a router to advertise prefixes but not a route via itself. When using HA, setting a short timespan here is adviced for faster IPv6 failover. A good combination could be 10 seconds RA interval and 30 seconds RA router lifetime. Going lower than that can pose issues in busy networks. false diff --git a/src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php b/src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php index 79c359a69..ba30a3c2d 100644 --- a/src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php +++ b/src/opnsense/mvc/app/models/OPNsense/Dnsmasq/Dnsmasq.php @@ -161,6 +161,15 @@ class Dnsmasq extends BaseModel ); } + if ($range->interface->isEmpty() && !$range->ra_mode->isEmpty()) { + $messages->appendMessage( + new Message( + gettext("Selecting an RA Mode requires an interface."), + $key . ".interface" + ) + ); + } + // Validate RA mode combinations $valid_ra_mode_combinations = [ ['ra-names', 'slaac'], diff --git a/src/opnsense/mvc/app/views/OPNsense/Dnsmasq/settings.volt b/src/opnsense/mvc/app/views/OPNsense/Dnsmasq/settings.volt index 7d11c6a0c..8cfcaf74d 100644 --- a/src/opnsense/mvc/app/views/OPNsense/Dnsmasq/settings.volt +++ b/src/opnsense/mvc/app/views/OPNsense/Dnsmasq/settings.volt @@ -125,15 +125,29 @@ let selected_tab = window.location.hash != "" ? window.location.hash : "#general"; $('a[href="' +selected_tab + '"]').click(); - $("#range\\.start_addr").on("keyup change", function() { - let value = $(this).val() || ""; - if (value.includes(":")) { - $(".style_dhcpv6").closest('tr').show(); - $(".style_dhcpv4").closest('tr').hide(); - } else { - $(".style_dhcpv6").closest('tr').hide(); - $(".style_dhcpv4").closest('tr').show(); - } + $("#range\\.start_addr, #range\\.ra_mode").on("keyup change", function () { + const addr = $("#range\\.start_addr").val() || ""; + const ra_mode = String($("#range\\.ra_mode").val() || "").trim(); + + const styleVisibility = [ + { + class: "style_dhcpv4", + visible: !addr.includes(":") + }, + { + class: "style_dhcpv6", + visible: addr.includes(":") + }, + { + class: "style_ra", + visible: ra_mode !== "" + } + ]; + + styleVisibility.forEach(style => { + const elements = $("." + style.class).closest("tr"); + style.visible ? elements.show() : elements.hide(); + }); }); }); diff --git a/src/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf b/src/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf index 8ca8c8300..896cb4d1c 100644 --- a/src/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf +++ b/src/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf @@ -174,8 +174,9 @@ constructor:{{helpers.physical_interface(dhcp_range.constructor)}}, domain={{ dhcp_range.domain }},{{dhcp_range.start_addr}},{{dhcp_range.end_addr}} {% endif %} -{% if dhcp_range.ra_mode %} -ra-param={{ helpers.physical_interface(dhcp_range.constructor) }} +{#- Only gets added if a custom ra_mode is chosen, otherwise the global defaults of enable-ra are used. -#} +{% if dhcp_range.ra_mode and dhcp_range.interface %} +ra-param={{ helpers.physical_interface(dhcp_range.interface) }} {%- if dhcp_range.ra_mtu %},mtu:{{ dhcp_range.ra_mtu }}{% endif -%} {%- if dhcp_range.ra_priority %},{{ dhcp_range.ra_priority }}{% endif -%}, {%- if dhcp_range.ra_interval %}{{ dhcp_range.ra_interval }}{% else %}60{% endif -%},