BGP attributes

1. BGP route selection: The premise of comparison is that multiple BGP routes have the same target, and can be optimized (the next hop is reachable, synchronously closed), and have the same priority (administrative distance)

 Prefer the route with the highest Preference_Value value (private attribute, only valid locally).
Not passing the attribute with the highest authority can interfere with EBGP/IBGP routing
 Prefer the route with the highest local preference (Local_Preference).
IBGP neighbor relationship can only be transmitted, and the route selection that most often interferes with IBGP relationship
 manual aggregation>automatic aggregation>network>import>learned from the peer.
 Prefer the route with short AS_Path.
EBGP/IBGP relationship can be interfered, but it can only be modified between EBGP neighbors;
 Origin type IGP>EGP>Incomplete.
Is the origin attribute i better than e? ; It can be modified at any interface on the control plane;
 For routes from the same AS, a small MED value is preferred.
The default is 0. When announcing or redistributing routes (turn off auto-summarization), the cost of local arrival to the destination is
most commonly used to interfere with the attributes of
EBGP routing.  Routes learned from EBGP are preferred (EBGP>IBGP).
 Prefer the route with the smallest Metric of IGP within the AS.
 Prefer the route with the shortest Cluster_List.
 Prefer the route with the smallest Orginator_ID.
 Prefer the route advertised by the router with the smallest Router_ID.
 Prefer the routes learned by neighbors with smaller IP addresses.
Insert picture description here

2. Attributes: Both Huawei and Cisco have 6 basic attributes. The first is private attributes

              传播范围                 默认值              大优或小优 

1. Preference_Value does not propagate 0.
Private attributes of Huawei devices
Global operation:
[r3-bgp]pe 2.2.2.2 preferred-value 1 Modify the preference value of all routes learned locally from neighbor 2.2.2.2 to 1;

Load sharing: When accessing different target network segments, let traffic enter different links for communication; use all links instead of only communicating with a single link;
use prefixes to capture network segments that need to modify attributes
[r3] ip ip-prefix w permit 1.1.1.0 24
Customize policies to modify, be sure to pay attention to whether an empty table is needed to allow other routes to pass through
[r3]route-policy w permit node 10
[r3-route-policy]if-match ip-prefix w
[r3-route-policy]apply preferred-value 1
[r3-route-policy]q
[r3]route-policy w permit node 20
[r3-route-policy]q
then call
[r3 for a neighbor in the protocol ]bgp 2
[r3-bgp]peer 2.2.2.2 route-policy w import Because this attribute is private and does not pass attributes, when invoking, it can only be invoked at the control level to affect the local BGP generation;

                    传播范围             默认值              大或小优

2. The local priority IBGP neighbor relationship is 100. The
first public attribute
is the most commonly used to interfere with IBGP routing, and the
most commonly used attribute is
modified globally;
[r4-bgp]default local-preference 101
All local transmissions to IBGP Routing entry, where the local priority is changed to 101;

Use local priority to achieve load sharing
[r2]ip ip-prefix p permit 1.1.1.0 24

[r2]route-policy p permit node 10
[r2-route-policy]if-match ip-prefix p
[r2-route-policy]apply local-preference 101
[r2-route-policy]q
[r2]route-policy p permit node 20
[r2-route-policy]q

[r2]bgp 2
[r2-bgp]pe 3.3.3.3 route-policy p export can be used in either the outbound or inbound direction at the control plane when invoking, but it must be an IBGP neighbor relationship;
3. As-path preferably has fewer ASs Path; this attribute is automatically added between EBGP neighbor relationships;
[r4]ip ip-prefix as permit 1.1.1.0 24

[r4]route-policy as permit node 10
[r4-route-policy]if-match ip-prefix as
[r4-route-policy]apply as-path 3 4 5 additive
[r4-route-policy]q
[r4]route-policy as permit node 20
[r4-route-policy]q

[r4]bgp 2
[r4-bgp]pe 14.1.1.1 route-policy as import Note: It can be called in the in or out direction of the control plane, but it can only be operated between ebgp neighbors; it can interfere with the routing of ebgp and ibgp relationships;

Outgoing call x 3 4 5 x is the actual AS number passed; the front number is the latest AS number passed;
incoming call 3 4 5 x

Remember: the as-path attribute is also used for horizontal division of EBGP. If the artificially added as number actually exists at the back end of the network, these routes will not be able to enter these ASs. Solution: repeatedly add the AS numbers that have passed;

4. How the origin attribute entry is generated:
network announces any route in the local routing table i
import republishes the local routes learned by other protocols to the BGP protocol?
egp The routes learned by the early ebg protocol are republished to the BGP protocol.
The modification of this attribute can be modified on any interface through which the entire control plane traffic passes;
[r4]ip ip-prefix o permit 1.1.1.0 24

[r4]route-policy o permit node 10
[r4-route-policy]if-match ip-prefix o
[r4-route-policy]apply origin egp 2 The AS configured here is the AS number of the peer neighbor
[r4] route-policy o permit node 20
[r4-route-policy]q
[r4]bgp 2
[r4-bgp]pe 3.3.3.3 route-policy o export
5. MED multi-export authentication attributes BGP protocol does not have cost by default; MED It is the rule of artificially using the router to choose the route—first compare the administrative distance (Huawei is the priority), and if it keeps comparing the metric value (Huawei is the cost), the
BGP protocol carries the cost value to reach the target locally under certain conditions; local announcement (recommended) Publish) the route in its own routing table, and pass it to the local ebgp neighbor, which will carry the cost value; for other AS devices to learn the route from the same as, the path with the smallest MED is preferred; the
administrator can In the process of transferring routing on the control plane, manually modify the MDE; most often used to interfere with ebgp routing;
often used to interfere with AS2 routing to AS1;
[r1]ip ip-prefix med 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 10
[r1-route-policy]q
r1]route-policy med permit node 20
[r1-route-policy]q
[r1]bgp 1
[r1-bgp]pe 14.1.1.2 route-policy med export

In the actual project, the administrator can only configure in one AS, so it is impossible to judge the routing result by viewing the BGP table. It can be solved by extending ping
[r1]ping -r -a 1.1.1.1 3.3.3.3

3. BGP community attributes-BGP extended attributes default that most manufacturers’ products do not carry community attributes in the BGP protocol

Example: Community attributes that control the propagation range
[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 transmit 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 transitive
no-advertise. If the community attribute exists in the received entry, it will no longer be transmitted to the route
no-export. If the community attribute is present in the received entry, it will not be passed to the next If an AS
no-export-subconfed entry has the community attribute, it will not be passed to the next small AS.
If the network does not have a small AS, and only a large AS exists, no-export and no-export-subconfed have the same effect

Guess you like

Origin blog.csdn.net/Han_V_Qin/article/details/112710796
BGP