Today I will be discussing BGP (Border Gateway Protocol) fundamentals. When it comes to dynamic routing there are two different main types of routes called “IGP” (Interior Gateway Protocol) and “EGP” (Exterior Gateway Protocol.) IGPs are routing protocols that dynamically derive routes within a single AS (autonomous system), while EGPs derive routes between ASs (autonomous systems.)
An example of IGP and EGP would be a gps route. A GPS route with the starting point inside New York to another destination inside New York can represent an IGP route. A GPS route from New York to the destination of New Jersey can represent an EGP route.
AS – An AS (autonomous system) is a collection of networks that are under administrative control by one organization or ISP. For example, a large corporation like CVS has headquarters, branch offices, and actual stores all within the United States. Although each building has its own network infrastructure being that they are geographically separated, the combination of those networks qualify as one AS.
BGP is a path vector routing protocol used to exchange routing information between different ASs (eBGP only) on the internet or between large enterprise (CVS, Publix) or service provider networks. BGP supports the thousands of routes that make up the public internet. IGPs such as OSPF, RIP, and EIGRP make routing decisions based on routing metrics such as bandwidth, delay, cost, or hop count. BGP on the other hand makes routing decisions between independently managed ASs based on path attributes, routing policies (using path attributes like local preference to prefer one ISP over another), and network reachability.
BGP does not make routing decisions on shortest or lowest cost path, but analyzes a series of path attributes instead. BGP path attributes are values attached to routes that a router uses to select the best path to a destination. These attributes provide specific information about a route such as the ASs it has traversed, the preferred exit path for traffic leaving an AS, or the preferred entry point into an AS.
BGP forms reliable neighbors relationships called “peerings” over TCP port 179, and advertises reachable IP prefixes along with their path attributes. After BGP shares every reachable prefix in the routing table, only incremental route changes will be propagated to neighbors. A BGP router can play two roles within the topology which are iBGP (Interior BGP) which are inside an AS, and eBGP (external BGP) which are at the border of the AS forming a peer with an adjacent AS BGP router.
Path Attributes – When BGP is selecting the best path to a destination and there are multiple competing routes, there are several path attributes that are considered in a specific order.
- Highest Weight (Cisco Proprietary)
- Highest Local Preference
- Locally Originated
- Shortest AS PATH
- Lowest Origin Type
- Lowest MED
- eBGP over iBGP
- Lowest IGP metric to NEXT HOP
- Oldest Path
- Lowest BGP RID
- Lowest Neighbor IP Address
BGP path attributes are categorized into groups such as well known mandatory, well known discretionary, optional transitive, and optional non-transitive. Whether a path attribute is placed into which category depends on two things:
- Whether the BGP router understands the attribute.
- Is the BGP router required to advertise the attribute to BGP neighbors.
Understanding in this context means that the BGP router recognizes the attribute, knows its purpose, and knows how to process and use it during BGP operation.

Before diving into each path attribute it is important to note, that this list is sequential and operates on a first match basis. So if there is a winner at weight, the rest of the attributes are not considered. If there is a winner at local preference, the rest of the attributes are not considered and so on.
Weight – Weight is a Cisco Proprietary BGP path attribute used to influence outbound route selection on a single Cisco router. Unlike standard (non-proprietary) BGP path attributes such as local preference or AS PATH, the weight attribute is not advertised to any other BGP routers/neighbors and only impacts the local router where it is configured. When a router learns multiple routes to the same destination, the router prefers the route with the highest weight value before considering any other BGP path attributes. By default, routes learned from BGP neighbors are assigned a weight of 0, while routes that were configured directly on the device (locally originated) are assigned a weight of 32,768. Since weight only impacts the local router and its routing decisions, it can be used to implement router specific traffic engineering and routing policies without affecting any other device in the same AS. For example, one router can prefer a specific path for a route by manipulating the weight value, and this weight value will not affect the same route on other routers within the same AS.
Local Preference – Local Preference is a standard (non-proprietary) BGP path attribute used to influence the preferred exit point (border router) for traffic leaving an AS. Unlike the weight attribute, local preference is actually advertised to all iBGP peers within the same AS but is not advertised to eBGP peers. When a router learns multiple routes to the same destination, it compares the local preference value after weight and prefers the route with the highest local preference. On non-cisco routers this will be the first path attribute to be considered. By default, Cisco routers assign a local preference of 100 to learned routes. Local preference allows network administrators to define consistent routing policy and router specific traffic engineering because defining local preference can cause all routes no matter the router to prefer the same egress router just by changing the value.
Locally Originated – A locally originated route is a BGP route that has been injected into the local BGP table by the router itself rather than being introduced by an iBGP or eBGP neighbor.
Three ways for a route can be considered locally originated are:
- By using the “network” command
- Route distribution from another routing protocol (OSPF, EIGRP)
- The “aggregate address” command for route summarization
During the BGP best path selection process, if higher priority attributes such as weight and local preference are equal, BGP will prefer the route that originated locally over routes learned from BGP neighbors.
AS_PATH – AS PATH is a well known mandatory standard BGP path attribute that records the sequential list of AS numbers that a route advertisement has traversed. If a route starts at AS 10 and traverses AS 20 and then AS 30, the AS PATH allows AS 30 to see that the route advertisement has traveled through AS 20 and AS 10. This attribute serves a double purpose which are loop prevention and path selection. For loop prevention, a BGP router examines the AS PATH of each incoming route advertisement; if it finds its own AS number already listed in the path, it rejects the route to prevent a routing loop. Finding its own AS number indicates that the route advertisement already traversed the AS so accepting it would cause it to be listed twice. For path selection, if higher priority attributes such as weight, local preference, and locally origin are equal, BGP prefers the shortest AS PATH. If there is one path that traverses 2 ASs, and another that traverses 4 ASs, the path with only 2 ASs wins.
Origin – Not to be confused with locally originated but origin is a different concept. Origin is a BGP path attribute that identifies how a route was originally introduced into BGP. An origin is a well known mandatory attribute and has one of three values: IGP, EGP, and Incomplete. A route with an origin of IGP is the most preferred and indicates that the route was introduced into BGP using the network command. A route with an origin of EGP indicates that the route was learned from a now obsolete EGP, this was the protocol used before BGP existed. A route with an origin of incomplete indicates that the route was introduced into BGP by redistribution from another routing protocol such as OSPF or EIGRP, rather than by using the network command. During the BGP best path selection, if higher priority attributes such as weight, local preference, locally originated and AS PATH are equal, BGP routers prefer the origin value in this following order:
- IGP
- EGP
- Incomplete
MED – MED (Multi Exit Discriminator) is an optional non-transitive BGP path attribute used to influence how external neighbors enter an AS when multiple entry points exist. Unlike local preference, which influences outbound traffic, MED is advertised to adjacent (neighbor) ASs to suggest a preferred path for inbound traffic. Unlike weight and local preference where the highest value wins, MED works differently meaning that a lower MED value is preferred over a higher one. During the BGP best path selection, if higher priority attributes such as weight, local preference, locally originated, AS PATH, and origin are equal, BGP prefers the route with the lowest MED value.
iBGP – iBGP routers play a huge role in the BGP. iBGP are peerings that share BGP routes between routers within the same AS. It allows routers to share external routes learned from eBGP routers while preserving its path attributes and routing policies leaving them untouched and routes identical. Although iBGP allows this there is one limitation which is the BGP split horizon rule. Every iBGP must follows this rule, meaning a router cannot advertise routes learned from one iBGP neighbor to another iBGP neighbor. So if one router shares an eBGP route to an iBGP router, that same router will no longer be able to share it to any other iBGP neighbors. In order to overcome this scalability limitation there are 3 solutions:
- Full Mesh iBGP (All iBGP routers peer directly with each other)
- Route Reflectors (Routers that allow iBGP routes to be shared without requiring a full mesh)
- Confederations (Dividing one large AS into smaller internal ASs while appearing as a single AS externally)
Leave a Reply