Border Gateway Protocol (BGP) is a routing protocol that is used to exchange routing information among different networks. It is widely used by internet service providers (ISPs) and large corporations to ensure the efficient and reliable routing of traffic across the internet. It is used to exchange routing information between different autonomous systems (ASes) that make up the internet.
BGP uses a number of attributes to determine the best path for routing traffic between networks.
1. AS Path Attribute: The AS Path attribute is a mandatory attribute that identifies the Autonomous Systems that a route has traversed. This attribute is used to prevent routing loops on internet.
2. Weight Attribute: The weight attribute is a Cisco-specific attribute that is used to influence the path selection process in BGP.
3. Local Preference Attribute: This attribute is used in BGP to influence the path selection process. In terms of local preference specifically, it is a value that is set locally on a router for routes that are learned via BGP. Routers use local preference to indicate to other routers which path is preferred when there are multiple paths to the same destination. The higher the local preference value, the more preferred the route. It is important to note that local preference is not advertised to other AS, so it only affects the path selection process within the local AS.
By default, BGP selects the path with the highest weight, where weight is a Cisco-specific attribute. If weight is tied, then BGP looks at the local preference value. The path with the highest local preference is chosen. If local preference is tied, BGP looks at the AS path length, preferring the path with the shortest AS path. If the AS path length is tied, then BGP looks at the origin code, preferring routes with the lowest origin code. If the origin code is tied, then BGP looks at the lowest MED and this way BGP will compare its other attributes one by one like eBGP over iBGP, oldest eBGP route, lowest neighbour BGP router id etc.
Note: BGP will not load balance by default like IGP protocols if metric is equal for multiple path.