#Listen on localhost
{% if dnsmasq_enable_bind_interfaces %}
bind-interfaces
{% endif %}

{% if dnsmasq_listen_address|length > 0 %}
listen-address={{ dnsmasq_listen_address }}
{% endif %}

{% if dnsmasq_addn_hosts|length > 0 %}
addn-hosts={{ dnsmasq_addn_hosts }}
{% endif %}

{% if dnsmasq_enable_strict_order %}
strict-order
{% endif %}

{% if dnsmasq_enable_all_servers %}
all-servers
{% endif %}

# Forward k8s domain to kube-dns
server=/{{ dns_domain }}/{{ skydns_server }}
# Reply NXDOMAIN to bogus domains requests like com.cluster.local.cluster.local
local=/{{ bogus_domains }}

#Set upstream dns servers
{% if dnsmasq_upstream_dns_servers|length > 0 %}
{% for srv in dnsmasq_upstream_dns_servers %}
server={{ srv }}
{% endfor %}
{% endif %}
{% if system_and_upstream_dns_servers|length > 0 %}
{% for srv in system_and_upstream_dns_servers %}
server={{ srv }}
{% endfor %}
{% elif resolvconf_mode == 'host_resolvconf' %}
{# The default resolver is only needed when the hosts resolv.conf was modified by us. If it was not modified, we can rely on dnsmasq to reuse the systems resolv.conf #}
server={{ cloud_resolver }}
{% endif %}

{% if kube_log_level == '4' %}
log-queries
{% endif %}

{% if dnsmasq_enable_no_resolv %}
no-resolv
{% endif %}

{% if dnsmasq_enable_bogus_priv %}
bogus-priv
{% endif %}

{% if dnsmasq_enable_no_negcache %}
no-negcache
{% endif %}

cache-size={{ cache_size }}
dns-forward-max={{ dns_forward_max }}
max-cache-ttl={{ dnsmasq_max_cache_ttl }}
max-ttl={{ dnsmasq_max_ttl }}
log-facility={{ dnsmasq_log_facility }}

{% for dnsmasq_additional_startup_parameter in dnsmasq_additional_startup_parameters %}
{{ dnsmasq_additional_startup_parameter }}
{% endfor %}