mirror of
https://github.com/lucaspalomodevelop/core.git
synced 2026-03-13 00:07:26 +00:00
dnsmasq: Use interface directly as tag in dhcp options (#8408)
* dnsmasq: Use interface directly as tag in dhcp options * dnsmasq: Always add tag to interface since set is automatic when interface receives DHCP Broadcast.
This commit is contained in:
parent
b11baac9d5
commit
cd23cfce17
@ -5,11 +5,17 @@
|
||||
<type>dropdown</type>
|
||||
<help>Option to offer to the client.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>option.interface</id>
|
||||
<label>Interface</label>
|
||||
<type>dropdown</type>
|
||||
<help>This adds a single interface as tag so this DHCP option can match the interface of a DHCP range.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>option.tag</id>
|
||||
<label>Tag</label>
|
||||
<type>select_multiple</type>
|
||||
<help>If the optional tags are given then this option is only sent when all the tags are matched.</help>
|
||||
<help>If the optional tags are given then this option is only sent when all the tags are matched. Can be optionally combined with an interface tag.</help>
|
||||
</field>
|
||||
<field>
|
||||
<id>option.value</id>
|
||||
|
||||
@ -171,6 +171,13 @@
|
||||
<ConfigdPopulateAct>dnsmasq list dhcp_options</ConfigdPopulateAct>
|
||||
<Required>Y</Required>
|
||||
</option>
|
||||
<interface type="InterfaceField">
|
||||
<BlankDesc>Any</BlankDesc>
|
||||
<Filters>
|
||||
<if>/^(?!lo0$).*/</if>
|
||||
</Filters>
|
||||
<AllowDynamic>Y</AllowDynamic>
|
||||
</interface>
|
||||
<tag type="ModelRelationField">
|
||||
<Model>
|
||||
<tag>
|
||||
|
||||
@ -132,7 +132,7 @@ set:{{dhcp_range.set_tag|replace('-','')}},
|
||||
{% else %}
|
||||
{# IPv6 range #}
|
||||
dhcp-range={%if dhcp_range.interface -%}
|
||||
{{helpers.physical_interface(dhcp_range.interface)}},
|
||||
tag:{{helpers.physical_interface(dhcp_range.interface)}},
|
||||
{%- endif -%}
|
||||
{%- if dhcp_range.set_tag -%}
|
||||
set:{{dhcp_range.set_tag|replace('-','')}},
|
||||
@ -165,11 +165,21 @@ dhcp-host={{host.hwaddr}}{% if host.set_tag%},set:{{host.set_tag|replace('-','')
|
||||
|
||||
{% 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 -%}
|
||||
{% set all_tags = [] %}
|
||||
{% if option.tag %}
|
||||
{% for tag in option.tag.replace('-','').split(',') %}
|
||||
{% do all_tags.append('tag:' + tag) %}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if option.interface %}
|
||||
{% do all_tags.append('tag:' + helpers.physical_interface(option.interface)) %}
|
||||
{% endif %}
|
||||
dhcp-option{% if option.force == '1' %}-force{% endif %}={% if all_tags %}{{ all_tags|join(',') }},{% endif %}{{ option.option }},{{ option.value }}
|
||||
{% if not option.tag and not option.interface 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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user