From e8d7c97876360801521ea982e5b7067eb5351f93 Mon Sep 17 00:00:00 2001 From: Maciej Delmanowski Date: Sun, 29 Mar 2015 23:41:24 +0200 Subject: [PATCH] Filter list of autogenerated nameservers If somehow '127.0.0.1' from 'dnsmasq' got into the list of nameservers in '/etc/resolv.conf', filter it out of the list of advertised nameservers to avoid confusion. --- templates/etc/dhcp/auto_options.j2 | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/templates/etc/dhcp/auto_options.j2 b/templates/etc/dhcp/auto_options.j2 index 72eb0cf..7c0a656 100644 --- a/templates/etc/dhcp/auto_options.j2 +++ b/templates/etc/dhcp/auto_options.j2 @@ -9,7 +9,12 @@ option dhcp6.domain-search "{{ dhcpd_tpl_domain_search | join('", "') }}"; {% if dhcpd_nameservers|d() and dhcpd_nameservers %} {% set dhcpd_tpl_nameservers = dhcpd_nameservers %} {% elif dhcpd_runtime_nameservers|d() and dhcpd_runtime_nameservers %} -{% set dhcpd_tpl_nameservers = dhcpd_runtime_nameservers %} +{% set dhcpd_tpl_nameservers = [] %} +{% for server in dhcpd_runtime_nameservers %} +{% if server not in [ '127.0.0.1', '::1' ] %} +{% set _ = dhcpd_tpl_nameservers.append(server) %} +{% endif %} +{% endfor %} {% endif %} {% if dhcpd_tpl_nameservers %} {% if dhcpd_tpl_nameservers | ipv4 %}