Using BGP path attributes

ORIGIN

ORIGIN is a well-known mandatory attribute that defines the origin of routing information, that is, how a route became a BGP route. There are three types:

IGP

Has the highest priority. Routes added to the BGP routing table using the network command have the IGP attribute.

EGP

Has the second highest priority. Routes obtained via EGP have the EGP attribute.

Incomplete

Has the lowest priority. The source of routes with this attribute is unknown, which does not mean such routes are unreachable. The routes that are redistributed from other routing protocols have this attribute.

AS_PATH

AS_PATH is a well-known mandatory attribute. This attribute identifies the autonomous systems through which routing information carried in the Update message has passed. When a route is advertised from the local AS to another AS, each passed AS number is added into the AS_PATH attribute, allowing the receiver to determine the ASs for routing back the message. The number of the AS closest to the receiver’s AS is leftmost, as shown in the following figure.

Figure 58: AS_PATH attribute

Usually a BGP router does not receive routes containing the local AS number to avoid routing loops.

NOTE:

The current implementation supports using the neighbor allow-as-loop command to receive routes containing the local AS number.

The AS_PATH attribute can be used for route selection and filtering. BGP gives priority to the route with the shortest AS_PATH length if other factors are the same. As shown in the above figure, the BGP router in AS50 gives priority to the route passing AS40 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.

By configuring an AS path filtering list, you can filter routes based on AS numbers contained in the AS_PATH attribute.

NEXT_HOP

Different from IGP, the NEXT_HOP attribute may not be the IP address of a directly connected router. It involves three types of values, as shown in the following figure.

  • When advertising a self-originated route to an eBGP peer, a BGP speaker sets the NEXT_HOP for the route to the address of its sending interface.

  • When sending a received route to an eBGP peer, a BGP speaker sets the NEXT_HOP for the route to the address of the sending interface.

  • When sending a route received from an eBGP peer to an iBGP peer, a BGP speaker does not modify the NEXT_HOP attribute. If load-balancing is configured, the NEXT_HOP attribute will be modified. For load-balancing information, refer to BGP route selection.

Figure 59: NEXT_HOP attribute

MED (MULTI_EXIT_DISC)

The MED attribute is exchanged between two neighboring ASs, each of which does not advertise the attribute to any other AS. Similar to metrics used by IGP, MED is used to determine the best 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 the best route if other conditions are the same. As shown below, traffic from AS10 to AS20 travels through Router B that is selected according to MED.

Figure 60: MED attribute

In general, BGP compares MEDs of routes received from the same AS only.

NOTE:

The current implementation supports using the always-compare-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 therefore is not advertised to any other AS. It indicates the priority of a BGP router. LOCAL_PREF is used to determine the best route for traffic leaving the local AS. When a BGP router obtains from several iBGP peers multiple routes to the same destination but with different next hops, it considers the route with the highest LOCAL_PREF value as the best route. As shown below, traffic from AS20 to AS10 travels through Router C that is selected according to LOCAL_PREF.

Figure 61: LOCAL_PREF attribute

COMMUNITY

The COMMUNITY attribute is used to simplify routing policy usage, and to ease management and maintenance. It identifies a collection of destination addresses having identical attributes, without physical boundaries in between, and having nothing to do with the local AS. Well known community attributes involve:

Internet

By default, all routes belong to the Internet community. Routes with this attribute can be advertised to all BGP peers.

No_Export

After being received, routes with this attribute cannot be advertised out the local AS.

No_Advertise

After being received, routes with this attribute cannot be advertised to other BGP peers.

No_Export_Subconfed

After being received, routes with this attribute cannot be advertised out the local AS.