Active, passive, and timers

Two meanings of one word: in RFC 4271 the Active state means the router is waiting to accept a TCP connection, not that the session is up. BGP runs over TCP port 179, so one router has to call. A neighbour with no mode set both calls and answers; transport connection-mode passive makes it only answer. Keepalive and hold timers decide how long each end waits for the other.

In Daveth Pro (Network)5 min video · lab: BGP peering and paths

By , founder of Daveth · Updated

Opening frame of the video walkthrough of Active, passive, and timers

Watch this lesson

5 min · Video walkthrough

In Daveth Pro (Network)

The full 5 min walkthrough is in Daveth Pro (Network). See what the plan opens

Upcoming practical lab

Lab C7: BGP peering and paths

What the lab covers

What this page answers

What does the BGP Active state mean?

That BGP is trying to acquire a peer by listening for, and accepting, a TCP connection. It is not up: a session exchanges routes only once it is Established. Read it in “A word that means two things”

What does neighbor transport connection-mode passive do?

It makes the router only accept the TCP connection on port 179, never open it. A neighbour with no mode set both calls and answers, so at least one end must be able to call. Read it in “Somebody has to call”

Three protocols, one question

A container port's edge router, PORT-R1, runs BGP with two carriers. CARRIER-A is on direct fibre. CARRIER-B is on a carrier Ethernet service, with the carrier's switch CE-SW in the middle. Which router starts each session, and how long does each wait before giving up on the other?

Plain words first. A BGP session is the conversation two routers hold to swap routes. A peer is the router at the other end. A keepalive is the small message a router sends to show it is still there, and the hold time is how long a router waits without hearing anything before it declares the peer dead.

This course has asked the timer question twice already. EIGRP (1.3.a) said each switch announces its own hold time and its neighbor simply records it. OSPF (1.4.a) said the hello and dead intervals must match or the two routers never become neighbors. Which of those do you expect BGP to do? Neither, as it turns out.

A word that means two things

Before the answer, one trap. RFC 4271, which defines BGP, names the states a session passes through. Here are two of them, Active and then Connect:

In this state, BGP FSM is trying to acquire a peer by listening for, and accepting, a TCP connection. In this state, BGP FSM is waiting for the TCP connection to be completed.

Notice what Active is not: up. A session is only exchanging routes once it is Established. Active means this router is waiting to accept a connection. Now the setting this lesson is about:

neighbor {ip-address | peer-group-name} transport {connection-mode {active | passive} | path-mtu-discovery [disable] | multi-session | single-session} Specifies an active connection. Specifies a passive connection.

And the RFC's own passive option, with what a passive start does:

This option indicates that the BGP FSM will passively wait for the remote BGP peer to establish the BGP TCP connection. In response to a ManualStart_with_PassiveTcpEstablishment event (Event 4) or AutomaticStart_with_PassiveTcpEstablishment event (Event 5), the local system: - initializes all BGP resources, - sets the ConnectRetryCounter to zero, - starts the ConnectRetryTimer with the initial value, - listens for a connection that may be initiated by the remote peer, and - changes its state to Active.

Read the last line of that list. A router told to wait passively goes into the state called Active. Naming things is hard, and BGP managed it twice in one word. In a state column, Active means not up yet. In a transport command, active is a choice about who calls.

Somebody has to call

BGP uses the Transmission Control Protocol (TCP) as its transport protocol (specifically port 179).

A TCP connection has a caller and an answerer, so before any routes move, one router has to open it.

By this course's reading, Cisco's connection-mode passive is the RFC's passive option, and a neighbor with no mode set both calls and answers. The command reference's passive example:

From elsewhere: the passive connection example. The names, numbers and addresses come from elsewhere, not from this scenario.

 neighbor 192.168.1.2 transport connection-mode passive

CARRIER-A sets every customer session passive; nobody has set a mode on the CARRIER-B session.

Configuration: PORT-R1, in the forms these commands take.

PORT-R1# configure terminal
PORT-R1(config)# router bgp 65010
PORT-R1(config-router)# neighbor 198.51.100.1 remote-as 64500
PORT-R1(config-router)# neighbor 203.0.113.1 remote-as 64510
PORT-R1(config-router)# end

Configuration: CARRIER-A, toward the port, in the forms these commands take.

CARRIER-A# configure terminal
CARRIER-A(config)# router bgp 64500
CARRIER-A(config-router)# neighbor 198.51.100.2 remote-as 65010
CARRIER-A(config-router)# neighbor 198.51.100.2 transport connection-mode passive
CARRIER-A(config-router)# end

Computed from the state, who calls on the CARRIER-A session. No command prints it in this form.

router     mode     opens the connection
PORT-R1    not set  yes
CARRIER-A  passive  no, waits

connection: PORT-R1's

Read the connection line: PORT-R1's. CARRIER-A waits, PORT-R1 calls. What happens toward CARRIER-B, where both ends call?

In the event of connection collision, one of the connections MUST be closed. The convention is to compare the BGP Identifiers of the peers involved in the collision and to retain only the connection initiated by the BGP speaker with the higher-valued BGP Identifier.

Computed from the state, who calls on the CARRIER-B session. No command prints it in this form.

router     mode     opens the connection
PORT-R1    not set  yes
CARRIER-B  not set  yes

connection: both called; kept CARRIER-B's (higher BGP identifier)

Look at the identifiers: CARRIER-B's 192.0.2.2 is higher than PORT-R1's 10.255.0.1, so CARRIER-B's connection is the one kept. Both calling is fine; the RFC settles it.

The security team's change

The port's security team wants the port never to open connections outward. They set PORT-R1 passive toward CARRIER-A, and the session is cleared to apply it.

Configuration: the security change on PORT-R1, typed alone, in the forms these commands take.

PORT-R1# configure terminal
PORT-R1(config)# router bgp 65010
PORT-R1(config-router)# neighbor 198.51.100.1 transport connection-mode passive
PORT-R1(config-router)# end

Before you read on, decide what the CARRIER-A session does now.

Computed from the state, who calls on the CARRIER-A session now. No command prints it in this form.

router     mode     opens the connection
PORT-R1    passive  no, waits
CARRIER-A  passive  no, waits

connection: none, nobody calls

Read the mode column: passive, passive. Nobody calls, so no connection exists for the identifier rule to choose between. Both configurations are correct on their own; the problem only exists in the pair.

Computed from the state: the state each end waits in. No command prints it in this form.

router     RFC 4271 state
PORT-R1    Active
CARRIER-A  Active

By this course's reading of the RFC, both ends sit in Active indefinitely: each started passively, and each is listening for a connection the other will never open.

So where would you look first? The 17.9 guide lists show ip bgp summary for this:

Displays the status of all BGP connections.

Proves: show ip bgp summary proves whether each session is established, which is the question to ask first. Does not prove: why a session is down. Two passive ends, a refused hold time and a missing route all leave a session that isn't established, so the next thing to read is both routers' configuration.

The fix is on one end. The team sets PORT-R1 back to calling, which still leaves CARRIER-A waiting:

Configuration: PORT-R1 set active toward CARRIER-A, typed alone, in the forms these commands take.

PORT-R1# configure terminal
PORT-R1(config)# router bgp 65010
PORT-R1(config-router)# neighbor 198.51.100.1 transport connection-mode active
PORT-R1(config-router)# end

Computed from the state, who calls on the CARRIER-A session after the fix. No command prints it in this form.

router     mode     opens the connection
PORT-R1    active   yes
CARRIER-A  passive  no, waits

connection: PORT-R1's