Back to Blog


How To Configure BGP
Detective looking through files. Josh Lee - Routed Bytes
May 23rd, 2026
Short Description: Learn some more advanced BGP topics, and how to configure BGP on a Cisco router.

BGP, which stands for Border Gateway Protocol, is one of the most important routing protocols in networking and is responsible for helping the internet function every single day. Unlike interior routing protocols that operate inside a single network, BGP is designed to exchange routing information between completely different organizations and autonomous systems. Internet providers, cloud companies, and large enterprises all rely on BGP to advertise routes and determine the best path for traffic across the internet. If you’ve ever wondered how your traffic reaches a website hosted thousands of miles away, there’s a very good chance BGP played a major role in getting it there.

BGP helps introduce engineers to how routing decisions are made at internet scale. BGP is considered a path vector routing protocol and requires neighbors to be manually configured before routers can exchange information. It establishes a TCP session between routers using TCP port 179, which allows reliable two-way communication between peers. BGP advertisements contain address prefixes and prefix lengths, commonly referred to as NLRI, or Network Layer Reachability Information. Routers can even advertise routes they want removed from routing tables, which helps networks dynamically adjust to outages or topology changes.

Another major concept in BGP is path selection. BGP uses a collection of path attributes to determine the best route to a destination. Here are some of the most important attributes worth remembering:

  • Weight — Cisco-specific and locally significant. Higher values are preferred and often influence outbound routing.
  • Local Preference — Shared throughout an autonomous system, where higher values are preferred.
  • Originate — Routes injected locally are preferred over externally learned routes.
  • AS Path Length — Shorter AS paths are preferred because traffic passes through fewer autonomous systems.
  • Origin Type — Indicates how a route entered BGP. Internal routes are preferred over redistributed routes.
  • MED (Multi-Exit Discriminator) — Used to influence inbound routing decisions between autonomous systems. Lower values are preferred.
  • eBGP vs iBGP — External BGP routes are preferred over internal BGP routes.
  • Router ID — When all else ties, the lowest router ID is preferred.

One thing that makes BGP unique is that the actual configuration is surprisingly simple compared to how powerful the protocol is. In many cases, you only need a few commands to bring up a basic BGP relationship. The first step is entering BGP configuration mode with your autonomous system number. From there, you define your neighbor and specify the remote AS number you want to peer with. After that, you advertise the networks you want shared with other routers and optionally define a router ID for easier identification.

For example, a simple configuration starts by entering:

Cisco IOS
                              R1(config)#router bgp 64500
                        

Then you define the neighbor relationship:

Cisco IOS
                              R1(config-router)#neighbor 192.168.1.2 remote-as 64495
                        

After the BGP session is established, you can advertise routes into BGP:

Cisco IOS
                              R1(config-router)#network 192.0.2.0 mask 255.255.255.0
                        

Finally, it’s a good idea to define a router ID:

Cisco IOS
                              R1(config-router)#bgp router-id 192.168.1.1
                        

BGP configuration without values:

Cisco IOS
                              R1#conf t
                              R1(config)#router bgp [AS NUM]
                              R1(config-router)#neighbor [PEER] remote-as [REMOTE AS NUM]
                              R1(config-router)#network [SUBNET] mask [SUBNET MASK]
                              R1(config-router)#bgp router-id [IP]
                        

BGP Config Walk Through

Here is an example of 2 routers with the BGP configuration.

Router 1:

Cisco IOS
                              R1(config)#int lo0
                              R1(config-if)#ip address 10.1.1.1 255.255.255.255

                              R1(config)#int lo1
                              R1(config-if)#ip address 10.2.1.1 255.255.255.255

                              R1(config)#int gi0/0/0
                              R1(config-if)#desc Peer Link
                              R1(config-if)#ip address 192.168.1.2 255.255.255.252

                              R1(config)#router bgp 6201
                              R1(config-router)#bgp router-id 10.1.1.1
                              R1(config-router)#neighbor 192.168.1.1 remote-as 6200
                              R1(config-router)#network 10.1.1.1 mask 255.255.255.255
                              R1(config-router)#network 10.2.1.1 mask 255.255.255.255
                        

Router 2:

Cisco IOS
                              R2(config)#int lo0
                              R2(config-if)#ip address 10.0.1.1 255.255.255.255

                              R2(config-)#int lo1
                              R2(config-if)#ip address 10.0.2.1 255.255.255.255

                              R2(config)#int gi0/0/0
                              R2(config-if)#ip address 192.168.1.1 255.255.255.252
                              R2(config-if)#desc Peer Link

                              R2(config)#router bgp 6200
                              R2(config-router)#bgp router-id 10.0.1.1
                              R2(config-router)#neighbor 192.168.1.2 remote-as 6201
                              R2(config-router)#network 10.0.1.1 mask 255.255.255.255
                              R2(config-router)#network 10.0.2.1 mask 255.255.255.255
                        

Once you get BGP configured on them, you should see the following log message with the respective IP of the neighbor.

Cisco IOS
                              %BGP-5-ADJCHANGE: neighbor 192.168.1.1 Up

You can verify you're getting routes from the hosts by doing a show ip route. This is an example of the output on one of the routers.

Cisco IOS
                              R1#sh ip route
                              Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
                                  D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
                                  N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
                                  E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
                                  i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
                                  * - candidate default, U - per-user static route, o - ODR
                                  P - periodic downloaded static route

                              Gateway of last resort is not set

                                  10.0.0.0/32 is subnetted, 4 subnets
                              B       10.0.1.1/32 [20/0] via 192.168.1.1, 00:00:00
                              B       10.0.2.1/32 [20/0] via 192.168.1.1, 00:00:00
                              C       10.1.1.1/32 is directly connected, Loopback0
                              C       10.2.1.1/32 is directly connected, Loopback1
                                  192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks
                              C       192.168.1.0/30 is directly connected, GigabitEthernet0/0/0
                              L       192.168.1.2/32 is directly connected, GigabitEthernet0/0/0
                              

BGP Troubleshooting

show ip bgp will show learned and advertised routes.

Cisco IOS
                              R1#sh ip bgp
                              BGP table version is 5, local router ID is 10.1.1.1
                              Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
                                        r RIB-failure, S Stale
                              Origin codes: i - IGP, e - EGP, ? - incomplete

                              Network          Next Hop            Metric LocPrf Weight Path
                              *> 10.0.1.1/32       192.168.1.1              0     0     0 6200 i
                              *> 10.0.2.1/32       192.168.1.1              0     0     0 6200 i
                              *> 10.1.1.1/32       0.0.0.0                  0     0 32768 i
                              *> 10.2.1.1/32       0.0.0.0                  0     0 32768 i
                              

show ip bgp summary will show a simple summary of BGP and the neighbors:

Cisco IOS
                              R1#sh ip bgp summary 
                              BGP router identifier 10.1.1.1, local AS number 6201
                              BGP table version is 5, main routing table version 6
                              4 network entries using 528 bytes of memory
                              4 path entries using 208 bytes of memory
                              2/2 BGP path/bestpath attribute entries using 368 bytes of memory
                              2 BGP AS-PATH entries using 48 bytes of memory
                              0 BGP route-map cache entries using 0 bytes of memory
                              0 BGP filter-list cache entries using 0 bytes of memory
                              Bitfield cache entries: current 1 (at peak 1) using 32 bytes of memory
                              BGP using 1184 total bytes of memory
                              BGP activity 4/0 prefixes, 4/0 paths, scan interval 60 secs

                              Neighbor        V    AS MsgRcvd MsgSent   TblVer  InQ OutQ Up/Down  State/PfxRcd
                              192.168.1.1     4  6200      11       9        5    0    0 00:07:56        4
                              

Using show ip bgp neighbors will show all of the neighbors and their status. Some of the following status:

The output of this command was not shown due to how long the output can be. If you have multiple neighbors, this can be a very lengthy output. If you use the | i searchterm with this command, you can find what you need much quicker.

  • Idle – The router is in a starting state where BGP is not actively attempting to form a session yet, usually waiting for a trigger or reset condition to clear.
  • Connect – The router has initiated a TCP connection to the neighbor on port 179 and is waiting for that connection to complete.
  • Active – The router is actively trying to establish a TCP connection with the neighbor after a failed attempt, repeatedly retrying if needed.
  • OpenSent – A TCP connection has been established and the router has sent its BGP Open message, waiting to receive one from the neighbor.
  • OpenConfirm – Both sides have exchanged Open messages and are now waiting for BGP Keepalive messages to confirm the session parameters.
  • Established – The BGP session is fully up, and routers can now exchange routing information (UPDATE messages).


Related Content