gre_upstream.j2 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. {% if ffrl_tun is defined %}
  2. {% for tun in ffrl_tun %}
  3. #auto tun-ffrl-{{tun.name}}
  4. #iface tun-ffrl-{{tun.name}} inet static
  5. # address {{tun.v4_remote | ipaddr( tun.v4_remote.split('.')[3] | int + 1) | ipaddr('address') }}
  6. # netmask {{tun.v4_remote | ipaddr('netmask')}}
  7. # pre-up ip tunnel add $IFACE mode gre local {{ansible_default_ipv4.address}} remote {{tun.gre_target | ipaddr('address') }} ttl 255
  8. # post-up ip link set $IFACE mtu 1400
  9. # post-down ip tunnel del $IFACE
  10. # post-up ip rule add iif $IFACE lookup ffnet
  11. # pre-down ip rule del iif $IFACE lookup ffnet ||:
  12. #iface tun-ffrl-{{tun.name}} inet6 static
  13. # address {{tun.v6_remote | ipaddr('2') | ipaddr('address') }}
  14. # netmask {{tun.v6_remote | ipaddr('prefix')}}
  15. # post-up ip -6 rule add iif $IFACE lookup ffnet
  16. # pre-down ip -6 rule del iif $IFACE lookup ffnet ||:
  17. auto tun-ffrl-{{tun.name}}
  18. iface tun-ffrl-{{tun.name}} inet tunnel
  19. mode gre
  20. ttl 64
  21. mtu 1400
  22. address {{tun.v4_local }}
  23. netmask {{tun.v4_local | ipaddr('netmask')}}
  24. dstaddr {{tun.v4_remote }}
  25. local {{primary_vnic_ip4}}
  26. endpoint {{tun.gre_target}}
  27. post-up ip link set $IFACE mtu 1400
  28. post-down ip tunnel del $IFACE
  29. post-up ip rule add iif $IFACE lookup ffnet
  30. pre-down ip rule del iif $IFACE lookup ffnet ||:
  31. iface tun-ffrl-{{tun.name}} inet6 static
  32. address {{tun.v6_remote | ipaddr('2') | ipaddr('address') }}
  33. netmask {{tun.v6_remote | ipaddr('prefix')}}
  34. post-up ip -6 rule add iif $IFACE lookup ffnet
  35. pre-down ip -6 rule del iif $IFACE lookup ffnet ||:
  36. {% endfor %}
  37. {% endif %}