Browse Source

better handling of dns-resolvers

netifs
parent
commit
f1ad34ac16
1 changed files with 10 additions and 36 deletions
  1. +10
    -36
      templates/network-interface-debian.j2

+ 10
- 36
templates/network-interface-debian.j2 View File

@@ -19,6 +19,7 @@ auto {{dev}}
{% set virt_pointopoint_ips_ipv6 = hostvars[virt_host].netifs[netifs[netif].virt_host_netif] | json_query("ips[].ip") | ipv6("address") %} {% set virt_pointopoint_ips_ipv6 = hostvars[virt_host].netifs[netifs[netif].virt_host_netif] | json_query("ips[].ip") | ipv6("address") %}
{% set virt_pointopoint_ips_ipv6_first = virt_pointopoint_ips_ipv6 | first %} {% set virt_pointopoint_ips_ipv6_first = virt_pointopoint_ips_ipv6 | first %}
{% set virt_pointopoint_ips_ipv6 = virt_pointopoint_ips_ipv6 | difference(virt_pointopoint_ips_ipv6_first) %} {% set virt_pointopoint_ips_ipv6 = virt_pointopoint_ips_ipv6 | difference(virt_pointopoint_ips_ipv6_first) %}

iface {{ dev }} inet static iface {{ dev }} inet static
address {{ ips_ipv4_first }} address {{ ips_ipv4_first }}
netmask 255.255.255.255 netmask 255.255.255.255
@@ -28,22 +29,10 @@ iface {{ dev }} inet static
post-up /sbin/ip -family inet route add {{ ptpip }}/32 dev {{ dev }} via {{ virt_pointopoint_ips_ipv4_first }} post-up /sbin/ip -family inet route add {{ ptpip }}/32 dev {{ dev }} via {{ virt_pointopoint_ips_ipv4_first }}
pre-down /sbin/ip -family inet route del {{ ptpip }}/32 dev {{ dev }} via {{ virt_pointopoint_ips_ipv4_first }} pre-down /sbin/ip -family inet route del {{ ptpip }}/32 dev {{ dev }} via {{ virt_pointopoint_ips_ipv4_first }}
{% endfor %} {% endfor %}
{% if netifs[netif].dns_resolvers is defined and netifs[netif].dns_resolvers | ipv4 %}
dns-nameservers {{ netifs[netif].dns_resolvers | ipv4 | join(" ") }}
{% endif %}
{% if netifs[netif].dns_search is defined%}
dns-search {{ netifs[netif].dns_search | join(" ") }}
{% endif %}
{% for ip in ips_ipv4 %} {% for ip in ips_ipv4 %}
iface {{ dev }} inet static iface {{ dev }} inet static
address {{ ip }} address {{ ip }}
netmask 32 netmask 32
{% if netifs[netif].dns_resolvers is defined and netifs[netif].dns_resolvers | ipv4 %}
dns-nameservers {{ netifs[netif].dns_resolvers | ipv4 | join(" ") }}
{% endif %}
{% if netifs[netif].dns_search is defined %}
dns-search {{ netifs[netif].dns_search | join(" ") }}
{% endif %}
{% endfor %} {% endfor %}
iface {{ dev }} inet6 static iface {{ dev }} inet6 static
address {{ ips_ipv6_first }} address {{ ips_ipv6_first }}
@@ -55,23 +44,11 @@ iface {{ dev }} inet6 static
{% for ptpip in virt_pointopoint_ips_ipv6 %} {% for ptpip in virt_pointopoint_ips_ipv6 %}
post-up /sbin/ip -family inet6 route add {{ ptpip }} dev {{ dev }} via {{ virt_pointopoint_ips_ipv6_first }} post-up /sbin/ip -family inet6 route add {{ ptpip }} dev {{ dev }} via {{ virt_pointopoint_ips_ipv6_first }}
pre-down /sbin/ip -family inet6 route del {{ ptpip }} dev {{ dev }} via {{ virt_pointopoint_ips_ipv6_first }} pre-down /sbin/ip -family inet6 route del {{ ptpip }} dev {{ dev }} via {{ virt_pointopoint_ips_ipv6_first }}
{% if netifs[netif].dns_resolvers is defined and netifs[netif].dns_resolvers | ipv6 %}
dns-nameservers {{ netifs[netif].dns_resolvers | ipv6 | join(" ") }}
{% endif %}
{% if netifs[netif].dns_search is defined %}
dns-search {{ netifs[netif].dns_search | join(" ") }}
{% endif %}
{% endfor %} {% endfor %}
{% for ip in ips_ipv6 %} {% for ip in ips_ipv6 %}
iface {{ dev }} inet6 static iface {{ dev }} inet6 static
address {{ ip }} address {{ ip }}
netmask 128 netmask 128
{% if netifs[netif].dns_resolvers is defined and netifs[netif].dns_resolvers | ipv6 %}
dns-nameservers {{ netifs[netif].dns_resolvers | ipv6 | join(" ") }}
{% endif %}
{% if netifs[netif].dns_search is defined %}
dns-search {{ netifs[netif].dns_search | join(" ") }}
{% endif %}
{% endfor %} {% endfor %}


{% else %} {% else %}
@@ -82,12 +59,6 @@ iface {{ dev }} inet6 static
iface {{ dev }} inet6 static iface {{ dev }} inet6 static
address {{ ip.ip | ipv6('address') }} address {{ ip.ip | ipv6('address') }}
netmask {{ ip.ip | ipv6('netmask') }} netmask {{ ip.ip | ipv6('netmask') }}
{% if netifs[netif].dns_resolvers is defined and netifs[netif].dns_resolvers | ipv6 %}
dns-nameservers {{ netifs[netif].dns_resolvers | ipv6 | join(" ") }}
{% endif %}
{% if netifs[netif].dns_search is defined %}
dns-search {{ netifs[netif].dns_search | join(" ") }}
{% endif %}
{% endif %} {% endif %}
{% if ip.ip | ipv4 %} {% if ip.ip | ipv4 %}
# ipv4 {{ip.ip}} # ipv4 {{ip.ip}}
@@ -100,13 +71,16 @@ iface {{ dev }} inet static
{% set default_route = netifs[netif].routes | json_query("[?to=='default']") | first %} {% set default_route = netifs[netif].routes | json_query("[?to=='default']") | first %}
gateway {{default_route.via}} gateway {{default_route.via}}
{% endif %} {% endif %}
{% if netifs[netif].dns_resolvers is defined and netifs[netif].dns_resolvers | ipv4 %}
dns-nameservers {{ netifs[netif].dns_resolvers | ipv4 | join(" ") }}
{% endif %}
{% if netifs[netif].dns_search is defined %}
dns-search {{ netifs[netif].dns_search | join(" ") }}
{% endif %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}


{% endif %} {% endif %}

# dns resolvers
iface {{ dev }} inet manual
{% if netifs[netif].dns_resolvers is defined %}
dns-nameservers {{ netifs[netif].dns_resolvers | join(" ") }}
{% endif %}
{% if netifs[netif].dns_search is defined%}
dns-search {{ netifs[netif].dns_search | join(" ") }}
{% endif %}

Loading…
Cancel
Save