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 redistribution the connected routes because I want to make sure the BGP is in-fact exchanging prefixed. (I don’t fully trust Dynamips when it comes to emulation…
)
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 (As you can see, the Local port is 179)
As you can see below, 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. On the command itself, Active being the Client and 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#