Skip to content

Fine-tuning BGP Client Server Relationship

Before you read through this post, I assume you have got at least the basic understanding of BGP and how it works.

Here are some facts…

BGP is a path vector Routing Protocol works on TCP port 179.

Neighbor with the lowers IP address will establish the connection to the Remote Peer on TCP port 179 with a random source port.

In this case, the Remote Peer will become the Server and the Local Peer will become the client. This peering relationship will change when we clear the BGP process on either peer or the underlying BGP connection get severed for any reason.

In case you want to specifically want to set one Peer as the Server and one as the Client, the IOS does support it.

This is how it is done…

R1 and R2 have a eBGP peering where R1 is on AS 100 and R2 is on 200.

router bgp 100
no synchronization
bgp router-id 1.1.1.1
bgp log-neighbor-changes
redistribute connected
neighbor 10.0.0.2 remote-as 200
no auto-summary
R1#
router bgp 200
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
redistribute connected
neighbor 10.0.0.1 remote-as 100
no auto-summary
R2#

If you are wondering, I am redistributing the connected routes because I want to make sure the BGP is in-fact exchanging prefixed.

As you can see below, here are the BGP connection info…

BGP state = Established, up for 01:27:40
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Local host: 10.0.0.1, Local port: 46257
Foreign host: 10.0.0.2, Foreign port: 179
R1#
BGP state = Established, up for 01:28:07
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Local host: 10.0.0.2, Local port: 179
Foreign host: 10.0.0.1, Foreign port: 46257
R2#

As you can see above, R1 is the Client and R2 is the Server with the Local port 179

Below you can see that I have cleared the BGP session, and the peering arrangement is changed from R1 being the Client to Server…

BGP state = Established, up for 00:00:31
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Local host: 10.0.0.1, Local port: 179
Foreign host: 10.0.0.2, Foreign port: 62021
R1#
BGP state = Established, up for 00:00:06
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Local host: 10.0.0.2, Local port: 62021
Foreign host: 10.0.0.1, Foreign port: 179
R2#

In case, you want to hard-code one Peer as Client and another Peer as Server. This is possible under the Cisco IOS. I have never seen such configuration on Production Environment but this will come in handy when we have some kind of firewalling on one side of the peer or we want to specifically set which neighbor becomes the Server and which becomes the Client.

This is accomplished under the neighbor statement and I will be configuring R1 as Server and R2 as the Client.

The below command states…

Active being the Client
Passive being the Server.

Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#router bgp 100
R1(config-router)#neighbor 10.0.0.2 transport connection-mode ?
active   Actively establish the TCP session
passive  Passively establish the TCP session

R1(config-router)#neighbor 10.0.0.2 transport connection-mode passive
R1(config-router)#
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#router bgp 200
R2(config-router)#neighbor 10.0.0.1 transport connection-mode ?
active   Actively establish the TCP session
passive  Passively establish the TCP session

R2(config-router)#neighbor 10.0.0.1 transport connection-mode active
R2(config-router)#

Now I have Cleared the BGP session numerous times and as you can see below, the Client / Server relationship is not changed.

BGP state = Established, up for 00:02:24
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Local host: 10.0.0.1, Local port: 179
Foreign host: 10.0.0.2, Foreign port: 14953
R1#
BGP state = Established, up for 00:01:22
Connection state is ESTAB, I/O status: 1, unread input bytes: 0
Local host: 10.0.0.2, Local port: 14953
Foreign host: 10.0.0.1, Foreign port: 179
R2#
comments powered by Disqus