BGP TCP Ports – Why BGP Uses TCP 1027 Instead of 179

bgpciscorouter

Why is the BGP foreign address port 1027?

I use BGP to connect Router1 and Router2, but when I show the TCP progress:

Router1>show tcp brief 
TCB       Local Address           Foreign Address        (state)
4E976890  10.0.0.1.179           10.0.0.2.1027         ESTABLISHED

We say the BGP is based on TCP port 179. Why is Router2's BGP on port 1027?

Best Answer

One side of the connection will have an arbitrary port number, the other will be on 179.

Cisco Press "BGP Fundamentals" has a good explanation (link)

the neighbor with the higher IP address manages the connection. The router initiating the request uses a dynamic source port, but the destination port is always 179.

Example 1-1 shows an established BGP session using the command show tcp brief to display the active TCP sessions between routers. Notice that the TCP source port is 179 and the destination port is 59884 on R1, and the ports are opposite on R2.

Example 1-1: Established BGP session

RP/0/0/CPU0:R1# show tcp brief | exc "LISTEN|CLOSED"
   PCB     VRF-ID     Recv-Q Send-Q Local Address    Foreign Address      State
0x088bcbb8 0x60000000      0      0  10.1.12.1:179    10.1.12.2:59884     ESTAB

R2# show tcp brief
TCB       Local Address               Foreign Address             (state)
EF153B88  10.1.12.2. 59884            10.1.12.1.179               ESTAB

This is just the same as any other TCP connection: the passive open side sits and waits on a well-known port number; the active open side uses an arbitary port. This makes it much easier to manage many-to-many TCP links.

Related Topic