summaryrefslogtreecommitdiff
path: root/roles/vm/guest/network/templates/interfaces/multihomed-base.j2
blob: 7ee46cd15e254e18d4d38d1c7a1ad4255e61cc0e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  address {{ interface.address | ansible.utils.ipaddr('address') }}
  netmask {{ interface.address | ansible.utils.ipaddr('netmask') }}
{% for route in interface.static_routes | default([]) %}
  up /bin/ip route add {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %}{% if 'table' in route %} table {{ route.table }}{% endif %}{{ '' }}
{% endfor %}
{% if 'gateway' in interface %}
  up /bin/ip route add default via {{ interface.gateway }} table default
{% endif %}
  up /bin/ip rule add pref 42000 lookup default
  up /bin/ip rule del pref 32767
  down /bin/ip rule add pref 32767 lookup default
  down /bin/ip rule del pref 42000
{% if 'gateway' in interface %}
  down /bin/ip route del default via {{ interface.gateway }} table default
{% endif %}
{% for route in interface.static_routes | default([]) | reverse %}
  down /bin/ip route del {{ route.destination }} via {{ route.gateway }}{% if 'source' in route %} src {{ route.source }}{% endif %}{% if 'table' in route %} table {{ route.table }}{% endif %}{{ '' }}
{% endfor %}