BGP attributes + route selection rules

Table of contents

1. Attributes of BGP—Basic Attributes

1.PrefVal

2.LocPrf

3. Prioritize the local next hop (NextHop)     

4、AS-PATH 

5. Origin attribute 

6. MED - Multi-Exit Discrimination Attribute    

2. BGP route selection rules

3. Community attributes of BGP


1. Attributes of BGP—Basic Attributes

1.PrefVal

                                       Spread Range Default Larger/Smaller

PrefVal (weight attribute) do not propagate 0 (0-65535) large

This attribute is a private attribute (Huawei) and is only valid locally

All local BGP routes learned through 4.4.4.4 neighbors have their priorities changed to 1;

[r3]bgp 2

[r3-bgp]peer  4.4.4.4 preferred-value 1   

Load balancing: When accessing the same target, when there are multiple paths with similar costs, let the device share the traffic and delay
                   multiple paths to transmit at the same time;
Equal overhead load balancing: When load balancing, the costs must be the same;

Routing strategy to achieve - in the process of BGP routing control plane transfer, capture route modification attributes

Load sharing: When accessing different targets, let the router choose different paths; achieve the effect that all paths are used;

[r3]ip ip-prefix p permit 1.1.1.0 24 Grab the network number

[r3] route-policy p permit node 10 custom policy

[r3-route-policy]if-match ip-prefix p match traffic

[r3-route-policy] apply preferred-value 1 Modify the priority attribute

[r3-route-policy]q

[r3] route-policy p permit node 20 Since the routing policy has the function of distribution list, the empty list must be considered

[r3-route-policy]q

[r3]bgp 2

[r3-bgp]peer 4.4.4.4 route-policy p import and the control plane direction call of the neighbor transfer route;

      The feature that the priority does not propagate can only be called in the local inbound direction;

2.LocPrf

                                           Spread Range Default Larger/Smaller

LocPrf (local priority) within the entire AS - between IBGP neighbors 100 (0-255) large

The most commonly used attributes for route selection under the interference I BGP neighbor relationship ;

[r4-bgp]default local-preference 1 When passing routes locally to all local IBGP neighbors, modify the attribute to 1;

Load sharing: 

[r3]ip ip-prefix l permit 1.1.1.0 24

[r3]route-policy l permit node 10      

[r3-route-policy]apply local-preference 101

[r3-route-policy]if-match ip-prefix l

[r3-route-policy]q

[r3]route-policy l permit node 20

[r3-route-policy]q

[r3]bgp 2

[r3-bgp]peer 4.4.4.4 route-policy l import can be called in the outbound or inbound direction between I BGP neighbor relationships

3. Prioritize the local next hop (NextHop)     

When locally announcing the IGP route in the local routing table in the bgp protocol, the next hop address in the local BGP table is 0.0.0.0;

For routes learned from other neighbors through BGP, the next hop address is normally not 0.0.0.0; the local preferred route of 0.0.0.0 is passed to other local BGP neighbors;

4、AS-PATH 

During the transfer process in the BGP routing entry, record all the AS numbers passed

effect:

The path with the least number of passing AS numbers is preferred; at the same time, this attribute is used for EBGP split horizon, and if there is a local AS number in the received route entry, it will refuse to receive it;

        Artificially increase the number of AS numbers between EBGP neighbors to interfere with route selection; modify path A and prefer path B; note that artificial operations can only be added, not reduced ; the addition of AS numbers must be performed between EBGP neighbors ;   

This attribute can interfere with EBGP relationship/IBGP relationship routing, but it can only be configured between EBGP relationship devices;

[r2]ip ip-prefix as index 10 permit 1.1.1.0 24

[r2]route-policy as permit node 10

[r2] if-match ip-prefix as

 [r2]apply as-path 3 4 5 additive

[r2]route-policy as permit node 20

[r2]bgp 2

[r2-bgp]peer 12.1.1.1 route-policy as import

Outbound calls are x 3 4 5 X represents the actual passed AS

The incoming call is 3 4 5 X X represents the actual passed AS

The newly added AS number is at the leftmost end of the list;

Note : In the above configuration, if AS3/4/5 actually exists at the backend of the network, these routes cannot be learned due to EBGP horizontal split;

Solution: Repeatedly add the AS numbers that have actually passed to increase the number

[r2-route-policy]apply  as-path  1 1 1 additive

5. Origin attribute 

        The source of the entry—by what method it enters into the BGP protocol

BGP announces route i in the local routing table   

Redistribute the IGP routes in the local routing table to the BGP protocol         ?

Redistribute the EGP route in the local routing table to the BGP protocol        e

Rule i is better than e is better than ?

[r3]ip ip-prefix o permit 1.1.1.0 24

[r3]route-policy o permit node 10

[r3-route-policy]if-match  ip-prefix o

[r3-route-policy]apply origin egp 2 Write the AS number of the peer device

[r3-route-policy]q

[r3]route-policy o permit node 20

[r3-route-policy]q

[r3]bgp 2

[r3-bgp]peer  2.2.2.2 route-policy o import

Inbound or outbound interface calls for control plane traffic are acceptable;

6. MED - Multi-Exit Discrimination Attribute    

        The BGP protocol has no metric value and no cost by default; the so-called MED is to artificially write a cost value in a routing entry to interfere with route selection;

Can be used to interfere with EBGP/IBGP relationship routing; most commonly used to interfere with EBGP relationship routing ;

It is often used for AS1 to interfere with the routing of AS2 to AS1;

<r1>tracert -a 1.1.1.1 3.3.3.3 The trace command shows the next hop visited between loopbacks

<r1>ping -r -a 1.1.1.1 3.3.3.3 shows back and forth between loopbacks

[r1]ip ip-prefix with permit 1.1.1.0 24

[r1]route-policy med permit node 10

[r1-route-policy]if-match ip-prefix med

[r1-route-policy]apply cost 2

[r1-route-policy]q

[r1]route-policy med permit node 20

[r1-route-policy]q

[r1]bgp 1

[r1-bgp]peer  12.1.1.2 route-policy med export

2. BGP route selection rules

Comparing the premise, multiple BGP routes have the same target, and all of them are optimal (next hop reachable, synchronously closed), and have the same priority (administrative distance)

Prefer the route with the highest Preference_Value (private attribute, valid only locally).

Do not pass the highest authority attribute    can interfere with EBGP/IBGP route selection

The route with the highest local preference (Local_Preference) is preferred.

The transmission between IBGP neighbor relationships     can only be done , and most often interferes with the routing of IBGP relationships.

Prefer manual aggregation > automatic aggregation > network > import > learned from peers.

A route with a short AS_Path is preferred.

EBGP/IBGP relationship can be interfered, but can only be modified between EBGP neighbors;

Origin Type IGP>EGP>Incomplete.

Is the origin attribute i better than e better than ? ; Can be modified at any interface on the control plane;

For routes from the same AS, the one with the smaller MED value is preferred.

The default value is 0, when the route is declared or republished (turning off automatic summarization), it carries the cost of reaching the destination locally, which is most commonly used to interfere with the EBGP route selection attribute 

Routes learned from EBGP are preferred (EBGP>IBGP).

Prefer the route with the smallest metric (ospf metric) of the IGP inside the AS .

The route with the shortest Cluster_List is preferred.

The route with the smallest Orginator_ID is preferred.

Prefer the route advertised by the router with the smallest Router_ID .

Routes learned from neighbors with smaller IP addresses are preferred.

3. Community attributes of BGP

    The extended attribute of BGP    defaults that the products of most manufacturers do not carry the community attribute in the BGP protocol

Add community attributes (community attributes that control the scope of transmission)

[r1]route-policy com permit node 10

[r1-route-policy]apply community no-advertise Modify attributes for all traffic

[r1]bgp 1

[r1-bgp]peer 12.1.1.2 route-policy com export

By default, Huawei devices do not pass community attributes, so when using community attributes, you must define transitivity  

[r1-bgp]peer 12.1.1.2 advertise-community    hop-by-hop behavior, each device needs to enable transitivity

no-advertise If the community attribute exists in the received entry, the route will no longer be delivered

no-export If the received entry has this community attribute, it will not be passed to the next AS

no-export-subconfed If the received entry has this community attribute, it will not be passed to the next small AS

If there are no small ASs in the network, no-export and no-export-subconfed have the same effect when there are only large ASs

Notice 

[r1-bgp] load-balancing as-path-ignore BGP protocol to enable load balancing, only valid for EBGP routes

        The peers of these paths whose conditions are balanced must be the same AS; and only the best is displayed in the BGP table; but the load balance phenomenon appears in the routing table;

        Nex-hop-locai only modifies the next hop to be local for the routing entries learned locally through external AS--EBGP neighbors;

For the EBGP relationship in the federation, the attributes of the transmitted route follow the IGBP relationship; the transitivity follows the EBGP relationship

Guess you like

Origin blog.csdn.net/m0_72210904/article/details/132022035