BGP Neighbor Adjacency States
Read the session state before changing the configuration. Each state tells you how far TCP and the BGP handshake have progressed.
The six states
Idle
The session is not running. A start event prepares its resources and connection retry timer. Administrative shutdown can keep a neighbor here; Idle by itself does not identify the cause.
Connect
BGP is waiting for a TCP connection. Success normally leads to OpenSent. A retry timer can restart the attempt. In the base RFC state machine, TCP failure returns to Idle unless optional DelayOpen behavior selects Active.
Active
The speaker is trying to obtain a TCP connection and listening for an incoming one. A successful connection normally leads to OpenSent; retry expiry leads back to Connect. Active does not mean the BGP session is working.
OpenSent
TCP is available and the local OPEN has been sent. The received OPEN must pass version, peer-AS and other checks. A valid OPEN leads to OpenConfirm; TCP failure here leads to Active. An OPEN error resets the session.
OpenConfirm
The OPEN exchange has succeeded. BGP waits for the peer’s KEEPALIVE. Receiving it completes establishment; a hold expiry, notification or TCP failure resets the session.
Established
The session can exchange UPDATEs. Valid KEEPALIVEs and UPDATEs refresh a nonzero hold timer. A TCP loss or hold expiry returns this session to Idle and removes its ordinary learned paths; graceful-restart retention is a separate feature.
State transition diagram
- Solid green: normal progress.
- Amber dash-dot: retry or transport loss.
- Gray dashed: reset to Idle.
- Curved loop: handle an event without changing state.
- Green state: Established, where routes can be exchanged.
- Amber state: Active, still acquiring a connection.
Configure the peers
Use two directly connected routers, with no originated prefixes. Both sides explicitly use 30-second keepalives and a 90-second proposed hold time.
Complete baseline configurations
R1
hostname R1
ip cef
interface Loopback0
ip address 10.255.0.1 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.1 255.255.255.252
no shutdown
exit
router bgp 65010
bgp router-id 10.255.0.1
bgp log-neighbor-changes
timers bgp 30 90
no bgp default ipv4-unicast
neighbor 192.0.2.2 remote-as 65020
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.2 activate
exit-address-family
endR2
hostname R2
ip cef
interface Loopback0
ip address 10.255.0.2 255.255.255.255
exit
interface GigabitEthernet1
ip address 192.0.2.2 255.255.255.252
no shutdown
exit
router bgp 65020
bgp router-id 10.255.0.2
bgp log-neighbor-changes
timers bgp 30 90
no bgp default ipv4-unicast
neighbor 192.0.2.1 remote-as 65010
address-family ipv4 unicast
no auto-summary
neighbor 192.0.2.1 activate
exit-address-family
endObserve the session
R1# show ip bgp neighbors 192.0.2.2 | include BGP state|hold time
BGP state = Established, up for 00:02:00
Last read 00:00:10, last write 00:00:10, hold time is 90, keepalive interval is 30 secondsR1# show ip bgp summary
BGP router identifier 10.255.0.1, local AS number 65010
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.0.2.2 4 65020 12 12 1 0 0 00:02:00 0A number in State/PfxRcd means Established in this summary format. Zero means no accepted prefixes, not a failed handshake. Connect, OpenSent and OpenConfirm can pass too quickly to catch in a single poll.
Short lab-only debug example
R1# debug ip bgp
BGP debugging is on for address family: IPv4 Unicast
BGP: 192.0.2.2 went from Connect to OpenSent
BGP: 192.0.2.2 went from OpenSent to OpenConfirm
BGP: 192.0.2.2 went from OpenConfirm to Established
R1# undebug all
All possible debugging has been turned offThe excerpt illustrates transitions; it does not imply that a debug command itself resets or establishes the session. Keep debugging brief in a lab.
Follow a reset
In this lab, disabling R2’s physical interface breaks the live TCP session.
interface GigabitEthernet1
shutdownR1# show ip bgp summary
BGP router identifier 10.255.0.1, local AS number 65010
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.0.2.2 4 65020 0 0 1 0 0 never ActiveImmediately after detecting the failure, an Established session returns to Idle. An automatic restart can already have moved it into Connect or Active by the time the summary is read. Diagnose the last reset reason as well as the current state.
R1# show ip bgp neighbors 192.0.2.2 | include Last reset
Last reset 00:00:12, due to Interface flapRestore R2’s interface, then verify that the handshake completes again.
interface GigabitEthernet1
no shutdownR1# show ip bgp summary
BGP router identifier 10.255.0.1, local AS number 65010
Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/PfxRcd
192.0.2.2 4 65020 12 12 1 0 0 00:02:00 0Key Takeaways
- Idle, Connect, Active, OpenSent, OpenConfirm and Established describe different session stages.
- Active means a connection is still being sought; it does not mean the BGP session is operational.
- A valid OPEN leads to OpenConfirm; receiving KEEPALIVE there leads to Established.
- TCP failure in OpenSent returns to Active; TCP failure in Established resets the session to Idle before a restart.
- A numeric State/PfxRcd value indicates an Established session in the example summary output, even when that number is zero.
Protocol and command references
BGP protocol and finite state machine · Router-symbol attribution.