Introduction to the ten BGP path attributes and how to modify them.

1. Attribute classification

recognized attribute

(The attribute that all BGP routes must recognize)

  • Well-known Mandatory (Well-known Mandatory) An attribute that must be carried in all routes.
  • Well-known Discretionary (Well-known Discretionary) is free to choose whether to include attributes.

optional attributes

(May not be recognized by BGP routers)

  • Optional Transitive does not recognize this attribute and will continue to forward routes carrying this attribute.
  • Optional Non-transitive (Optional Non-transitive) does not recognize this attribute, and will not continue to forward routes carrying this attribute.

2. Attribute Items

Recognized must comply : Origin, AS_Path, Next_Hop

Recognized as arbitrary : Local_Preference, Atomic_aggregate

Optional transitions : Aggregator, Community

Optional non-transitional : Med, Cluster-List, Originator-ID

insert image description here

Three, attribute details

Recognized as obligatory

Origin

Name: Origin

Function: It identifies the origin of the BGP route and how the BGP route was generated.

introduce:

1. The representation of Origin is divided into three types: i, e,?

insert image description here

2. When there are multiple routes with different Origin attributes to the same destination, and other conditions are the same, BGP will optimize routes in the following order of Origin: IGP > EGP > Incomplete, that is, i > e > ?.

3. How to view the path attribute?display bgp routing-table

In the red box in the figure below, Path is similar to Origin:

1. By default, the Path of the route generated from IBGP is empty, while the Path of the route imported from EBGP will carry the AS number.

2. Origin is i, indicating the routing entry learned from IBGP or EBGP.

Do not confuse EGP with EBGP here. EGP is an early protocol for exchanging routing information between AS autonomous systems, the predecessor of BGP.

insert image description here

AS_Path

Name: AS_Path path

Function: Identify the list of AS numbers that need to pass through when going to the target network.

introduce:

1. Taking AS_Path 300 200 100 as an example, the route is generated from AS100, passes through AS200 and AS300, and finally reaches the local router.

2. AS_Path records the passed AS number, so when the route of AS100 is passed back to AS100, it will be discarded, because AS_Path contains its own AS number. This is a common anti-ring attribute of BGP .

3. AS_Path identifies the passing AS. When learning two BGP routes with the same purpose, if other attributes are the same but the AS_Path is different, the fewer AS numbers in the AS_Path, the better. The route with the shorter AS_Path has higher priority .

4. The types of AS_Path include commonly used AS_SEQENCE and AS_SET .

 AS_SEQENCE representation method:AS_PATH=300 200 100

 AS_SET representation method:AS_PATH=300 {100,200}

Under what circumstances does AS_SET appear?

  • Occurs when BGP routes are aggregated.

  • Route aggregation solves two types of problems. One is to reduce the burden on devices, and the other is to hide detailed routing information and reduce the impact of route flapping. However, after the route is aggregated, the AS_Path attribute is lost, and there is a risk of a loop. Therefore, the AS_Path attribute of the AS_SET type can be used to carry the AS path information before aggregation.

  • After route aggregation occurs, if the aggregated route needs to carry the AS number carried in the AS_Path attribute of all detailed routes to prevent loops, add the as-set parameter to the command for configuring aggregation.

  • The {} behind AS_PATH indicates the passed AS numbers. The AS numbers in this set are not in sequence, which is mainly used to prevent loops.

  • As shown in the figure below, R3 aggregates the routes of R1 and R2, and then passes the aggregated routes classified as AS300 to R4.

insert image description here

Next_Hop

Name: Next_Hop next hop

Function: used to specify the next hop address to reach the target network.

introduce:

In different scenarios, the device sets the default Next_Hop attribute value of BGP routes according to the following rules:

 1. When a BGP router advertises a route to an IBGP or EBGP peer, it will set the Next_Hop of the route to the address of the interface that establishes a BGP neighbor relationship between the local end and the peer end .

 2. After the router receives the EBGP route and forwards it to other IBGP peers, it will keep the value of the Next_Hop attribute of the route unchanged.

 3. If the router receives a BGP route, the Next_Hop attribute value of the route belongs to the same network segment as the EBGP peer (update object), then the Next_Hop address of the route will remain unchanged and passed to its BGP peer body. [Similar to FA address function]

As shown below:

(1) R3 receives the next hop of the EBGP route destined for 10.0.2.0/24 sent by R2 to 10.0.123.2.

(2) When R3 learns that the EBGP route to 10.0.2.0/24 with the next hop of 10.0.123.2 is passed to R1, the next hop will not be modified to the address that establishes an EBGP neighbor with R1, because it satisfies the Next_Hop attribute **"Next_Hop attribute value and EBGP peer (update object) belong to the same network segment, then the Next_Hop address of this route will remain unchanged and be passed to its BGP peer"**

insert image description here

Recognized as arbitrary

Local_Preference

Name: Local_Preference local preference

Function: It is used to tell the router in the AS which path is the preferred path to leave the AS.

introduce:

1. The larger the value of the Local_Preference attribute, the better the route . The default Local_Preference value is 100, which can be modified through policy routing.

insert image description here

2. This attribute can only be passed to IBGP peers , but not to EBGP peers. If a route carrying Local_Preference is received between EBGP peers, error handling will be performed.

Question : If the LP value cannot be passed to EBGP, does EBGP have the LP value?

 When a router sends a route update to its EBGP peer, it cannot carry the Local_Preference attribute, but after the peer receives the route , it will assign a default Local_Preference value (100) to the route locally, and then pass the route to its own IBGP peers.

Atomic_aggregate

Name: Atomic_aggregate aggregation tag

Function: It is only equivalent to an early warning mark, and does not carry any information. It mainly tells the router that the route has been aggregated.

introduce:

1. When a router receives a BGP route update and finds that the route carries the Atomic_Aggregate attribute, it knows that the route may have lost the path attribute. At this time, the router advertises the route to other peers , the Atomic_Aggregate attribute of the route needs to be preserved .

optional transition

Aggregator

Name: Aggregator aggregation identifier

Function: mark which AS and which BGP router the route aggregation behavior occurs on.

introduce:

1. The router performing the route aggregation operation adds an Aggregator attribute to the aggregated route, and records the local AS number and its own Router-ID in this attribute , so other routers can know which AS and which BGP router the aggregation occurred in through the Aggregator superior.
insert image description here

Community

Name: Community community value

Function: A routing mark, mainly to mark the imported routes to facilitate BGP routing control.

introduce:

1. The length of the Community attribute value is 32bit, that is, 4Byte. Available in two forms:

 Decimal integer format.

 AA: NN format, where AA represents the AS number, and NN is a user-defined number.

insert image description here

2. In addition to this, there are default Community values:

community attribute name Group attribute number illustrate
Internet 0(0x00000000) After receiving a route with this attribute, the device can send the route to any BGP peer. By default, all routes belong to the Internet community
No_Advertise 4294967042(0xFFFFFF02) After the device receives a route with this attribute, it will not send the route to any BGP peer
No_Export 4294967041(0xFFFFFF01) After the device receives a route with this attribute, it will not send the route out of the AS
No_Export_Subconfed 4294967043(0xFFFFFF03) After the device receives a route with this attribute, it will not send the route outside the AS, nor will it advertise the route to other sub-ASs in the AS.

optional non-transitional

With

Name: Med Expenses

Function: A metric value used to point out the preferred path to enter the AS to the external peer.

introduce:

1. When there are multiple entrances to the AS, the AS can use the MED to dynamically influence the path selected by other ASs.

 The value of the MED attribute is consistent with the cost, so the smaller the MED, the better the BGP route. The default value is 0.

2. MED is mainly used to affect BGP route selection between ASs. After the MED is passed to an EBGP peer, the peer carries the MED value when passing the route in its AS, but does not carry the MED attribute by default when passing the route to its EBGP peer again.

[As shown in the figure below, R4 preferentially uses the route with the least cost sent by R2, and floods it in IBGP (the cost remains unchanged). ]

[However, if it is passed to another EBGP neighbor, the MED value of the route will be removed. ]

insert image description here

3. By default, routes carrying MED values ​​are not passed to EBGP neighbors, so under what circumstances can they be carried?

 When a route is imported in IBGP, the cost of the imported route will be inherited and will not be deleted when it is passed to EBGP.

 If a router learns a route through IGP and imports the route into BGP through network or import-route , the MED value of the generated BGP route inherits the metric of the route in IGP.

[For example, if R2 learns the 10.0.1.0/24 route through OSPF in the figure below, and the route has OSPF Cost=100 in the global routing table of R2, then when R2 enters the route network into BGP, the MED value of the generated BGP route for 100. ]

insert image description here

 If the router connects the local direct and static routes , then the MED of this BGP route is 0, because the default cost of direct and static routes is 0.

4. Able to understand cost inheritance, but will the learned route continue to inherit the cost and pass it on to the next EBGP neighbor?

 Answer: No, because MED cannot be transferred across ASs.

 Rhetorical question: Then why can R2 inherit from R3?

 Lore: The so-called inheritance can be understood in this way inside IBGP, but on R2 it can be understood as manually setting the MED cost when sending out BGP, which is not a real inheritance.

[So look at the figure below and you can understand that due to the principle that MED cannot cross ASs, when R2 transmits BGP routes to R3, it will automatically modify the MED value, and when R3 transmits it to R4, it will not automatically modify it because there is no so-called inheritance. MED, only routes without MED will be passed to R4]

insert image description here

Originator-ID

Name: Originator ID

Function: record the origin advertiser of the route before reflection. The RR adds Originator_ID to the reflected route, and its value is the Router ID of the BGP router that advertises the route .

introduce:

1. Similar to Origin, the Originator ID is mainly used to record the advertiser of the route before reflection, so that the route after reflection can return to the origin router to cause a routing loop.

2. If there are multiple RRs in the AS, the Originator_ID attribute is created by the first RR and will not be changed by subsequent RRs.

3. When a BGP router receives an IBGP route carrying the Originator_ID attribute, and the value of the Originator_ID attribute is the same as its own Router ID, it will ignore the update about this route.
insert image description here

3. How to check the Originator ID?

insert image description here

Cluster-List

Name: Cluster-List reflection cluster list

Function: It is used to implement routing anti-loop in the RR reflection cluster environment.

introduce:

1. Each cluster has a unique cluster ID (Cluster_ID, which is the BGP Router ID of RR by default)

2. When a route is reflected by the reflector, the Cluster_ID of the RR (the cluster) will be added to the Cluster_list attribute of the route.

3. Multiple routing reflection clusters are allowed in one AS (as shown in the figure below)
insert image description here

4. When the RR receives a BGP route carrying the Cluster_list attribute, and the value of the attribute contains the Cluster_ID of the cluster, the RR considers that there is a loop in the route, and therefore ignores the update/reflection of the route.

[As shown in the figure, R1 reflects the R2 route to R3 (the first Cluster-list is its own RID), R3 continues to reflect it to R4 (the Cluster-list increases the RID of R4), and finally R4 reflects it back to R1 (the Cluster-list increases the RID of R4) , R1 receives the reflected route and finds that its own RID exists in the Cluster-list, then the route will not be processed]
insert image description here

local attribute

Preferred-Value

Name: Preferred-Value protocol preferred value

Function: A unique attribute of Huawei equipment , used for local manual election of the optimal route.

introduce:

1. There are ten BGP path attributes, plus Huawei's exclusive protocol preference value, a total of eleven path attributes.
2. This attribute is only valid locally on the router, so modify the preferred value by creating a policy locally and applying it to the inbound direction of the corresponding neighbor.

insert image description here

3. When there are routes to the same destination in the BGP routing table, the route with a higher Preferred-Value will be selected first . The default value is 0/empty.

[As shown in the figure below, the one with a higher Prefval value will become the preferred route]

insert image description here

Fourth, modify the path properties

Due to space reasons, only relevant configuration commands are given, and the commands can be modified and applied based on logic.

Origin

It is recognized as mandatory, so it can be passed between IBGP and EBGP after modification through policy routing .

Requirement: Change the origin of the route of 192.168.30.0/24 delivered by EBGP neighbor 10.1.13.3 to EGP type.

Configuration logic:

1. First create an ACL or prefix list to match the 192.168.30.0/24 route

2. Create policy routing, if-match matching routing, and then modify its type through apply origin egp AS number

Because it is modified to EGP, the original AS_Path information needs to be specified

3. Configure the policy After modifying the specified route, you need to create a policy to allow other routes, otherwise other routes will not be delivered.

4. Finally, apply the policy to the corresponding neighbors

ip ip-prefix 30 permit 192.168.30.0 24

route-policy P30 permit node 5 
 if-match ip-prefix 30 
 apply origin egp 200

route-policy P30 permit node 10

[AR1-bgp]peer 10.1.13.3 route-policy P30 import

再次查看BGP路由表:
[AR1-bgp]dis bgp routing-table 
 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   192.168.30.0       10.1.13.3       0                     0      200e

AS_Path

It is recognized as mandatory, so it can be passed between IBGP and EBGP after modification through policy routing .

Requirement: For the route of 192.168.30.0/24 transmitted from EBGP neighbor 10.1.13.3, its AS_Path is increased by AS 65005 to reduce the priority of the route.

Configuration logic:

1. Match routing

2. Create a policy and modify its AS_Path for the specified route

3. Create a policy to release other routes

4. Apply policies to specified neighbors

ip ip-prefix 30 permit 192.168.30.0 24
#
route-policy AS permit node 5 
 if-match ip-prefix 30 
 apply as-path 65505 additive
#
route-policy AS permit node 10

[AR1-bgp]peer 10.1.13.3 route-policy AS import

再次查看BGP路由表:
[AR1-bgp]dis bgp routing-table 
 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
*>   192.168.30.0       10.1.13.3       0                     0      65505 200i

Actions about AS_Path:

1. Additive, add the specified AS number in AS_Path [addition].

2. Overwrite, rewrite AS_Path to the specified AS number [Modify/Delete].

3. None overwrite, clear the AS_Path value.

insert image description here

Next_Hop

It is recognized as mandatory, so it can be passed between IBGP and EBGP after modification through policy routing .

Requirement: Change the route of 192.168.30.0/24 passed from EBGP neighbor 10.1.13.3 to 3.3.3.3.

ip ip-prefix 30 permit 192.168.30.0 24
#
route-policy NextHOP permit node 5 
 if-match ip-prefix 30 
 apply ip-address next-hop 3.3.3.3 
#
route-policy NextHOP permit node 10

[AR1-bgp]peer 10.1.13.3 route-policy NextHOP import

再次查看BGP路由表:
[AR1-bgp]dis bgp routing-table 
 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
      192.168.30.0       3.3.3.3         0                     0      200i

Local_Preference

It is recognized as arbitrary, so it can be transmitted between IBGP and EBGP through policy routing modification , but due to the particularity of the local priority, even if it is transmitted to EBGP neighbors, it will not be processed.

Requirement: Modify the route of 192.168.30.0/24 passed from EBGP neighbor 10.1.13.3 to 300.

ip ip-prefix 30 permit 192.168.30.0 24
#
route-policy LPRI permit node 5 
 if-match ip-prefix 30 
 apply local-preference 300 
#
route-policy LPRI permit node 10 

[AR1-bgp]peer 10.1.13.3 route-policy LPRI import

再次查看BGP路由表:
[AR1-bgp]dis bgp routing-table 
 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   192.168.30.0       10.1.13.3       0          300        0      200i

By default, all local priorities are 100, if you need to modify the default value:[AR1-bgp]default local-preference 新优先值

Atomic_aggregate

It is recognized as arbitrary, so it can be passed between IBGP and EBGP after being modified through policy routing .

Aggregator

It is an optional transition and can be passed between IBGP and EBGP after the policy is modified . Even if the device cannot recognize it, it needs to continue to retain this attribute .

These two attributes cannot be modified through policy routing, and only the configuration commands are given here:

Requirements: Configure the aggregation 192.168.0.0/16 on AR1, suppress the external advertisement of the corresponding detailed route, and add the Aggregator attribute to the aggregated route.

[AR1-bgp]aggregate 192.168.0.0 16 as-set detail-suppressed 

insert image description here

Community

It is an optional transition and can be passed between IBGP and EBGP after the policy is modified. Even if the device cannot recognize it, it needs to continue to retain this attribute.

Requirement: For the route of 192.168.30.0/24 delivered by EBGP neighbor 10.1.13.3, set the community value of the route to 200:3.

ip ip-prefix 30 permit 192.168.30.0 24
#
route-policy COM permit node 5 
 if-match ip-prefix 30 
 apply community 100:3 
#
route-policy COM permit node 10 
#
[AR1-bgp]peer 10.1.13.3 route-policy COM import

再次查看BGP路由详细信息:
[AR1-bgp]display bgp routing-table 192.168.30.0

 BGP local router ID : 10.1.13.1
 Local AS number : 100
 Paths:   1 available, 1 best, 1 select
 BGP routing table entry information of 192.168.30.0/24:
 From: 10.1.13.3 (10.1.13.3)
 Route Duration: 00h00m35s  
 Direct Out-interface: GigabitEthernet0/0/1
 Original nexthop: 10.1.13.3
 Qos information : 0x0
 Community:<100:3>	【团体值在这】
 AS-path 200, origin igp, MED 0, pref-val 0, valid, external, best, select, acti
ve, pre 255
 Not advertised to any peer yet

Extension: When introducing BGP route selection later, this attribute will be used to distinguish different routes, so as to control route selection.

With

It is optional and non-transitional, and can be passed between IBGP and EBGP, but it will be removed by default when it is passed to EBGP neighbors.

Requirement: Change the MED value of the route 192.168.30.0/24 from EBGP neighbor 10.1.13.3 to 10.

ip ip-prefix 30 permit 192.168.30.0 24
#
route-policy MED permit node 5 
 if-match ip-prefix 30 
 apply cost 10 
#
route-policy MED permit node 10 
#
[AR1-bgp]peer 10.1.13.3 route-policy MED import

再次查看BGP路由表:
[AR1-bgp]dis bgp routing-table 
 Total Number of Routes: 2
      Network            NextHop        MED        LocPrf    PrefVal Path/Ogn
 *>   192.168.30.0       10.1.13.3       10                    0      200i

By default, the MED learned by BGP is 0, if you need to modify the default value:[AR1-bgp]default local-preference 新优先值

Cluster-List

It is optional and non-transitional, and it is applied to scenarios where RR reflector clusters exist to prevent multiple route reflections.

Originator-ID

It is optional and non-transitional, and it is used in scenarios where RR reflectors exist to prevent routing loops from being returned to the originating device after multiple reflections.

The above two attributes cannot be modified through policy routing. They are enabled by default and will automatically record the corresponding information.

A detailed introduction will be given later when the BGP reflector is introduced.

Guess you like

Origin blog.csdn.net/qq_45443704/article/details/129910246