BGP Routing and Path Selection for Service Providers

In this Cisco CCNA training tutorial, you’ll learn about how BGP (the Border Gateway Protocol) routing works within service providers. Scroll down for the video and text tutorial.

This is the 2nd in a series of BGP tutorials.

Part 1: Why We Need BGP

Part 3: Configuring BGP Neighbors on Cisco Routers

Part 4: How to Advertise BGP Routes on Cisco Routers

Part 5: Cisco BGP for Enterprises

BGP Routing and Path Selection for Service Providers Video Tutorial

YouTube video

Tiago Candeias

Tiago Candeias

Constant support and feedback from the tutor, detailed explanation on concepts, solid and helpful lab exercises to help solidify concepts. A huge recommend.

Tiago Candeias

The slide below is the last slide you saw in the previous tutorial.

 

BGP for Service Providers

 

In our example, we've got five service providers, SP1 through to SP5. Each of those service providers have their own customers and are running their own IGP (such as OSPF or ISIS) internally. Each of the service providers will be assigned a unique AS (Autonomous System) number through the internet authorities such as IANA. The AS number is used to control the routing of the internet traffic between the service providers.

 

BGP (Border Gateway Protocol) is a path vector routing protocol. By default, it makes routing decisions in a way that is similar to RIP (which uses physical hop count, the total number of routers in the path). However, rather than choosing the path with the shortest hop count, BGP chooses the path with the shortest AS path. In other words, BGP chooses the path with the least amount of ASes from the source to the destination. It doesn't care about physical router by router hops within those other ASes. BGP routers are not aware of the individual physical hops that traffic takes as it moves through another AS. They just see another AS as one single hop. This makes BGP much more scalable than if it were aware of  every router, physical hop by physical hop.

 

We’ll use this simple example to demonstrate how BGP works:

 

BGP for Service Providers - How BGP works

 

In the example, we're looking at how traffic is going to get from Customer 3 (top right of the diagram) to the 203.0.113.8/29 network for Customer 4 (bottom left of diagram). All service providers in the path need to learn the route to get to 203.0.113.8/29

 

If you're wondering why I used 203.0.113 and subnetted it into smaller chunks for all of the examples, it's because that range of IP addresses is designated by the Internet authorities to be used for documentation. When I'm talking about internet routing, I want to use IP addresses that are public, not private. That's why I'm using this range. It's just a single /24 network, so I have to chop it up into smaller subnets for the example.

 

The customer has been allocated 203.0.113.8/29 by their service provider, SP4 using AS 65004. In our example, we need to advertise that route out to all of the other service providers, including Service Provider 3, which is where Customer 3 are connected.

 

BGP Routing and Path Selection for Service Providers - CCNA Tutorial

 

SP4 are connected to SP1 using IP address 203.0.113.1 on the link highlighted above. SP4 will advertise the route 203.0.113.8/28 to SP1 using BGP. SP4 advertises the route with an AS Path of '64004', which is its AS number.

 

SP4 is advertising the route saying, "Hey, you can get to that network through me, and I'm AS 65004. The IP address to use to get to it 203.0.113.1, which is also at me. Use that as your next hop."

 

BGP for Service Providers - How BGP works 1

 

SP1 learns how to get to 203.0.113.8 via SP4 with AS 65004. SP1 will put that information into its BGP table. Then, because SP1 has a BGP relationship with SP2, which uses AS 65002, SP1 will pass the routing information on to SP2. SP1 is connected to SP2 using a different physical link, so it has a different IP address (203.0.113.17 in our example) than the link to SP4.

 

When SP1 advertises the route to SP2, it prepends its own AS number onto the AS path. When it was advertised from SP4 to SP1, the AS path was '65004' (SP4's AS number). When SP1 passes the information on to SP2, it prepends its own AS of 65001 onto the AS path it passes on. Now the AS path is going to be '65001 65004'. SP1 will say, "To get there, use my IP address, which is 203.0.113.17, as your next hop." SP2 will add the route to its BGP table.

 

BGP for Service Providers - How BGP works 2

 

SP1 and SP2 now know how to get to Customer 4. SP2 will pass the route on to Service Provider 3 because it's got a BGP relationship with it. The IP address that connects SP2 to SP3 is 203.0.113.33 and SP2's AS number is 65002. When SP2 passes the information on to SP3, SP2 will prepend its own AS number of 65002 onto the existing AS path of '65001 65004'. The AS path that SP3 learns is '65002 65001 65004'. SP3 learns that it can reach 203.0.113.8/28 with the next hop address of 203.0.113.33, which is on SP2.

 

BGP for Service Providers - How BGP works 3

 

At this point, SP3 has learned how to get to Customer 4 over the top path. But we’ve also got the bottom path - 203.0.113.8/28 is going to be advertised along the bottom path as well. SP4 doesn't just advertise the route to SP1. SP4 also has a BGP relationship with SP5. SP4 will advertise the routing information to SP5 as well. There is one link going to SP1 and a different link going to SP5, so the link to SP5 is going to have a different IP address (203.0.113.49, in our example).

 

SP4 advertises 203.0.113.8/28 to SP5 with an AS path of 65004 and its own IP address (203.0.113.49) as the next hop address. SP5 will put that information into its BGP table so it knows how to get to Customer 4.

 

BGP for Service Providers - How BGP works 4

 

Then it will pass that information onto SP3 because SP5 has a BGP relationship with SP3. The IP address connecting SP5 to SP3 is 203.0.113.65. When SP5 advertises the route to SP3, the AS path will now be '65005 65004'. SP3 will get that information.

 

Path Selection when Multiple BGP Paths Are Present

 

SP3 has now learned two different paths that it can take to get to 203.0.113.8/29. It can either go along the top path or the bottom path. It can go via SP2 as its next hop with an AS path of '65002 65001 65004' and a next hop address of 203.0.113.33, or it can go via SP5 with an AS path of '65005 65004' and a next hop address of 203.0.113.65. Both of those routes will be learned by SP3 via BGP, so they will both go into the BGP table.

 

The BGP table functions in BGP like the OSPF database functions in OSPF. All routes learned from BGP go into the BGP table. But, just like with an IGP, only the best route will be placed into the routing table and actually be used. The routes are compared based on the number of ASes the traffic must go through to reach the destination.

 

In our example, SP3 will compare the routes it has learned and choose the shorter of the two routes to insert into its routing table. The route to customer 4 via SP2 is going through '65002 65001 65004'. That's three ASes. The route to customer 4 via SP5 is going through '65005 65004'. That's only two ASes. SP3 is going to choose the route via SP5 because it has the shortest path based on the number of ASes.

 

Again, both paths will be visible in the BGP table on SP3, but only the best path is inserted into the routing table on SP3.

 

You can see that this is similar to RIP in that it uses the shortest hop count. But, rather than a hop being an individual physical router, a hop is the entire AS of another service provider. A router is not aware and doesn’t care what is happening within each AS. It doesn't know about the individual physical router hops inside each AS. It sees each AS as one single hop.

 

Summary

 

So, looking at the whole thing end to end...

 

BGP for Service Providers - How BGP works Summary

 

Customer 3 has a default static route pointing to its service provider SP3. We're going to send traffic from Customer Three to Customer Four, with a destination address of 203.0.113.9 for example. Customer 3 will send the traffic to SP3 according to its default static route. SP3 will use the BGP route. It knows that the next hop is 203.0.113.65 at AS 65005, so it will send the traffic there. AS 65005 knows that the next hop is 203.0.113.1 at AS 65004, so it will send the traffic there. SP4 is the service provider that actually allocated the public IP address to Customer 4. SP4 knows how to get to Customer 4, so it will send the traffic down to Customer 4. That's how we propagate routes with BGP and how the traffic is going to be forwarded across the Internet.

 

Load Balancing

 

By default, BGP does not do load balancing. If multiple paths to a destination are available which have the same number of ASes, only one of them will be inserted into the routing table. BGP can load balance, but you have to override the default setting to make it do so.

 

BGP Policy

 

We’ve seen that BGP uses the path with the least ASes by default. You can override this setting by configuring BGP policy.

 

One reason you might want to manipulate the BGP path choice is if you are a service provider (that is, you're an AS, and you've got links to other ASes) and  your links to other ASes have different bandwidths. Going back to our example again, let's say that the top half (which has a longer AS path) has higher bandwidth links than the bottom half. We are SP3, and we've got a higher bandwidth connection to SP2 than we do to SP5. By default, traffic is going to go through SP5 because it has a shorter AS path. If we know the top path has higher bandwidth, then we could influence the path selection via BGP policy to force traffic to go via the top path rather than the bottom path.

 

BGP policy allows you to manipulate the path for both outbound and inbound traffic.

 

In the next tutorial, we'll look at the actual BGP configuration process and commands.

Additional Resources

IP Routing: BGP Configuration Guide

 

Want to practice Cisco BGP on your laptop? Download my complete 350-page Cisco CCNA Lab Guide for free.

 

Click Here to get my Cisco CCNA Gold Bootcamp, the highest rated CCNA course online with a 4.8 star rating from over 20,000 public reviews.

 

Text by John Rallison. Need your audio transcriptions or other work edited into stellar written English? Visit johnrallison.com