BGP Attributes - Fundamental Properties
1. Preference Value (PrefVal)
This is a proprietary attribute (Huawei implementation) -- effective only locally (since it's not propagated, modifications can only be made at the entry point)
[r3]bgp 2
[r3-bgp]peer 4.4.4.4 preference-value 1
All BGP routes learned from neighbor 4.4.4.4 will have their preference value modified to 1;
Load balancing: When accessing different destinations, the router selects different paths; achieving the effect of using all paths;
Implemented through routing policies -- modifying attributes during BGP route propagation
[r3]ip ip-prefix p permit 1.1.1.0 24
[r3]route-policy p permit node 10
[r3-route-policy]if-match ip-prefix p
[r3-route-policy] apply preference-value 1
[r3-route-policy]q
[r3]route-policy p permit node 20
[r3-route-policy]q
[r3]bgp 2
[r3-bgp]peer 4.4.4.4 route-policy p import
The non-propagating nature of preference value means it can only be applied in the inbound direction locally;
2. Local Preference (LocPrf)
Used most commonly to influence route selection in IBGP neighbor relationships;
[r4-bgp]default local-preference 101
When locally propagating routes to all IBGP neighbors, modify the attribute to 101;
Load balancing:
[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
This attribute can be propagated, so it can be applied in either inbound or outbound directions between IBGP neighbors
3. Local Next Hop
Route is only considered optimal if the next hop is reachable;
When the router advertises IGP routes from its routing table into BGP locally, the next hop address in the local BGP table is 0.0.0.0;
Routes learned from other BGP neighbors typically have a next hop address that is not 0.0.0.0; The router prefers routes with 0.0.0.0 as next hop when propagating to other BGP neighbors;
4. AS-PATH – Records all AS numbers traversed by the route (EBGP horizontal split)
Note: AS number addition occurs only between EBGP neighbors;
Paths with fewer AS numbers are preferred; This attribute also implements EBGP horizontal split - routes containing the local AS number will be rejected;
Manually increasing AS numbers between EBGP neighbors can influence route selection, modifying path A to prefer path B;
Manual operations can only add, not remove AS numbers, as removal would break the loop prevention mechanism;
Can influence route selection in both EBGP and IBGP relationships, but configuration can only be done between EBGP neighbors;
[r2]ip ip-prefix as index 10 permit 1.1.1.0 24
[r2]route-policy as permit node 10
[r2-route-policy]if-match ip-prefix as
[r2-route-policy]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 application: x 3 4 5 (x represents actual traversed AS numbers) Inbound application: 3 4 5 x (x represents actual traversed AS numbers) New AS numbers are added to the left end of the list;
Note: The above configuration method will prevent route learning if AS 3/4/5 actually exist in the network backend;
Solution: Repeatedly add already traversed AS numbers to increase the count
[r2-route-policy]apply as-path 1 1 1 additive
5. Origin Attribute (Ogn) – Source of the route entry - how it entered BGP
BGP advertisement of local routes Network i
Redistribution of local IGP routes into BGP import ?
Redistribution of local EGP routes into BGP e
Rule: i > e > ?
[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
[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
Can be applied at any control plane interface (inbound or outbound);
6. MED - Multi-Exit Discriminator (metric value)
When redistributing or advertising local routes learned via IGP into BGP, the local IGP metric is carried into the BGP route;
BGP protocol has no metric value by default, no cost; MED is a manually assigned cost value in the route entry to influence router table installation and thus route selection;
Can be used to influence route selection in both EBGP and IBGP relationships, most commonly used for EBGP route selection;
Often used for AS1 to influence AS2's route selection to AS1;
<r1>ping -r -a 1.1.1.1 3.3.3.3
[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 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
BGP Route Selection Rules
Prerequisite: Multiple BGP routes to the same destination, all optimal (next hop reachable, synchronization disabled), with the same preference value (administrative distance)
Related to attributes:
1. Prefer the route with the highest Preference Value (proprietary attribute, locally effective only).
Not propagated, highest priority attribute, can influence EBGP/IBGP route selection
2. Prefer the route with the highest Local Preference value.
Propagated between IBGP neighbors, only and most commonly used to influence IBGP route selection
3. Prefer manual aggregation > automatic aggregation > network > import > routes learned from peers.
4. Prefer the route with the shortest AS_PATH.
Can influence both EBGP and IBGP route selection, but can only be modified between EBGP neighbors
5. Prefer IGP origin type > EGP > Incomplete.
Origin attribute: i > e > ?; can be modified at any control plane interface
6. For routes from the same AS, prefer the one with the smallest MED value.
Default is 0, carries local cost to destination when advertising or redistributing routes (with auto-summary disabled)
Most commonly used attribute for influencing EBGP route selection
Unrelated to attributes:
1. Prefer routes learned from EBGP > federated EBGP > IBGP.
2. Prefer the route with the smallest IGP metric within the AS.
3. Prefer the route with the shortest Cluster_List. (for reflectors) equivalent to selecting smaller Router_ID
4. Prefer the route with the smallest Originator_ID.
5. Prefer routes advertised by the router with the smallest Router_ID.
6. Prefer routes learned from neighbors with smaller IP addresses.
BGP Community Attributes
– Extended BGP attribute, most vendor products do not carry community attributes by default in BGP
Example: Community attribute for controlling propagation range
[r1]route-policy com permit node 10
[r1-route-policy]apply community no-advertise
[r1]bgp 1
[r1-bgp]peer 12.1.1.2 route-policy com export
By default, Huawei devices also do not propagate community attributes, so when using them, transitivity must be defined
[r1-bgp]peer 12.1.1.2 advertise-community
Per-hop behavior, each device must enable transitivity (carry community attributes during propagation)
no-advertise: If a received route contains this community attribute, it will not be further propagated
no-export: If a received route contains this community attribute, it will not be propagated to the next AS
no-export-subconfed: If a received route contains this community attribute, it will not be propagated to the next sub-AS
If the network has no sub-AS and only contains a large AS, no-export and no-export-subconfed have the same effect
BGP Protocol Load Balancing
[r1-bgp]load-balancing as-path-ignore
Enables load balancing in BGP protocol, effective only for EBGP routes
Conditions for balancing: The endpoints of these balanced paths must be in the same AS; Only the optimal path is displayed in the BGP table, but load balancing occurs in the routing table;