How do routers choose the best path?
Show
BGP (Border Gateway Protocol) routers usually receive multiple paths to the same destination. Like how our IGPs (RIP, EIGRP, OSPF) work, we need to select the best path to each destination.
IGPs select the path with the lowest metric. For example:
BGP however, selects the best path based on a list of attributes. On the Internet, it’s more important that you have granular control over how you forward your traffic and to which autonomous systems instead of just going for the shortest path based on a metric. Let’s look at a quick example. Below I have the output of the BGP table of a looking glass server:
This BGP router has 5 paths for network 1.0.0.0/24. Look at the > symbol at the bottom left. The > symbol means that BGP has selected this path as the best path. This path will be installed in the routing table. Out of all those 5 paths, why did BGP select this path as the best path? This path was selected based on the following attributes:
Let me give you a quick overview of each attribute. We will cover these in other lessons in detail. WeightPrefer the path with the highest weight. This is a value that is local to the router and it’s Cisco proprietary. The default value is 0 for all routes that are not originated by the local router. You can learn how it works in the BGP weight attribute lesson. Local PreferenceThe local preference is used within an autonomous system and exchanged between iBGP routers. We prefer the path with the highest local preference. The default value is 100. To learn more, take a look at the BGP local preference attribute lesson. OriginatePrefer the path that the local router originated. In the BGP table, you will see next hop 0.0.0.0. You can get a path in the BGP table through the BGP network command, aggregation, or redistribution. A BGP router will prefer routes that it installed into BGP itself over a route that another router installed in BGP. AS path lengthPrefer the path with the shortest AS path length. For example, AS path 1 2 3 is preferred over AS path 1 2 3 4 5. You can learn more about AS path length here. Origin codePrefer the lowest origin code. There are three origin codes:
IGP is lower than EGP and EGP is lower than INCOMPLETE. You can learn how it works in the origin code lesson. MEDPrefer the path with the lowest MED. The MED is exchanged between autonomous systems. For a detailed explanation, take a look at the MED lesson. eBGP path over iBGP pathPrefer eBGP (external BGP) over iBGP (internal BGP) paths. Shortest IGP path to BGP next hopPrefer the path within the autonomous system with the lowest IGP metric to the BGP next hop. Oldest PathPrefer the path that we received first, in other words, the oldest path. Router IDPrefer the path with the lowest BGP neighbor router ID. The router ID is based on the highest IP address. If you have a loopback interface, then the IP address on the loopback will be used. The router ID can also be manually configured. Neighbor IP addressPrefer the path with the lowest neighbor IP address. If you have two eBGP routers and two links in between then the router ID will be the same. In this case, the neighbor IP address is the tiebreaker. Path SelectionWhen BGP has multiple paths to a destination they are stored in the BGP table. All paths are in the BGP table but only one gets installed in the routing table. Which path do we select? We start at the top of the list with BGP attributes and work our way to the bottom:
I hope this lesson has been useful to understand how BGP selects the best path. How do routers find the shortest path?Each router chooses the shortest path to a destination network by comparing the distance (or metric) information it receives from its various neighbors.
What are the 3 ways routers learn paths to destination networks?There are three ways for a router to learn routes:. Static Routing – This is the method by which an administrator manually adds routes to the routing table of a router. ... . Default Routing – This is the method where all routers are configured to send all packets towards a single router.. What is the order of preference for a route to be chosen by a router from the routing table?A router evaluates routes in the following order.. Prefix Length - The longest-matching route is preferred first. ... . Administrative Distance - In the event there are multiple routes to a destination with the same prefix length, the route learned by the protocol with the lowest administrative distance is preferred.. How does OSPF determine best path?OSPF uses cost values to determine the best path to a particular destination – the lower the cost value, the more likely the interface will be used to forward data traffic.
|