BGP attribute classification and route priority selection

BGP attribute classification and route priority selection


1. Common BGP attribute types

Routing attributes are specific descriptions of routes, and all BGP routing attributes can be divided into the following four categories

1. Recognized mandatory attributes (principles that all BGP routers must abide by)

Origin、AS-Path 、Next hop

2. Recognized compliance attributes (all routers can recognize but not necessarily comply)

Local-Preference、Atomic_Aggregate

3. Optional transfer attributes (not all BGP routers can recognize, but all BGP can transfer)

Community、 Aggregator

4. Optional non-transitive attribute (not all routers can recognize it, and BGP routers that cannot recognize it will discard it)

MED、Originator_ID、Cluster_list、Weight

2. Detailed introduction

1. Origin attribute (recognized as mandatory)

Explanation : The Origin attribute is used to define the source of path information and mark how a route becomes a BGP route. It
has the following three types :
IGP : has the highest priority. The origin attribute of the route injected into the BGP routing table through the network command is IGP.
EGP : Second priority. For routing information obtained through EGP, its Origin attribute is EGP.
Incomplete : The lowest priority. Routing information learned by other means. For example, the origin attribute of a route imported by BGP through the import-route command is Incomplete.

2. AS_Path attribute (recognized and required)

The AS_Path attribute records all the AS numbers that a route passes through from the local area to the destination address in vector order; when receiving a route, if the device finds its own AS number in the AS_Path list, it will not receive the route, thus avoiding inter-AS Routing loop.
①When the BGP speaker propagates the route imported by itself:
When the BGP speaker advertises this route to the EBGP peer, it will create an AS_Path list carrying the local AS number in the Update message.
When the BGP speaker advertises this route to the IBGP peer, it will create an empty AS_Path list in the Update message.
②When the BGP speaker propagates the route learned from the Update message of other BGP speakers:
when the BGP speaker advertises this route to the EBGP peer, it will add the local AS number to the front of the AS_Path list (the last left). The BGP device that receives this route can know the AS to pass through to the destination address according to the AS_Path attribute. The adjacent AS number closest to the local AS is listed first, and other AS numbers are listed in sequence.
When the BGP speaker advertises this route to the IBGP peer, it will not change the AS_Path attribute related to this route.

3. Next_Hop attribute (recognized as mandatory)

The Next_Hop attribute records the next hop information of the route. The next hop attribute of BGP is different from that of IGP, not necessarily the IP address of the neighboring device.
The Next_Hop attribute follows the following rules:
When a BGP speaker advertises a route to an EBGP peer, it sets the next hop attribute of the route information to the address of the interface that establishes a BGP neighbor relationship between the local end and the peer end.
When the BGP speaker advertises the local originating route to the IBGP peer, it will set the next hop attribute of the routing information to the address of the interface that establishes the BGP neighbor relationship between the local end and the peer end.
When a BGP speaker advertises a route learned from an EBGP peer to an IBGP peer, it does not change the next-hop attribute of the route information.

4.Local_Pref attribute (recognized and compliable)

The Local_Pref attribute indicates the BGP preference of the router, and is used to determine the best route when the traffic leaves the AS.
When a BGP device obtains multiple routes with the same destination address but different next hops through different IBGP peers, it will preferentially select the route with the higher value of the Local_Pref attribute.
The Local_Pref attribute is valid only between IBGP peers and is not advertised to other ASs. The Local_Pref attribute can be manually configured. If the Local_Pref attribute is not configured for the route, the Local_Pref value of the route will be processed as the default value of 100 during BGP route selection.

5. Community attribute (optional transfer)

The community attribute (Community) is used to identify BGP routes with the same characteristics, which makes the application of routing policies more flexible and reduces the difficulty of maintenance and management.
Community attributes are divided into custom community attributes and recognized community attributes.
The recognized community attributes are shown in the table
insert image description here

6. MED attribute (optional non-transitive)

The MED (Multi-Exit Discriminator) attribute is used to determine the best route when traffic enters an AS. When a device running BGP obtains multiple routes with the same destination address but different next hops through different EBGP peers, other Under the same conditions, the route with the smaller MED value will be selected as the best route.
The MED attribute is only transmitted between two adjacent ASs, and the AS that receives this attribute will not announce it to any other third-party AS.
The MED attribute can be manually configured. If the route is not configured with the MED attribute, the MED value of the route will be processed as the default value of 0 during BGP route selection.

7. Originator_ID attribute and Cluster_List attribute (optional non-transferable)

The Originator_ID attribute and the Cluster_List attribute are used to solve the loop problem in the route reflector scenario.

3. BGP selects route priority rules

1. The route with the highest protocol preference value (PrefVal) is preferred.

The protocol preferred value (PrefVal) is a unique attribute of Huawei devices, and this attribute is only valid locally.

2. Prefer the route with the highest local preference (Local_Pref).

If the route has no local preference, the route will be processed according to the default local preference 100 during BGP route selection.

3. Select manual aggregated routes, automatic aggregated routes, routes imported by the network command, routes imported by the import-route command, and routes learned from peers in sequence.

4. Prefer the route with the shortest AS path (AS_Path).

5. Select the routes whose origin types are IGP, EGP, and Incomplete in sequence.

6. For routes from the same AS, the route with the lowest MED value is preferred.

7. Select EBGP routes, IBGP routes, LocalCross routes, and RemoteCross routes in sequence.

The ERT of the VPNv4 route of a VPN instance on the PE matches the IRT of other VPN instances and is copied to the VPN instance, called LocalCross
. The ERT of the VPNv4 route learned from the remote PE matches the IRT of a VPN instance and is copied to the VPN instance, called RemoteCross

8. Prefer the route to the BGP next hop with the smallest IGP metric.

In IGP, for different routes to the same destination address, IGP calculates the metric value of the route according to its own routing algorithm

9. Prefer the route with the shortest Cluster_List.

10. Prefer the route advertised by the device with the smallest Router ID.

If the route carries the Originator_ID attribute, the size of the Originator_ID will be compared during the route selection process (the Router ID will no longer be compared), and the route with the smallest Originator_ID will be selected

11. Prefer the route learned from the peer with the smallest IP Address.

BGP load balancing
When there are multiple equal-cost routes to the same destination address, BGP equal-cost load balancing can be used to achieve the purpose of balancing traffic. The condition for forming BGP equal-cost load sharing is that the attributes to be compared in rules 1 to 8 of "BGP route selection strategy" are exactly the same

Guess you like

Origin blog.csdn.net/qq_30054403/article/details/128955070