interface.conf.j2 1.0 KB

12345678910111213141516171819202122232425262728
  1. auto {{ item.name }}
  2. iface {{ item.name }} inet6 manual
  3. pre-up ip link add {{ item.name }} type dummy
  4. {% if item.ipv4 is defined %}{% for ip in item.ipv4 %}
  5. up ip addr add dev {{ item.name }} {{ ip }}/32
  6. {% endfor %}{% endif %}
  7. {% if item.ipv6 is defined %}{% for ip in item.ipv6 %}
  8. up ip addr add dev {{ item.name }} {{ ip }}/128
  9. {% endfor %}{% endif %}
  10. post-down ip link del {{ item.name }}
  11. {% if item.routes is defined %}{% for route in item.routes %}
  12. post-up ip route add {{ route.target }} {{ route.prefix }} proto static
  13. pre-down ip route del {{ route.target }} {{ route.prefix }} proto static
  14. {% endfor %}{% endif %}
  15. {% if item.rules is defined %}{% for rule in item.rules %}
  16. {% if rule.proto == "ipv4" %}
  17. post-up ip rule add {{ rule.selector }} {{ rule.action }}
  18. pre-down ip rule del {{ rule.selector }} {{ rule.action }}
  19. {% else %}
  20. post-up ip -6 rule add {{ rule.selector }} {{ rule.action }}
  21. pre-down ip -6 rule del {{ rule.selector }} {{ rule.action }}
  22. {% endif %}
  23. {% endfor %}{% endif %}