diff options
Diffstat (limited to 'roles/vm/network/templates/interfaces.j2')
-rw-r--r-- | roles/vm/network/templates/interfaces.j2 | 44 |
1 files changed, 26 insertions, 18 deletions
diff --git a/roles/vm/network/templates/interfaces.j2 b/roles/vm/network/templates/interfaces.j2 index db0e322f..3c151144 100644 --- a/roles/vm/network/templates/interfaces.j2 +++ b/roles/vm/network/templates/interfaces.j2 @@ -6,25 +6,33 @@ source /etc/network/interfaces.d/* # The loopback network interface auto lo iface lo inet loopback +{% for interface in network_cooked.interfaces %} -# The primary network interface -auto {{ network.primary.interface }} -iface {{ network.primary.interface }} inet static + +auto {{ interface.name }} +iface {{ interface.name }} inet static pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/accept_ra pre-up echo 0 > /proc/sys/net/ipv6/conf/$IFACE/autoconf - address {{ network.primary.ip }} - netmask {{ network.primary.mask }} -{% if 'overlay' in network.primary %} - up /bin/ip addr add dev $IFACE {{ network.primary.overlay }}/32 - up /bin/ip route add default via {{ network.primary.gateway }} src {{ network.primary.overlay }} - down /bin/ip route del default via {{ network.primary.gateway }} src {{ network.primary.overlay }} - down /bin/ip addr del dev $IFACE {{ network.primary.overlay }}/32 -{% else %} - gateway {{ network.primary.gateway }} -{% endif %} -{% if 'prefix6' in network.primary %} + address {{ interface.ip }} + netmask {{ interface.mask }} +{% if 'overlay' in interface %} + up /bin/ip addr add dev $IFACE {{ interface.overlay }}/32 +{% if 'gateway' in interface %} + up /bin/ip route add default via {{ interface.gateway }} src {{ interface.overlay }} + down /bin/ip route del default via {{ interface.gateway }} src {{ interface.overlay }} +{% endif %} + down /bin/ip addr del dev $IFACE {{ interface.overlay }}/32 +{% else %} +{% if 'gateway' in interface %} + gateway {{ interface.gateway }} +{% endif %} +{% endif %} +{% if 'prefix6' in interface %} -iface {{ network.primary.interface }} inet6 static - address {{ network.primary.prefix6 }} - gateway {{ network.primary.gateway6 }} -{% endif %} +iface {{ interface.name }} inet6 static + address {{ interface.prefix6 }} +{% if 'gateway6' in interface %} + gateway {{ interface.gateway6 }} +{% endif %} +{% endif %} +{% endfor %} |