Services: Dnsmasq DNS & DHCP - only add default dns when not already specified, avoids duplication warning message for https://github.com/opnsense/core/issues/8329

This commit is contained in:
Ad Schellevis 2025-03-04 21:04:21 +01:00
parent 8c0ef7c3ac
commit e9047fa003

View File

@ -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 +%}