Course contents

Module 1: BGP FoundationsLesson 1.2 (2 of 3 in this module)2 of 43 in the BGP course

BGP sessions, messages and neighbour states

Your neighbour says Active, but no routes arrive. Does Active mean the connection is working? Let's check the session before we change any route policy.

Advanced · 13 min read

You'll learn to describe how a BGP session forms over TCP, name the BGP message types and timers, read the neighbour state in show ip bgp summary, and say what each state means for troubleshooting.

Why does Active mean no routes yet?

R1 has been configured to peer with ISP A at 192.0.2.1, but no routes arrive. Where a number of received prefixes should be, show ip bgp summary says Active. It sounds healthy, but it means R1 has not established the BGP conversation and is waiting for a TCP connection. A brief Active state can be part of startup; a persistent one calls for investigation. The state alone does not identify the fault. It starts with how a session forms.

A BGP session is the conversation used by two routing processes to exchange route information. A neighbour, also called a peer, is the router at the other end. Established means that conversation is ready to exchange routes. It does not mean that a user's application is reachable.

We use one Ethernet link: R1 Gi0/0 is 192.0.2.2/30 in AS 64500; ISP A's interface is 192.0.2.1/30 in AS 64501. R1's BGP router ID is 1.1.1.1. The neighbour address is an interface IP, not a website URL, an AS number or the router ID. The /30 is the subnet prefix length. Both routers have a connected route to this link.

How a session forms

In this lab, each router is configured with the neighbour's IP address and AS number, the identifier of its routing domain. It opens a TCP connection to destination port 179. The initiating side normally uses a temporary source port; not every packet has both ports set to 179. TCP provides reliable, ordered delivery. BGP sends the eligible initial routes, then normally sends changes rather than periodically repeating a complete table. Route refresh or reconnection can cause routes to be sent again.

The routers next exchange OPEN messages to identify themselves and negotiate supported features. A KEEPALIVE confirms that the OPEN was accepted. Once the session is Established, an UPDATE can announce a prefix or withdraw a previously announced path. A withdrawal tells the receiver to stop using that path; it does not physically shut down the destination network.

Step 1 of 6 · TCP handshake
R1 Gi0/0 to ISP A · 192.0.2.0/30
R1
AS 64500, 192.0.2.2
ISP A
AS 64501, 192.0.2.1

1. TCP handshake · SYN, SYN-ACK, ACK · TCP → 179

R1 opens a TCP connection to port 179 on 192.0.2.1. Until it completes, the neighbour is in Connect (or Active after a failed try).

Device key: R1, ISP A (router)

Arrows run from each message's sender to its receiver. Rows show message order, not separate cables or elapsed time to scale. Port numbers identify services or conversations, not physical switch sockets.

Reading the addresses

IP labels identify interfaces or destinations. Subnet labels identify networks; /n is the prefix length. A router ID (RID) identifies a routing process and need not be a reachable interface.

An IP address alone is not a URL. A web URL includes a scheme such as https://; an address on a router or printer does not imply a website.

  • R1: AS 64500, 192.0.2.2
  • ISP A: AS 64501, 192.0.2.1
Figure 1. From TCP setup to the first route announcement. These arrows carry routing information; ordinary user traffic is separate. Cisco IOS commonly uses a 60-second keepalive interval.

First prove that the session is Established; then check which routes it actually exchanges.

The five message types

BGP keeps its protocol small. Five message types cover everything a session needs, and only one of them carries routes. Knowing which message does what tells you which counter or log line to look at when something fails.

Five message types, one job each
Five message types, one job eachOPEN starts a session, KEEPALIVE keeps it alive, UPDATE carries routes, NOTIFICATION reports an error and closes it, ROUTE-REFRESH asks for routes again.OPENSent once at startVersion, AS, holdtime, router ID,capabilitiesKEEPALIVEConfirms the OPENthen repeats whilenothing else issentUPDATENew paths withattributes, andwithdrawn paths(all route data)NOTIFICATIONAn error code,then the sessionclosesROUTE-REFRESHAsks for permittedroutes again,no reset needed(RFC 2918)Typical order in a session: OPEN, KEEPALIVE, UPDATE (many), with NOTIFICATION only on error

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Only UPDATE carries routes. The other four manage the session itself.
The five message types
The five message typesMessage; What it carries. OPEN: Version, AS number, hold time, router ID and capabilities; sent once at the start UPDATE: New routes with their attributes, and withdrawn routes KEEPALIVE: Nothing but "still here"; resets the neighbour's hold timer NOTIFICATION: An error code, then the session closes (hold timer expired, bad peer AS, administrative shutdown and others) ROUTE-REFRESH: When supported by both peers, requests the permitted routes again for an address family, for example after an inbound-policy change (RFC 2918)MessageWhat it carriesOPENVersion, AS number, hold time, router ID and capabilities; sent once atthe startUPDATENew routes with their attributes, and withdrawn routesKEEPALIVENothing but "still here"; resets the neighbour's hold timerNOTIFICATIONAn error code, then the session closes (hold timer expired, bad peer AS,administrative shutdown and others)ROUTE-REFRESHWhen supported by both peers, requests the permitted routes again for anaddress family, for example after an inbound-policy change (RFC 2918)

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Each item on the left, with what it means on the right.

Keepalive and hold timers

Keepalives reset the hold timer; silence runs it out
Keepalives reset the hold timer; silence runs it outKeepalives arrive at 0, 60 and 120 seconds. Then the neighbour goes silent. The 180 second hold timer started at the last message expires at 300 seconds and the session closes.KEEPALIVE0 sKEEPALIVE60 sKEEPALIVE120 sNo message received: hold timer counts down (180 s)Hold expires, NOTIFICATION300 sBoth routers use the lower hold time offered in the two OPEN messages

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Each received KEEPALIVE or UPDATE restarts the hold timer. If it reaches zero, the router sends a hold timer expired NOTIFICATION and closes the session. Keepalive is commonly one third of the hold time.

Each router expects a qualifying message from its neighbour within the hold time. In Established state, receiving an UPDATE or KEEPALIVE restarts this timer. A NOTIFICATION instead reports an error and closes the session. On Cisco IOS the usual defaults are a keepalive every 60 seconds and a hold time of 180 seconds. The two routers offer their hold times in the OPEN and both use the lower one, so the timers do not have to match for the session to come up. A negotiated hold time of zero disables the hold timer and periodic keepalives; nonzero hold times must be at least three seconds.

When the hold time runs out, the router sends a NOTIFICATION (hold timer expired), closes the session and removes paths learned through it in ordinary operation. A directly detected interface failure can bring the session down before this timer expires. Shorter timers detect silent failures sooner, but leave less room for delayed messages or an overloaded router. Agree changes with the peer rather than reducing timers on every neighbour as a first troubleshooting step.

router bgp 64500 neighbor 192.0.2.1 timers 10 30

Keepalive 10 s and hold time 30 s for this neighbour. The new values are used the next time the session is established.

Neighbour states, from Idle to Established

A neighbour moves through a fixed set of states. Reading them in order shows how far a session got, and therefore which layer to inspect. TCP trouble keeps the neighbour in Connect or Active. Trouble in the OPEN exchange sends it back to Idle with a NOTIFICATION. Only Established carries routes.

Neighbour states from Idle to Established
Neighbour states from Idle to EstablishedThe normal path is Idle, Connect, OpenSent, OpenConfirm, Established. A failed TCP attempt moves Connect to Active and back. Any error returns the session to Idle.IdleNot trying,or waitingConnectTCP inprogressActiveRetrying,listeningOpenSentOPEN sent,awaiting OPENOpenConfirmAwaitingKEEPALIVEEstablishedExchangeUPDATEsTCP fails: retry timerAny error, NOTIFICATION or hold timer expiry returns the session to Idle

On small screens, swipe sideways or focus the diagram and use the arrow keys.

A session that sits in Connect or Active has not completed TCP. A numeric prefix count in show ip bgp summary means Established.
Neighbour states, from Idle to Established
Neighbour states, from Idle to EstablishedState; What is happening; What it usually means when it is stuck. Idle: Not trying yet, or waiting after an error Shut down (shown as Idle (Admin)), no route to the neighbour, or just reset after an error Connect: Waiting for the TCP connection to complete Normally passes in a moment Active: Listening for a peer TCP connection; retries can return to Connect If persistent, check the address, route, TCP 179 permissions and peer configuration. A snapshot does not prove which check failed. OpenSent: OPEN sent, waiting for the neighbour's OPEN Rarely stuck; if the OPEN is rejected, back to Idle OpenConfirm: OPENs exchanged, waiting for a KEEPALIVE Rarely stuck Established: Ready to exchange UPDATEs Connection is up; advertised routes and forwarding still need separate checksStateWhat is happeningWhat it usually means when it isstuckIdleNot trying yet, or waiting after anerrorShut down (shown as Idle (Admin)), noroute to the neighbour, or just resetafter an errorConnectWaiting for the TCP connection tocompleteNormally passes in a momentActiveListening for a peer TCP connection;retries can return to ConnectIf persistent, check the address,route, TCP 179 permissions and peerconfiguration. A snapshot does notprove which check failed.OpenSentOPEN sent, waiting for theneighbour's OPENRarely stuck; if the OPEN isrejected, back to IdleOpenConfirmOPENs exchanged, waiting for aKEEPALIVERarely stuckEstablishedReady to exchange UPDATEsConnection is up; advertised routesand forwarding still need separatechecks

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Read each row across: the left box names the item, the others describe it.

Reading show ip bgp summary

One command shows every neighbour on one line. Learn to read the last column first, because it tells you whether the session is up before you look at anything else.

Reading one line of show ip bgp summary
Reading one line of show ip bgp summaryFive columns matter most: neighbour address, AS, message counters, up or down time and the state or prefix count. A number in the last column means Established; a word means it is not.Neighbor192.0.2.1AS64501MsgRcvd / MsgSent31 / 29Up/Down00:21:52State/PfxRcd1Number (0, 1, 250...)Established; count of accepted prefixes0 is healthy but emptyIdle, Connect, Active, OpenSentNot Established: check TCP, address,remote-as and the last reset reasonMsgRcvd and MsgSent at 0 with Up/Down never: nothing has ever been exchangedUp/Down is the time in the current state, so a low value means a recent change

On small screens, swipe sideways or focus the diagram and use the arrow keys.

The last column does two jobs. A number is a prefix count for an Established session. A state name means the session is not up.
Example output
R1#show ip bgp summary
BGP router identifier 1.1.1.1, local AS number 64500
BGP table version is 5, main routing table version 5
...
Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
10.255.0.2      4        64500      28      30        5    0    0 00:21:40        1
192.0.2.1       4        64501      31      29        5    0    0 00:21:52        1
A number in the last column means the session is Established, and the number is how many accepted prefixes from that neighbour for this address family. Here R1 also has an existing iBGP neighbour, R2 at Loopback0 10.255.0.2 in the same AS. Its loopback is reached through the company network, not the provider /30 shown above. Both neighbours supply one accepted prefix. Up/Down is how long the session has been in its current state.
Example output
R1#show ip bgp summary | begin Neighbor
Neighbor        V           AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
192.0.2.1       4        64501       0       0        1    0    0 never    Active
The situation from the start of the lesson. Active, zero messages and never up: this peer has not reached Established in the displayed record. The zero message counters are another clue to check the connection first: ping 192.0.2.1, the interface and route, then any access control list (ACL) or firewall on the path for TCP 179. A successful ping tests ICMP, not TCP, so it cannot prove that BGP is permitted.
Example output
R1#show ip bgp neighbors 192.0.2.1 | include BGP state
  BGP state = Established, up for 00:21:52
The same information for one neighbour. The full show ip bgp neighbors output also lists the negotiated hold time, the capabilities and the last error, which is where a rejected OPEN shows up.

The router ID

How a Cisco router picks the BGP router ID
How a Cisco router picks the BGP router IDThe router uses bgp router-id if set, otherwise the highest loopback IPv4 address, otherwise the highest active interface IPv4 address.1 bgp router-id set?Used as configuredR1: 1.1.1.1if not set2 Loopback addressHighest IPv4 on a loopbackR1: Loopback0 10.255.0.1if not set3 Interface addressHighest IPv4 on an active interfaceR1: Gi0/0 192.0.2.2Where it is usedIdentifies the routerin OPENA late tie-breakerin best-path selectionMust be unique in the AS

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Set it by hand so the ID does not change when interfaces change. A change resets the router's BGP sessions.

Each BGP router has a 32-bit router ID (BGP identifier). With the conventional Cisco IOS IPv4 selection rules, it uses the bgp router-id command if set, otherwise the highest IPv4 address on a loopback, otherwise the highest IPv4 address on an active interface. Keep IDs unique within the AS, including iBGP neighbours. It breaks ties late in best-path selection. Setting it by hand keeps it stable when interfaces change.

router bgp 64500 bgp router-id 1.1.1.1

Changing the router ID resets the router's BGP sessions, so set it when the router is built.

Where sessions usually fail

From the neighbour state to the first check
From the neighbour state to the first checkStart from show ip bgp summary. A stuck Active or Connect means check route, TCP 179 and addresses. Repeated resets mean read the NOTIFICATION reason. Established with zero prefixes means check address family, origination and policy.show ip bgp summaryStuck in Connect or ActiveRoute to the neighbour?TCP 179 permitted?Neighbour IP correct?Peer configured at all?Resets every few secondsshow loggingLast reset reasonBad Peer AS: compareremote-as with local ASEstablished, 0 prefixesAddress family activated?Peer originating anything?Inbound policy dropping?Not a transport problem

On small screens, swipe sideways or focus the diagram and use the arrow keys.

Match the state to the layer: transport first, then the OPEN, then routes and policy.
  • Persistent Active or Connect: investigate TCP establishment. Check the neighbour address, route, peer configuration and TCP 179 permissions; the state alone cannot identify a blocked port.
  • Repeated resets: read the last reset reason and logs. A Bad Peer AS NOTIFICATION points to an unacceptable AS in an OPEN; compare each remote-as with the opposite router's local AS. An Idle/Active cycle alone does not prove an AS mismatch.
  • eBGP to a loopback address: by default Cisco IOS only starts an eBGP session to an address on a directly connected subnet, and sends its packets with a TTL of 1. Peering with a loopback needs an extra command, covered in the eBGP multihop lesson.
  • Established, but 0 prefixes: the session is ready, but zero may be intentional, as in the lab below. If routes are expected, check address-family activation, origination and policy before changing TCP settings.

Use show ip bgp neighbors 192.0.2.1 and show logging to connect a state change to its cause. A Bad Peer AS error means an OPEN was processed on that connection, so TCP had worked at that point. It does not prove the path is still working now. Observe the recovery after correcting the confirmed cause; avoid repeatedly resetting a peer just to see whether its state changes.

Build and check a two-router session

Use a Cisco IOS or IOS XE IPv4-unicast lab. Configure and enable the two Ethernet interfaces with the /30 addresses above first. The following commands start in global configuration mode and create an eBGP session only; they do not originate a prefix. Release-specific address-family commands may be required on your chosen image.

router bgp 64500 bgp router-id 1.1.1.1 neighbor 192.0.2.1 remote-as 64501

R1: start BGP for local AS 64500, set its identifier and identify ISP A as an external neighbour in AS 64501.

router bgp 64501 bgp router-id 2.2.2.2 neighbor 192.0.2.2 remote-as 64500

ISP A: configure the opposite endpoint and R1's AS. Each remote-as must match the other router's local AS, not its router ID.

  1. Run show ip interface brief and ping 192.0.2.1 on R1. Confirm the intended link is up and the directly connected neighbour replies.
  2. Run show ip bgp summary. With no originated routes, expect a numeric 0 after establishment. That is the intended result at this stage.
  3. Run show ip bgp neighbors 192.0.2.1. Find the BGP state, remote AS, negotiated hold time and any last reset reason. If the session fails, use those clues before changing configuration.

For a failure exercise, shut the lab ISP interface, observe the state change, then restore it with no shutdown. Direct link-down detection may act before the hold timer. Do not expect this exercise to demonstrate a full 180-second timeout.

Technical references: RFC 4271, route refresh, RFC 2918, graceful restart, RFC 4724 and Cisco's BGP troubleshooting guide. These commands and outputs are written examples, not captures from a tested router image.

Test yourself on BGP sessions

Predict · scenario 1

show ip bgp summary shows a neighbour in the Active state. What does that tell you?

Predict · scenario 2

R1 offers a hold time of 180 seconds and ISP A offers 90. What hold time does the session use?

Predict · scenario 3

Which message would R1 send to ask ISP A to resend all its routes after an inbound filter changes?

Predict · scenario 4

The session to ISP A resets every few seconds. The log shows a NOTIFICATION about the peer's AS. What is the most likely cause?

FAQ

Does BGP discover its neighbours like OSPF does?
Ordinary BGP uses configured unicast neighbours rather than OSPF-style multicast Hellos. This lab configures each address with neighbor ... remote-as. Some platforms also support dynamic peers within explicitly configured ranges; that is not automatic OSPF-style discovery.
Which router opens the TCP connection?
Either router can initiate TCP, and both may try at once. BGP has collision-detection rules to retain one suitable connection. In the usual simultaneous-start case, the router IDs help decide which connection survives; this does not mean the router with the lower ID cannot initiate a session.
What happens to the routes when a session goes down?
In ordinary operation, the router removes paths learned through that session and selects alternatives. Negotiated graceful restart can retain stale paths temporarily during certain restarts, so immediate removal is not universal. On reconnection, peers exchange routes permitted by their address-family settings and export policies, not every route in their routing tables.