· 9 min read

BGP Session Flapping or Stuck in Active: Troubleshooting Guide

A BGP session that flaps or sits in Idle, Active or Connect almost always fails at one of three layers: IP/TCP reachability, session parameters (authentication, AS numbers, timers), or policy and resource limits (max-prefix, CPU, CoPP). The fastest fix is to read the state, read the last NOTIFICATION, and then test each layer in order.

Step 1: Read the state and the last error

The FSM state tells you where to look.

State What it means Look at
Idle Not attempting a connection Admin shutdown, no route to peer, max-prefix restart timer, config error
Connect TCP handshake in progress Return path, ACLs, wrong source address
Active Retrying TCP, no completed handshake Peer not listening, filtered port 179, MD5/TCP-AO mismatch, TTL
OpenSent / OpenConfirm TCP is up, BGP OPEN not accepted Wrong remote AS, capabilities, router-ID clash, auth
Established, then drops Session came up, then failed Hold timer, MTU, max-prefix, CPU, link loss

Note that "Active" is not "working." It means the router is actively trying and failing.

Get the last reset reason first:

# Cisco IOS/IOS-XE
show ip bgp summary
show ip bgp neighbors 192.0.2.1 | include BGP state|Last reset|Notification|hold|Connections
show tcp brief | include 192.0.2.1

# Juniper
show bgp summary
show bgp neighbor 192.0.2.1
show log messages | match "bgp|192.0.2.1" | last 50

# MikroTik RouterOS v7
/routing/bgp/session print detail where remote.address=192.0.2.1
/log print where topics~"bgp"

# Linux / BIRD
birdc show protocols all peer1
journalctl -u bird --since "-30min"

The NOTIFICATION code narrows things quickly: code 4 is hold timer expired, code 6 is Cease (subcode 1 is max-prefix reached), and code 2 is an OPEN message error (bad peer AS, for example).

Step 2: Prove IP and TCP reachability

Stuck in Connect or Active, start with the basics from the correct source address. eBGP over a directly connected link and iBGP from loopbacks behave differently here.

# Cisco
ping 192.0.2.1 source 192.0.2.2
telnet 192.0.2.1 179 /source-interface GigabitEthernet0/0/1

# Juniper
ping 192.0.2.1 source 192.0.2.2 count 5

# MikroTik
/ping 192.0.2.1 src-address=192.0.2.2 count=5

# Linux
ping -c5 -I 192.0.2.2 192.0.2.1
ss -tnp state all '( sport = :179 or dport = :179 )'
tcpdump -ni eth0 'host 192.0.2.1 and tcp port 179'

What the capture tells you:

Common mistakes:

Step 3: Check authentication (MD5 and TCP-AO)

An MD5 or TCP-AO mismatch is silent. The receiving TCP stack drops segments with a bad signature without replying, so you see repeating SYNs, no SYN-ACK, and a session bouncing between Connect and Active. The BGP process often logs nothing.

# Cisco: MD5
router bgp 64496
 neighbor 192.0.2.1 password <key>

# Juniper: MD5 (TCP-AO uses an authentication-key-chain; check your release)
set protocols bgp group UPSTREAM neighbor 192.0.2.1 authentication-key "<key>"

# MikroTik v7
/routing/bgp/connection set peer1 tcp-md5-key="<key>"

# BIRD
protocol bgp peer1 {
  local 192.0.2.2 as 64496;
  neighbor 192.0.2.1 as 64497;
  password "<key>";
}

A quick test is to remove authentication on both sides in a maintenance window. If the session comes up, the key is the problem.

Step 4: Hold timer expiry and the MTU trap

Session establishes, then drops with "hold timer expired" a few seconds to a few minutes later? Suspect MTU or PMTUD, especially if it happens right as the routes are being exchanged.

Here is why. OPEN and KEEPALIVE messages are tiny and always get through. Large UPDATE messages fill full-size TCP segments. If the path MTU is smaller than the MSS negotiated, and ICMP "fragmentation needed" is filtered, those segments vanish. The TCP retransmissions stall, KEEPALIVEs queue behind the stuck data, and the hold timer expires. After the reset, the cycle repeats.

Test with DF-bit pings at your expected MTU:

# Linux (1472 + 28 = 1500)
ping -M do -s 1472 192.0.2.1

# Cisco
ping 192.0.2.1 size 1500 df-bit

# Juniper
ping 192.0.2.1 size 1472 do-not-fragment

# MikroTik
/ping 192.0.2.1 size=1500 do-not-fragment

Fixes, in order of preference:

  1. Make the MTU consistent on both ends of the link, including L2 switches and tunnels in the path.
  2. Allow ICMP type 3 code 4 (and ICMPv6 Packet Too Big) end to end, and enable PMTUD for BGP: ip tcp path-mtu-discovery on Cisco.
  3. Clamp TCP MSS on the interface or tunnel as a workaround.

Other hold timer causes include packet loss on the link, a saturated uplink (during a volumetric attack, KEEPALIVEs can be dropped in the same queue as attack traffic), or a peer that is too busy to send keepalives. Mark control-plane traffic (TCP/179) with a high-priority DSCP class and give it a protected queue on congested links. Don't set an aggressively low hold time as a "fix." Where you need quick failure detection, use BFD instead, and tune its intervals conservatively.

Step 5: Max-prefix limits

If the session drops exactly when the peer announces more routes, check the prefix limit. The result is a Cease NOTIFICATION, and the session may stay in Idle until a restart timer fires or you clear it manually.

# Cisco
show ip bgp neighbors 192.0.2.1 | include Maximum|prefixes
router bgp 64496
 address-family ipv4 unicast
  neighbor 192.0.2.1 maximum-prefix 1000 80 restart 10

# Juniper
set protocols bgp group UPSTREAM family inet unicast prefix-limit maximum 1000 teardown 80 idle-timeout 10

# BIRD 2
ipv4 {
  import limit 1000 action restart;
};

Compare the limit with what the peer actually sends, and leave headroom. If the neighbor is a customer that announces a growing prefix list, set the limit from the registered AS-SET and review it periodically.

Step 6: Route filters: session up, no routes

If the session is Established but routes are missing, the problem is policy, not transport. Check what is received before the filter and what survives it:

# Cisco (needs soft-reconfiguration inbound for received-routes)
show ip bgp neighbors 192.0.2.1 received-routes
show ip bgp neighbors 192.0.2.1 routes
show ip bgp neighbors 192.0.2.1 advertised-routes

# Juniper
show route receive-protocol bgp 192.0.2.1 hidden
show route advertising-protocol bgp 192.0.2.1

# MikroTik
/routing/route print where bgp

# BIRD (keep filtered routes for debugging)
birdc show route protocol peer1 filtered

In BIRD, add import keep filtered on; to the channel so you can see what the filter rejected. On Juniper, "hidden" routes usually mean the next hop is unresolvable or an import policy rejected them. Also confirm that prefix-lists and as-path filters match the data in your IRR objects. A stale route object produces a perfectly healthy session that carries nothing.

Step 7: CPU and control-plane policing

Hardware routers protect the control plane with CoPP (Cisco), loopback firewall filters (Juniper), or similar policers. If those are too tight, or if the router is under attack, BGP packets get dropped alongside everything else. Symptoms include flaps that line up with traffic spikes, high CPU in the BGP or IP Input process, and policer drop counters rising.

# Cisco
show processes cpu sorted | exclude 0.00
show policy-map control-plane

# Juniper
show system processes extensive | match "rpd|CPU"
show firewall filter protect-re

# MikroTik
/tool profile

# Linux
top -H -p $(pidof bird)
nstat -az | grep -i -E "drop|overflow"

Make sure your CoPP or RE-protect filter explicitly permits TCP/179 from configured peers only, with a generous rate. Lower-priority traffic, such as ICMP and SNMP, should be policed more tightly than BGP. Also check for a route flap storm that puts load on both routers: dampening, a clear policy, and sensible timers help.

Diagnosing flaps inside GRE DDoS tunnels

When BGP runs inside a GRE tunnel, such as the one used for clean-traffic delivery from a scrubbing provider, add these checks.

Recursive routing. If the tunnel destination becomes reachable through the tunnel itself (for example, because your prefix is now announced via the scrubbing edge), the tunnel collapses and BGP flaps in a loop. Pin the tunnel endpoint with a static route over the physical uplink.

MTU and MSS. GRE over IPv4 adds 24 bytes, so a 1500-byte uplink gives a 1476 tunnel MTU and an MSS of 1436 for IPv4 TCP. Verify with DF pings through the tunnel.

ip tunnel add gre-edge mode gre local 198.51.100.10 remote 203.0.113.1 ttl 255
ip addr add 192.0.2.2/30 dev gre-edge
ip link set gre-edge mtu 1476 up
iptables -t mangle -A FORWARD -o gre-edge -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu

Protocol 47 and uplink filtering. Confirm that your firewall permits IP protocol 47 from the tunnel endpoint, and check with tcpdump -ni eth0 proto gre that packets arrive in both directions.

Reverse path filtering. Strict rp_filter on Linux can drop decapsulated packets. Check sysctl net.ipv4.conf.all.rp_filter.

Inner BGP session. Test the tunnel's inner addresses with ping first, then test TCP/179 on them. If ping works but BGP drops, you are back to MTU, MSS, or authentication.

NixGuard Edge works this way: your prefixes are announced from the scrubbing edge and clean traffic returns over GRE with a BGP session inside. If you are building or debugging that setup, the NixGuard Edge overview covers the requirements, including your own ASN and at least one /24.

A short checklist

  1. Read state and the last NOTIFICATION.
  2. Ping from the right source, then capture TCP/179.
  3. Check authentication on both sides.
  4. Test the path MTU with DF pings.
  5. Compare prefix counts against max-prefix limits.
  6. Check received vs. accepted routes.
  7. Review CPU, CoPP counters, and congested queues.
  8. For tunnels, check recursive routing, MTU, and protocol 47.

If you also want attack visibility next to your session troubleshooting, you can try NixMon free for 15 days. No credit card is required.

Frequently asked questions

Why is my BGP session stuck in Active?

Active means the router is trying to open a TCP connection and failing. Common causes are no route to the peer, a firewall blocking TCP/179, the wrong update source, an MD5 or TCP-AO mismatch, or eBGP multihop not configured. A packet capture on port 179 usually shows which one.

Why does BGP flap with hold timer expired right after coming up?

This is the classic MTU symptom. Small OPEN and KEEPALIVE messages pass, but large UPDATE segments are dropped when the path MTU is lower than the MSS and ICMP is filtered. Fix the MTU, allow ICMP fragmentation-needed messages, or clamp the MSS.

How can I tell if an MD5 mismatch is the problem?

Mismatched MD5 or TCP-AO segments are silently dropped, so you see repeated SYNs with no SYN-ACK and often no log message. Temporarily remove authentication on both sides, or re-enter the key. If the session then comes up, the key was the issue.

What MTU and MSS should I use for BGP inside a GRE tunnel?

GRE over IPv4 adds 24 bytes of overhead. On a 1500-byte uplink, set the tunnel MTU to 1476 and clamp TCP MSS to 1436 for IPv4. Verify with DF-bit pings through the tunnel, and adjust if other encapsulation is in the path.

Start a 15-day free trial of NixMon. No credit card required.Learn more