BGP routing principle notes Cyrus

The attributes of BGP are some of the characteristics of BGP routes. It is
recognized that it must be followed: as long as it is a BGP route, it should have characteristics. The Update message must contain these attributes.
AS-Path, Next-Hop, Origin ID
(1) When the prefix is ​​first injected into BGP, Next-hop dependency injection method
aggregate-address-0.0.0.0 (local router)
network / redistribute-the next-hop address of the original route. If the next-hop address of the route exists (pointing to null), this router will become the BGP The next hop of routing! That is 0.0.0.0
(2) The prefix advertised through EBGP, the next hop is automatically reset to the updated source address of the EBGP Peer that is sending the prefix! Except for "third-party next hop" here
(3) IBGP next hop remains unchanged, and next-hop-self can also be used to modify the
recognized compliance: all BGP routers can recognize it, but it is not necessarily required, and it may not be included in the Updata message The attribute
Local-prefence, Atomtic-aggre
optional transmission: not all routers can recognize, but all routers can pass it, even if this router does not accept it can also pass
Aggregator, Community
optional non-transmission: not all routers are Recognizable, unrecognizable routers discard it! If the BGP router does not accept it, immediately discard this feature, and no longer pass
MED, Originator ID, Cluster Lister
============================= ===============
Each BGP update message has a variable-length path attribute sequence <attribute type, attribute length, attribute value>, if the first bit is 0, it is a recognized attribute, if it is 1, the attribute is optional Attribute, if the second bit is 0, the attribute is not transferable, if it is 1, the attribute is transferable, it is recognized that the attribute is always transferable, and the third bit in the attribute flag field indicates that optional Whether the information in the transfer attribute is partial (value 1) or complete (value 0), the fourth bit determines whether the attribute length is 1 word or 2 bytes, and the other 4 bits in the flag field are always 0. Attribute type The code byte contains the attribute code. As shown below.


BGP routing attribute (located in the BGP table)
(1) Weight-optional non-transit attribute (higher is better)
This router is valid (propagation range: Cisco IOS private attribute)
Locally initiated route 32768 The
learned route is 0 (Two default values)

(2)
The
default value of Local-preference transmission (propagation range) in this AS is 100, which
can be modified under the process: bgp default local-preference XXX
Configuration result description: configuration in this AS affects this AS's access to external networks (recommended to use detailed routing View this property)

(3) Origination
evaluates the route based on the origin (origination). The
local origin route of the router is preferred, in order from high to low:
default-originate (for each neighbor)
default-information-originate (for each address cluster)
network
redistribute
aggregate-address

(4) AS-Path
network - wide propagation (propagation range)
every time an AS number passes, it is added after the starting AS (left side) (default value)
By default, the path with the shortest AS-PATH list takes precedence. However, this step
can be ignored by configuring bgp bestpath as-path ignore (implicit command). Configuration instructions: you can add AS numbers in the in and out directions to affect BGP transmission
. Add the set AS number
before entering and add it before issuing The set AS number
Note:
An AS-PATH is counted as 1, regardless of how many AS
AS_CONFED_SQUENCE is included in the "set" is not included in the length of the AS-Path

(5) The default value of Origin-ID (Origin code)
network-wide propagation (propagation range)
depends on the way of advertising routes.
Configuration instructions: IGP> EGP> incomplete
EGP routes no longer exist on the current network!
When the prefix is ​​injected into BGP, its Origin-ID attribute is automatically defined, but it can be modified manually

(6) MED (smaller is better) [metric]
The
default value of propagation within this AS (propagation range) is 0 (default value).
Configuration description: This AS is configured to affect external access to the network
MED in this AS. :
By default, the MED will be compared only when the AS_SEQUENCE is the same as the first AS! If you want to compare the MED from different ASs, you must activate bgp always-compare-med, and it is activated in the entire AS.
If the received route does not have a MED, it is reset to 0 by default, unless bgp bestpath med missing-as-worst Activated (By default, the route entry with MED lost will be set to a worst MED value)
* Any sub-confederation autonomous system is ignored, you can use bgp always-compare-med to activate all paths are compared with the
local initiated by the MED border router The MED attribute advertised to eBGP neighbors will not be lost
bgp deterministic-med                                                      
    Pick the best-MED path among paths advertised from the neighboring AS 

In addition, MED's notification rules:
(1. ebgp will clear the value of MED when publishing the route learned from ibgp. If you want to force the announcement, you can use "set metric-type internal" on the announced route
(2. If you use The network or redistribute command advertises the route from IGP to BGP, then the BGP MED is derived from the IGP metric.
(3. If the aggregate-address command is injected into the route, the BGP MED is not set.

(7)Prefer EBGP path over IBGP path (EBGP > IBGP)

(8) Prefer the path through the closest IGP neighbor (
here is the nearest IGP neighbor). This refers to the update source of the peer showing in my routing table, which one is closest to which is the best.
Does OSPF consider O, OIA, OE1, OE2? Just look at cost and not O / OIA / OE.

(9) Prefer the path with the lowest IBGP neighbor router ID (the smallest ibgp router-id)
if maximum-paths {IBGP} n <2-6> is configured, and there are multiple equal-cost paths (for multiple paths, The comparison results of the above 1-6 are the same, and the AS-Path is also the same)
Then BGP will insert n paths in the IGP routing table, the default is only valid for EBGP
BGP default maximum-path = 1, there can only be one optimal path, But it can be changed by command. If there is no IBGP parameter, it can only do EBGP load balancing by default. Another condition for load balancing is that load balancing can only occur when none of the above 8 can match the best one.

(10) When both paths are external paths, BGP will prefer the first received path (the oldest path), but if any of the following conditions are true, this step is ignored.
Enable bgp bestpath compare-routerid
multiple RIDs with the same optimal path (because they are received from the same external router)
currently have no optimal path. An example of the lack of the current optimal path is when the neighbor who is advertising the optimal path fails

Compare Router-ID does not take effect for EBGP

(11) Select the path sent by the BGP neighbor with the smallest RID (If the path contains the RR attribute, use Originator-ID instead of RID)
BGP prefers the route from the BGP router with the lowest router ID. Router-id is the highest IP address on the router, and the loopback port is preferred. You can also statically set the router ID through the bgp router-id command. If the path contains the RR attribute, then in the path selection process, the originator-id is used instead of the router ID.

(12) If the Originator-ID or RID of multiple paths are the same, then select the path with the shortest cluster-list length and
the originating router ID of the multi-hop path is the same, then select the one with the shortest length of CLUSTER_LIST. The router-id of this RR will be added.
If the originating router-id of multiple paths is the same, BGP will prefer the path with the shortest cluster-list length. This situation only occurs in the context of BGP RR.

(13) BGP selects the path from the lowest neighbor address
BGP prefers the path from the lowest neighbor address. This is the address in the BGP neighbor configuration. If it is a loopback port, it depends on the address of the loopback port.
BGP prefers the path from the lowest neighbor address. This is the IP address used in BGP's neighbor configuration, and it corresponds to the remote peer that establishes a TCP connection with the local router.

Lab

step1: R2 advertises two loopback ports, R3 learns two routes through BGP with R1 / R4 and selects R1 as the best (because R1 has a smaller bgp router-id)-the routing principle step 9

step2: The cost of ospf (ip ospf cost 100) of s1 port of R3, so that the two routes of R3 about R2 select R4 as the optimal path (because the cost of R3 to 4.4.4.4 is smaller)-routing Principle Step 8

step3: Establish the IBGP relationship between R1 and R4. R1 learns three routes through BGP with R2 / R4, and selects R2 as the optimal path (EBGP> IBGP)-Step 7 of the routing principle
    

step4: Under the BGP process of R2, the two route MEDs (that is, metric) are changed to 100 for the neighbor R1 with the outbound route-map. At this time, R1 selects R4 as the optimal path for these two routes (because the metric from R4 = 0) —— Step 6 of the routing principle 
ip prefix-list R2 seq 5 permit 100.2.2.0/24
ip prefix-list R2 seq 10 permit 200.2.2.0/24

route-map TR1 permit 10
 match ip address prefix-list R2
 set metric 100
route-map TR1 permit 20

router bgp 100
neighbor 12.1.1.1 route-map TR1 out 

step5: Change the Origin code of the two routes to EBG in the route-map of neighbor R4 under the BGP process of R1. At this time, R1 selects R2 as the optimal path (igp> bgp> Incomplete) for these two routes-
—Routing Principle Step 5 ip prefix-list R4 seq 5 permit 100.2.2.0/24
ip prefix-list R4 seq 10 permit 200.2.2.0/24

route-map FR4 permit 10
 match ip address prefix-list R4
 set origin incomplete
route-map FR4 permit 20

router bgp 100
neighbor 3.3.3.3 route-map FR4 in
neighbor 4.4.4.4 route-map FR4 in 
     

step6: In the BGP process of R1, the AS-path of the two routes is lengthened with the inbound route-map for the neighbor R2. At this time, R1 selects R4 as the optimal path for these two routes (because the as-path is shorter) ——Routing Principle Step 4
route-map FR2 permit 10
 match ip address prefix-list R4
 set as-path prepend 2 2 2
route-map FR2 permit 20

router bgp 100
 neighbor 12.1.1.2 route-map FR2 in (add 2 2 2 before entering, that is, 2 2 2 100) When
going out in the R2 process, add 2 2 2 before going out, which is 100 2 2 2
   

step7: Under the BGP process of R4, use the outbound route-map for neighbor R1 to set the local-preference of the two routes to 10. At this time, R1 selects R2 as the shortest path for these two routes (the higher the local-Pre, the more Excellent)-route selection principle Step 2
route-map TR1 permit 10
 match ip address prefix-list R4
 set local-preference 10
route-map TR1 permit 20

router bgp 100
 neighbor 1.1.1.1 route-map TR1 out 

Step8: At this time, R3 learns that the cost value of R4 is lower, so the two BGP routes prefer R4. On R3, the neighbor R1 is used as the entrance route-map to change the two drop weight = 100, so R3 is about R2. Two routes choose R1 as the optimal path (Weight)
route-map FR1 permit 10
 match ip address prefix-list R1
 set weight 100
route-map FR1 permit 20

router bgp 100
 neighbor 1.1.1.1 route-map FR1 in 
weight cannot use out direction, otherwise prompt:% "FF1" used as BGP outbound route-map, set weight not supported

The IBGP next hop is unchanged by default. The
router must send the local optimal entry to the neighbor, and other suboptimal entries will not be passed to the neighbor.

Published 220 original articles · won praise 2 · Views 4463

Guess you like

Origin blog.csdn.net/qq_43207781/article/details/105480930