summaryrefslogtreecommitdiff
path: root/roles/vm/network/templates/interfaces.j2
blob: d257a98aa307d93a67857f0ca9c490a4ef632b1d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback
{% for interface in network_cooked.interfaces %}


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 {{ interface.address | ipaddr('address') }}
  netmask {{ interface.address | ipaddr('netmask') }}
{%   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 'address6' in interface %}

iface {{ interface.name }} inet6 static
  address {{ interface.address6 }}
{%     if 'gateway6' in interface %}
  gateway {{ interface.gateway6 }}
{%     endif %}
{%   endif %}
{% endfor %}