Only add interface definitions for current IPs
Change-Id: I297aad7568e42a0351a26dc54d6b99711c9f3d5a
diff --git a/templates/unbound.conf.j2 b/templates/unbound.conf.j2
index 28a537e..a1b9be7 100644
--- a/templates/unbound.conf.j2
+++ b/templates/unbound.conf.j2
@@ -47,8 +47,11 @@
{% endif %}
{% if unbound_listen_zone_ips and dns_zones %}
{% for key, value in dns_zones.items() %}
+{% set if_ip = value.ip_range | ipaddr('next_usable') | ipaddr('address') %}
+{% if if_ip in ansible_all_ipv4_addresses %}
# listen on IPs defined by dns_zones: {{ key }}
- interface: {{ value.ip_range | ipaddr('next_usable') | ipaddr('address') }}
+ interface: {{ if_ip }}
+{% endif %}
{% endfor %}
{% endif %}