Juniper BGP Session and Route Flaps: Prevention Guide - 夜莺博客

Juniper BGP Session and Route Flaps: Prevention Guide

BGP session flapping is one of the most disruptive events on a Junos router: every flap withdraws and re-advertises routes, triggering route churn across the entire network. This guide, based on the official Juniper Networks Junos documentation, explains why BGP session flaps cascade when VPN address families are configured on route reflectors and AS boundary routers, and shows the exact configuration statements that stop unnecessary flaps before they impact production traffic. You will learn practical prevention techniques including passive EBGP sessions, BGP-static routes, and address-family-level damping.

Why BGP Sessions Flap on Junos OS

When a router or switch is configured as a route reflector (RR) or an AS boundary router (an external BGP peer), and a VPN family such as family inet-vpn unicast is configured, a flap of either the RR IBGP session or the EBGP session causes flaps of all other BGP sessions configured with the same family. The root cause is that Junos re-advertises the full VPN table on session re-establishment, so one unstable session drags down the whole group. Understanding this behavior is the first step of BGP session flapping troubleshooting on Juniper equipment.

Verifying That Unnecessary Session Flaps Are Occurring

Use the following procedure to confirm that VPN-family configuration is amplifying session flaps:

  1. Run show bgp summary to verify that the sessions have been established.
  2. Deactivate the EBGP session with deactivate protocols bgp group ebgp.
  3. Run show bgp summary again and observe the flap counters on the remaining sessions.

Preventing Flaps with a Passive EBGP Session

The recommended fix is to add a passive EBGP session with a neighbor address that does not exist in the peer autonomous system. Because the session is passive, Junos never attempts to actively connect to it, yet the VPN address family still has a valid configuration target, which stops the cascading flap behavior:

set protocols bgp group ebgp passive
set protocols bgp group ebgp neighbor 192.0.2.254

After committing, run show bgp summary to verify that the real sessions are established and the passive session stays idle.

Configuring BGP-Static Routes to Prevent Route Flaps

Beginning with Junos OS Release 14.2, you can configure and advertise BGP-static routes in a BGP network. A BGP-static route can be advertised even when it is not the active route for the prefix, and it does not flap unless deleted manually. This is ideal for stable prefix origination:

set routing-options static route 203.0.113.0/24 discard
set policy-options policy-statement export-bgp term 10 from protocol static
set policy-options policy-statement export-bgp term 10 then accept
set protocols bgp group ibgp export export-bgp

Route Flap Damping at the Address-Family Level

Since Junos OS Release 12.2, flap damping can be applied at the address-family level, for example on family inet-mvpn signaling damping. Damping suppresses unstable prefixes instead of letting every flap propagate to the rest of the network, which is a valuable complement to session-level prevention. See the BGP route flap damping documentation in the Junos BGP guide for full policy examples.

Related Reading

原文链接:https://www.juniper.net/documentation/us/en/software/junos/bgp/topics/topic-map/bgp-session-flaps.html