XCIE-HUAWEI-super complete BGP-4-route optimization

XCIE-HUAWEI-super complete BGP-4-routing optimization

This chapter talks about BGP route selection and attributes

Attributes are carried by TLV encoding

All the above conditional sequences match from small to large, and match uniquely, the same as ACL
And it is impossible not to choose because the last one is Wang Zha, IP comparison, no IP to run what BGP

There is no automatic load balancing in BGP, but you can do load manually

These attributes are also divided into four rules

Wel1-known mandatory (Wel1-known mandatory): All BGP devices can recognize this attribute and must exist in the Update message. If this attribute is missing, the routing information will be wrong.
1Recognized mandatory attribute representative
Next-hop
AS-Path
origin
Wel1-known discretionary (Wel1-knowmn discretionary): All BP devices can recognize this attribute, but it is not required to exist in the Update message, that is, even if this attribute is missing, the routing information will not be wrong
In fact, in simple terms, the same thing needs to exist, but it may or may not exist.
2. Recognized Arbitrary Representative
Local-pref
Optional transitive (Optional transitive): BGP equipment may not recognize such attributes, if BGP equipment does not recognize such attributes, it will still receive such attributes and notify other peers.
Some manufacturers may not recognize it, but they will accept it and pass it on for you
3. Optional over-property representation
Community
Optional non-transitive (optional non-transitive): BGP does not have to recognize such attributes, if BGP does not recognize such attributes, it will be ignored and will not be notified to other peers .
The meaning is obvious
Recognize it, don't recognize it
4. Optional non-transitional
MED
CLuster-list
Originator-ID
RR

Environment

The OSPF running on the bottom layer has already communicated with the whole network

When IBGP establishes a neighbor, it needs to use the update source lo to do it. If it is an IBGP boundary
Then you must do next-hop-local
Because he wants to modify the next hop to point to it, otherwise it will be a black hole if the route is unreachable

One, Preference-Valut (Cisco called weight, Huawei called protocol preferred value)

This is a private property and only valid locally.

https://blog.csdn.net/weixin_48137911/article/details/122890714 //Cisco's is also written by me

The above picture environment
AS1 and AS5 announce the 192.168.1.0/24 network segment at the same time
Then look at the BGP acceptance of R2 and R4

The reason for writing static is because BGP announces that the route must be in the routing table. I am too lazy to make a lo port, which will be more convenient.
In BGP, it is declared that the most accurate number is down to the network segment, otherwise there will be a probability that it will affect the route selection.

Check the BGP table of R2 and R4


It can be seen that there are two 192.168.1.0 in the BGP table on the two devices, but there is only one greater number, because BGP does not automatically load balance, as mentioned earlier
It is in this BGP as a backup, R2 points to R1, and R3 points to R5

This is the default

The first condition, PreVal, preferred value, private, is 0 by default, so the first condition is incomparable by default
 The second condition is localpre, which is called local priority. Although he did not write the first one, the default value is 100.
The third condition is preferably aggregated, then aggregated, then networked, then introduced, and then learned from neighbors. Obviously, it cannot be compared
The fourth one is to prefer a route with a short AS_Path. Obviously, it doesn’t work, because they only pass through one AS, that is, they all pass through 234, and then they are gone.
The fifth one, the origin attribute, IGP>EGP>Incomlet(?) This stuff is displayed as a question mark in the bgp table, and it can’t be compared
The sixth one, MED, can’t be compared, the default value is 0
The seventh one, preferably from EBGP, is better than IBGP
It came out for this one, because they all learned it from EBGP, and the backup one learned it from IBGP, so at this time, the route has already been compared.
If you are matched, don’t close the next match
So how do we know how the system is selected?
display bgp routing-table the network segment you want to check


Among them, in Paths, it means how many there are. For this network segment, there are 2 reachable routes.
Then, there are two 45.1.1.2 below to explain here, the former means the update source, and the latter brackets mean the RID of the other party
Who is on the top, whoever is chosen, the most important attribute is here


not preferred for peer type

Having said so much, it is only the principle of choice and willingness, so now, how to change it? , I will teach you how to do it from the first preferred value

I will talk about this stuff again, the change will only take effect locally and will not be passed on to any device, Huawei private, default value = 0, value range is 0-255, the larger the value, the better
 Stream-saving version: First, use the prefix list to capture, and then use policy matching after capturing, and change the matching policy in BGP after matching

Strategic approach

Use the prefix list to match the network segment 192.168.1.0, then use the route-policy to match the prefix list, and then directly modify the attributes
Then make an empty node so the others don’t match

Called in BGP

For all the routes sent by the neighbor 5.5.5.5, I call bgp (the name of the route-policy) as a policy

After the call, you can see that it has taken effect, but this place should not be done for 5.5.5.5, because the effect I want is to see that the route from 192.168.1.0 from 2.2.2.2 is selected through this attribute.

When I do this policy for 2.2.2.2, it has already taken effect, so the bgp on this device will go to the above route of 192.168.1.0
By the way, this can only be done for the incoming direction, but if the export in the command is sent out, it will not take effect if you do it, because it is only valid locally and will not be transmitted.

2.Local-preference local priority (default value 100)

Delete it for him before doing it, or there will be a conflict later

First of all, this thing is transmitted in IBGP, not in EBGP. The local meaning means this AS, the same AS
The default is 100, the bigger the better
The new policy is called LOCAL, and the network segment called is 123.1.0.0/24 (created on R4)

strategic approach

Why is there no need to make an empty pocket here?
Because of the knowledge he influenced 123.1.0.0/24
Will not match at all, affecting other routes

Then call it directly in BGP, just for a neighbor, now you can call it directly for this network segment, but this needs to be done under the network

net X.X.X.X mask route-policy name

Look at the BGP table of R4’s EBGP (R5) and R4’s IBGP (R2)



It can be seen that it takes effect in IBGP, and there is nothing in EBGP, and the default value is 100 (empty is the default value)

Even if it comes to R1, it is empty, because it is EBGP for R2, and it will take effect for both sending and receiving directions. The default is 2 directions