diff --git a/roles/exit/templates/frr.conf.j2 b/roles/exit/templates/frr.conf.j2 index 059a5ff..39c35e1 100644 --- a/roles/exit/templates/frr.conf.j2 +++ b/roles/exit/templates/frr.conf.j2 @@ -11,8 +11,16 @@ service integrated-vtysh-config # Route to the outside world. vrf outside - ip route 0.0.0.0/0 {{ (interfaces | selectattr('name', '==', iface_uplink) | first).custom_fields.gateway.address | ipaddr('address') }} {{ iface_uplink }} - ipv6 route ::/0 fe80::2 {{ iface_uplink }} +{# Add default routes for IPv4 and IPv6. Both are over link-local addresses. #} +{% set uplink = interfaces | selectattr('name', '==', iface_uplink) | first %} +{% for address in uplink.ip_addresses %} +{% set gateway = address.address | ipmath(1) %} +{% if address.family.value == 4 %} + ip route 0.0.0.0/0 {{ gateway }} {{ iface_uplink }} +{% else %} + ipv6 route ::/0 {{ gateway }} {{ iface_uplink }} +{% endif %} +{% endfor %} # Route installation into kernel fails (rarely) without this option. # It is not documented anywhere and appears to be a Cumulus extension.