diff options
author | Christian Pointner <equinox@spreadspace.org> | 2020-07-22 23:01:37 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2020-07-22 23:01:37 +0200 |
commit | 076074fa02f4ba33f798c2053771e4827fd1c35f (patch) | |
tree | db6a31c412d1db575efcd902e0eea8a1f1e63720 /roles/vm/guest | |
parent | switch from gpg --verify to gpgv (diff) |
add some more interface configs
Diffstat (limited to 'roles/vm/guest')
3 files changed, 38 insertions, 1 deletions
diff --git a/roles/vm/guest/network/templates/interfaces/multihomed-base.j2 b/roles/vm/guest/network/templates/interfaces/multihomed-base.j2 new file mode 100644 index 00000000..db16d15f --- /dev/null +++ b/roles/vm/guest/network/templates/interfaces/multihomed-base.j2 @@ -0,0 +1,18 @@ + address {{ interface.address | ipaddr('address') }} + netmask {{ interface.address | 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 %} diff --git a/roles/vm/guest/network/templates/interfaces/multihomed-overlay.j2 b/roles/vm/guest/network/templates/interfaces/multihomed-overlay.j2 new file mode 100644 index 00000000..7ac94246 --- /dev/null +++ b/roles/vm/guest/network/templates/interfaces/multihomed-overlay.j2 @@ -0,0 +1,19 @@ + address {{ interface.address | ipaddr('address') }} + netmask {{ interface.address | ipaddr('netmask') }} +{% for overlay in interface.overlays %} +{% if 'name' in overlay %} + ## {{ overlay.name }} +{% endif %} + up /bin/ip addr add dev $IFACE {{ overlay.address }} + up /bin/ip route add default via {{ overlay.gateway }} src {{ overlay.address | ipaddr('address') }} table {{ 200 + loop.index0 }} + up /bin/ip rule add pref {{ 40000 + loop.index0 }} from {{ overlay.address | ipaddr('address') }} lookup {{ 200 + loop.index0 }} +{% endfor %} + ########## +{% for overlay in interface.overlays | reverse %} +{% if 'name' in overlay %} + ## {{ overlay.name }} +{% endif %} + down /bin/ip rule del pref {{ 40000 + loop.revindex0 }} + down /bin/ip route del default via {{ overlay.gateway }} src {{ overlay.address | ipaddr('address') }} table {{ 200 + loop.revindex0 }} + down /bin/ip addr del dev $IFACE {{ overlay.address }} +{% endfor %} diff --git a/roles/vm/guest/network/templates/interfaces/overlay.j2 b/roles/vm/guest/network/templates/interfaces/overlay.j2 index a3262f9c..0524c5df 100644 --- a/roles/vm/guest/network/templates/interfaces/overlay.j2 +++ b/roles/vm/guest/network/templates/interfaces/overlay.j2 @@ -7,8 +7,8 @@ {% 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 %} {% 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 %} {% endfor %} -{% endif %} down /bin/ip addr del dev $IFACE {{ interface.overlay }}/32 |