From cc2e9cd1c58477aa60f575c6d08b0556f790c911 Mon Sep 17 00:00:00 2001 From: Jesper Hess Nielsen Date: Mon, 27 Apr 2020 08:56:13 +0200 Subject: [PATCH] Add possibility of configuring static routes in the router yml files and clean up OSPF filters --- .../frb1.cph.dk.routers.v6.hessnet.dk.yml | 8 +++++++- roles/bird/templates/bird.conf.j2 | 20 ++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/host_vars/frb1.cph.dk.routers.v6.hessnet.dk.yml b/host_vars/frb1.cph.dk.routers.v6.hessnet.dk.yml index 944bb0b..9cde339 100644 --- a/host_vars/frb1.cph.dk.routers.v6.hessnet.dk.yml +++ b/host_vars/frb1.cph.dk.routers.v6.hessnet.dk.yml @@ -21,7 +21,7 @@ bgp_peers: filters: import: "{ accept; }" export: "{ if is_own_route() then reject; accept; }" - + - name: "ibgp_fra1" template: "ibgp_hessnet" peer_asn: "209616" @@ -30,6 +30,12 @@ bgp_peers: announce_from_here: true configure_static_multihop_routes: false +extra_static_routes: + - route: "2001:678:15c:b00::/128" + destination: "wg-fra1" + - route: "2001:678:15c:c00::/128" + destination: "v6tunnel-home" + wireguard: privatekey: !vault | $ANSIBLE_VAULT;1.1;AES256 diff --git a/roles/bird/templates/bird.conf.j2 b/roles/bird/templates/bird.conf.j2 index 47f5327..caae431 100644 --- a/roles/bird/templates/bird.conf.j2 +++ b/roles/bird/templates/bird.conf.j2 @@ -99,7 +99,7 @@ filter kernel_export { } filter ospf_export { - if source = RTS_DEVICE then accept; + if source !~ [ RTS_DEVICE ] then reject; if is_own_route() then accept; reject; } @@ -111,16 +111,14 @@ filter transit_import { } filter transit_export { -{% if configure_static_multihop_routes is sameas true %} if proto = "noAnnounce_v6" then reject; if proto = "noAnnounce_v4" then reject; -{% endif %} if is_own_aggregated_net() then accept; reject; } filter myroutes_import_export { - if source !~ [ RTS_BGP, RTS_OSPF, RTS_OSPF_EXT1, RTS_OSPF_EXT2, RTS_STATIC ] then reject; + if source !~ [ RTS_BGP, RTS_STATIC ] then reject; if is_own_route() then accept; reject; } @@ -141,25 +139,33 @@ protocol static announce_v4 { } {% endif %} -{% if configure_static_multihop_routes is sameas true %} protocol static noAnnounce_v6 { ipv6; +{% if configure_static_multihop_routes is sameas true %} {% for peer in bgp_peers %} {% if peer.neighbor_ip | ipv6 %} route {{ peer.neighbor_ip }}/128 via {{ router_v6_ip }}; {% endif %} {% endfor %} +{% endif %} +{% if extra_static_routes is defined %} + # other static routes +{% for route in extra_static_routes %} + route {{ route.route }} via "{{ route.destination }}"; +{% endfor %} +{% endif %} } protocol static noAnnounce_v4 { ipv4; +{% if configure_static_multihop_routes is sameas true %} {% for peer in bgp_peers %} {% if peer.neighbor_ip | ipv4 %} route {{ peer.neighbor_ip }}/32 via {{ router_v4_ip }}; {% endif %} {% endfor %} -} {% endif %} +} protocol device { scan time 5; @@ -238,7 +244,7 @@ template bgp ibgp_hessnet { ipv6 { next hop self; import all; - export all; + export filter { if is_own_route() then reject; accept; }; }; }