auto lo
iface lo inet loopback

{% for interface in network_interfaces %}
auto {{ interface.name }}

iface {{ interface.name }} inet {{ interface.ip4_type }}
{% if interface.ip4_type == 'dhcp' and interface.udhcpc_opts is string %}
    udhcpc_opts {{ interface.udhcpc_opts }}
{% endif %}
{% if interface.ip4_type == 'static' %}
    address {{ interface.ip4_addr }}
    gateway {{ interface.ip4_gateway }}
{% endif %}
    post-up /sbin/resolvconf -u

iface {{ interface.name }} inet6 {{ interface.ip6_type }}
{% if interface.ip6_type == 'static' %}
    address {{ interface.ip6_addr }}
    gateway {{ interface.ip6_gateway }}
    pre-up echo 0 > /proc/sys/net/ipv6/conf/{{ interface.name }}/accept_ra
{% endif %}
    post-up /sbin/resolvconf -u
{% endfor %}
