firewall: get mgmt gateway from custom field on prefix

Mainly so we can add IPv6 mgmt addresses and drop the gateway custom
field from NetBox interfaces.
This commit is contained in:
Timotej Lazar 2025-03-26 19:19:09 +01:00
parent 6040a3ae84
commit 2f662373e5

View file

@ -18,9 +18,14 @@ iface {{ iface.name }}
{% endif %} {% endif %}
{% for addr in iface.ip_addresses %} {% for addr in iface.ip_addresses %}
address {{ addr.address }} address {{ addr.address }}
{% endfor %} {% set subnet = addr.address | ipaddr('subnet') %}
{% if iface.custom_fields.gateway %} {% set prefix_match = prefixes | selectattr('prefix', '==', subnet) %}
up ip route add default via {{ iface.custom_fields.gateway.address | ipaddr('address') }}{% if iface.vrf %} vrf {{ iface.vrf.name }}{% endif %} {% if prefix_match %}
{% set prefix = prefix_match | first %}
{% if prefix.custom_fields.gateway %}
up ip route add default via {{ prefix.custom_fields.gateway.address | ipaddr('address') }}{% if iface.vrf %} vrf {{ iface.vrf.name }}{% endif %}
{% endif %}
{% endif +%} {% endif +%}
{% endfor %}
{% endfor %} {% endfor %}