≡ Menu

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.

R1#sh run | s bgp
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#
R2#sh run | s bgp
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…

R1#sh ip bgp neighbors 10.0.0.2 | i host|state
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#
R2#sh ip bgp neighbors 10.0.0.1 | i host|state
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…

R1#sh ip bgp neighbors 10.0.0.2 | i host|state
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#
R2#sh ip bgp neighbors 10.0.0.1 | i host|state
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.

R1#conf t
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)#
R2#conf t
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.

R1#sh ip bgp neighbors 10.0.0.2 | i host|state
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#
R2#sh ip bgp neighbors 10.0.0.1 | i host|state
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 on this entry are closed.

  • Anonymous

    Thanks,
    My curiosity on this is satisfied 🙂

  • CCIE 4729 ret.

    This command is not new to me….but is funny how you forget. Excellent thanks for reminding me…

    • You’re most welcome. It is used on extreme cases but still a handy command…

  • RSG

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

    RFC 4271

    ….
    There exists a period in which the identity of the peer on the other
    end of an incoming connection is known, but the BGP identifier is not
    known. During this time, both an incoming and outgoing connection
    may exist for the same configured peering. This is referred to as a
    connection collision (see Section 6.8).

Next post:

Previous post:

Copyright © Nish Vamadevan 2002-2017. All Rights Reserved. Terms and Policies.