BGP uses the following path attributes in update messages for route filtering and selection:
ORIGIN
The ORIGIN attribute specifies the origin of BGP routes. This attribute has the following types:
IGP—Has the highest priority. Routes generated in the local AS have the IGP attribute.
EGP—Has the second highest priority. Routes obtained through EGP have the EGP attribute.
INCOMPLETE—Has the lowest priority. The source of routes with this attribute is unknown. Routes redistributed from other routing protocols have the INCOMPLETE attribute.
AS_PATH
The AS_PATH attribute identifies the ASs through which a route has passed. Before advertising a route to another AS, BGP adds the local AS number into the AS_PATH attribute, so the receiver can determine ASs to route the message back.
The AS_PATH attribute has the following types:
AS_SEQUENCE—Arranges AS numbers in sequence. As shown in Figure 48, the number of the AS closest to the receiver's AS is leftmost.
AS_SET—Arranges AS numbers randomly.
Figure 48: AS_PATH attribute
BGP uses the AS_PATH attribute to implement the following functions:
Avoid routing loops—A BGP router does not receive routes containing the local AS number to avoid routing loops.
Affect route selection—BGP gives priority to the route with the shortest AS_PATH length if other factors are the same. As shown in Figure 48, the BGP router in AS 50 gives priority to the route passing AS 40 for sending data to the destination 8.0.0.0. In some applications, you can apply a routing policy to control BGP route selection by modifying the AS_PATH length. For more information about routing policy, see "Configuring routing policies."
Filter routes—By using an AS path list, you can filter routes based on AS numbers contained in the AS_PATH attribute. For more information about AS path list, see "Configuring routing policies."
NEXT_HOP
The NEXT_HOP attribute may not be the IP address of a directly-connected router. Its value is determined as follows:
When a BGP speaker advertises a self-originated route to a BGP peer, it sets the address of the sending interface as the NEXT_HOP.
When a BGP speaker sends a received route to an EBGP peer, it sets the address of the sending interface as the NEXT_HOP.
When a BGP speaker sends a route received from an EBGP peer to an IBGP peer, it does not modify the NEXT_HOP attribute. If load balancing is configured, BGP modifies the NEXT_HOP attribute for the equal-cost routes. For load balancing information, see "BGP load balancing."
Figure 49: NEXT_HOP attribute
MED (MULTI_EXIT_DISC)
BGP advertises the MED attribute between two neighboring ASs, each of which does not advertise the attribute to any other AS.
Similar to metrics used by IGPs, MED is used to determine the optimal route for traffic going into an AS. When a BGP router obtains multiple routes to the same destination but with different next hops, it considers the route with the smallest MED value as the optimal route. As shown in Figure 50, traffic from AS 10 to AS 20 travels through Router B that is selected according to MED.
Figure 50: MED attribute
Generally BGP only compares MEDs of routes received from the same AS. You can also use the compare-different-as-med command to force BGP to compare MED values of routes received from different ASs.
LOCAL_PREF
The LOCAL_PREF attribute is exchanged between IBGP peers only, and is not advertised to any other AS. It indicates the priority of a BGP router.
BGP uses LOCAL_PREF to determine the optimal route for traffic leaving the local AS. When a BGP router obtains multiple routes to the same destination but with different next hops, it considers the route with the highest LOCAL_PREF value as the optimal route. As shown in Figure 51, traffic from AS 20 to AS 10 travels through Router C that is selected according to LOCAL_PREF.
Figure 51: LOCAL_PREF attribute
COMMUNITY
The COMMUNITY attribute identifies the community of BGP routes. A BGP community is a group of routes with the same characteristics. It has no geographical boundaries. Routes of different ASs can belong to the same community.
A route can carry one or more COMMUNITY attribute values (each of which is represented by a 4-byte integer). A router uses the COMMUNITY attribute to determine whether to advertise the route and the advertising scope without using complex filters such as ACLs. This mechanism simplifies routing policy configuration, management, and maintenance.
Well-known COMMUNITY attributes involve the following:
INTERNET—By default, all routes belong to the Internet community. Routes with this attribute can be advertised to all BGP peers.
NO_EXPORT—Routes with this attribute cannot be advertised out of the local AS or out of the local confederation, but can be advertised to other sub-ASs in the confederation. For confederation information, see "Settlements for problems in large-scale BGP networks."
No_ADVERTISE—Routes with this attribute cannot be advertised to other BGP peers.
No_EXPORT_SUBCONFED—Routes with this attribute cannot be advertised out of the local AS or other sub-ASs in the local confederation.
You can configure BGP community lists to filter BGP routes based on the BGP COMMUNITY attribute.
Extended community attribute
To meet new demands, BGP defines the extended community attribute. The extended community attribute has the following advantages over the COMMUNITY attribute:
Provides more attribute values by extending the attribute length to eight bytes.
Allows for using different types of extended community attributes in different scenarios to enhance route filtering and control and simplify configuration and management.
Currently, the device supports the Route-Target attribute for VPN and Site of Origin (SoO) attribute. For more information, see MPLS Configuration Guide.