From e9047fa0030827d2c95902147cd74ba2ee37233e Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 4 Mar 2025 21:04:21 +0100 Subject: [PATCH] Services: Dnsmasq DNS & DHCP - only add default dns when not already specified, avoids duplication warning message for https://github.com/opnsense/core/issues/8329 --- .../service/templates/OPNsense/Dnsmasq/dnsmasq.conf | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf b/src/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf index 337d1a7a2..dde17726a 100644 --- a/src/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf +++ b/src/opnsense/service/templates/OPNsense/Dnsmasq/dnsmasq.conf @@ -162,11 +162,17 @@ dhcp-host={{host.hwaddr}}{% if host.set_tag%},set:{{host.set_tag|replace('-','') {% endif %} {% endfor %} -# default dns mapped to this server (0.0.0.0) -dhcp-option=6,0.0.0.0 +{% set has_default=[] %} {% for option in helpers.toList('dnsmasq.dhcp_options') %} dhcp-option{% if option.force == '1' %}-force{% endif %}={% if option.tag %}tag:{{option.tag.replace('-','').split(',')|join(',tag:')}},{% endif %}{{ option.option }},{{ option.value }} +{% if not option.tag and option.option == '6' %} +{%- do has_default.append(1) -%} +{%- endif -%} {% endfor %} +{% if not has_default %} +# default dns mapped to this server (0.0.0.0) +dhcp-option=6,0.0.0.0 +{% endif %} {% for match in helpers.toList('dnsmasq.dhcp_options_match') %} dhcp-match=set:{{match.set_tag.replace('-','')}},{{match.option}}{%if match.value %},{{match.value}}{% endif +%}