Skip to content

Commit

Permalink
gateways: create static routes for the gre endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
spolack committed Dec 18, 2024
1 parent 45fb5b5 commit 897d7b1
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions roles/cfg_openwrt/templates/gateway/config/network.j2
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,21 @@ config interface 'mgmt'
{% endif %}


{% if uplink['ipv4'] | ansible.utils.ipaddr('prefix') >= 30 %}
{% set ipv4_uplink_gw = uplink['ipv4'] | ansible.utils.ipaddr('peer') %}
{% else %}
{% set ipv4_uplink_gw = uplink['ipv4'] | ansible.utils.ipaddr('1') | ansible.utils.ipaddr('address') %}
{% endif %}

# gre doesnt support _ in name
{% for gateway in groups['role_gateway'] | difference([inventory_hostname]) | sort %}
{% set name = hostvars[gateway]['gre_tunnel_alias'] %}

config route 'route_gre_{{ name }}'
option interface 'uplink'
option target '{{ hostvars[gateway]['uplink']['ipv4'] | ansible.utils.ipaddr('address') }}/32'
option gateway '{{ ipv4_uplink_gw }}'

config interface '{{ name }}'
option proto 'gre'
option ipaddr '{{ uplink['ipv4'] | ansible.utils.ipaddr('address') }}'
Expand Down

0 comments on commit 897d7b1

Please sign in to comment.