ansible-ffibk/roles/network-meshbridge/templates/bridge.j2

34 lines
1.9 KiB
Text
Raw Normal View History

{% set ip4hex = item.ipv4_network | ipaddr('net') | ipaddr(magic) | ipaddr('address') | ip4_hex() -%}
{% set mac = '0210' + ip4hex -%}
#
# {{ ansible_managed }}
#
2017-11-06 21:24:56 +01:00
auto {{ item.id }}br
iface {{ item.id }}br
hwaddress {{ mac | hwaddr('linux') }}
address {{ item.ipv4_network | ipaddr('net') | ipaddr(magic) | ipaddr('ip/prefix') }}
{% for prefix in item.ipv6_ula %}
address {{ prefix | ipaddr('net') | ipsubnet(64, 0) | ipaddr(magic) | ipaddr('ip/prefix') }}
{% endfor %}
{% for prefix in item.ipv6_public %}
address {{ prefix | ipaddr('net') | ipsubnet(64, 0) | ipaddr(magic) | ipaddr('ip/prefix') }}
{% endfor %}
2017-11-06 21:24:56 +01:00
bridge-ports {{ item.id }}bat
# static routes for rt_table mwu
post-up /sbin/ip -4 route add {{ item.ipv4_network }} proto static dev $IFACE table mwu
{% for ula in item.ipv6_ula %}
post-up /sbin/ip -6 route add {{ ula | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu
{% endfor %}
{% for public in item.ipv6_public %}
post-up /sbin/ip -6 route add {{ public | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu
post-up /sbin/ip -6 route add {{ public | ipaddr('net') | ipsubnet(56, magic) | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu
{% endfor %}
pre-down /sbin/ip -4 route del {{ item.ipv4_network }} proto static dev $IFACE table mwu
{% for ula in item.ipv6_ula %}
pre-down /sbin/ip -6 route del {{ ula | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu
{% endfor %}
{% for public in item.ipv6_public %}
pre-down /sbin/ip -6 route del {{ public | ipaddr('net') | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu
pre-down /sbin/ip -6 route del {{ public | ipaddr('net') | ipsubnet(56, magic) | ipsubnet(64, 0) | ipaddr('subnet') }} proto static dev $IFACE table mwu
{% endfor %}