Troubleshooting Tip: Prevent advertising a black hole route via BGP when IPsec tunnel is down
| Description | This article describes how to prevent black hole route advertisement to a remote BGP peer. |
| Scope | FortiOS v7.0.x, v7.2.x, v7.4.x, v7.6.x. |
| Solution | When a tunnel goes down, the route to the remote subnet may be withdrawn from the routing table. Without a blackhole route, traffic destined for the remote network may follow the default route, potentially causing traffic to leak to the internet or an unintended WAN interface.
In a BGP deployment where 'redistribute static' is enabled, a configured blackhole static route will still be considered a valid static route and will be redistributed into BGP unless it is explicitly filtered using a route map.
There is an IPsec tunnel between FortiGate_1 and FortiGate_2. On the FortiGate_2 device, a static route is configured for network 172.168.1.0/24 via the IPsec tunnel, black hole route with an AD of 250 is configured as well.
FortiGate_2 has a BGP session with FortiGate_3, and all 'static' routes are advertised to that device.
FortiGate_2 BGP configuration:
config router bgp config redistribute "connected" end config redistribute "rip" end config redistribute "ospf" end
With this configuration, FortiGate_2 will advertise all of its 'static routes'.
The routing table of FortiGate_2 when the IPsec tunnel is up and running:
get router info routing-table database Routing table for VRF=0
When the tunnel is down, the route prefix 172.168.1.0/24 with AD 10 will be removed from the routing table, and only the blackhole route with AD 250, FortiGate_2, will continue to advertise 172.168.1.0/24 with AD 250. In order to prevent the black hole route from being advertised, a configuration change on FortiGate_2 is needed. A route map with a prefix list for every static route is needed. For the IPsec route, a prefix-list with the 'set match-interface IPSec_interface'. This will check if the interface is UP and routes under 'set match-ip-address prefix_list' are learned via that interface.
Adapted BGP configuration:
config redistribute "static"
config router route-map next end
config router prefix-list
When the IPsec is down, FortiGate_2 does not advertise the black hole route:
FortiGate_2 (root) # get router info routing-table details 172.168.1.0 Routing table for VRF=0 Routing entry for 172.168.1.0/24
FortiGate_2 (root) # get router info bgp neighbors 192.168.1.99 advertised-routes Network Next Hop Metric LocPrf Weight RouteTag Path
Total number of prefixes 1
When the IPsec is up, the prefix 172.168.1.0/24 is advertised to FortiGate_3:
FortiGate_2 (root) # get router info routing-table details 172.168.1.0 Routing table for VRF=0
Network Next Hop Metric LocPrf Weight RouteTag Path Total number of prefixes 2 |

