As previously stated, BGP allows administrators to influence the path that traffic destined into the enterprise network takes. In other words, BGP can be used to influence which path traffic from a neighboring autonomous system takes back into the address space that is advertised out by the enterprise. When using BGP attributes to influence inbound path selection, the configuration must be implemented in the outbound direction. In other words, the attributes that are used to influence the path a neighboring autonomous system uses to take back into the originating autonomous system but be advertised in UPDATES sent to that neighboring autonomous system. There are BGP two attributes that are used to influence the inbound path:
- The MULTI_EXIT_DISC attribute
- The AS_PATH attribute
Influencing Inbound Path Selection using the MED Attribute
Before we delve into the specific configuration of these policies in Cisco IOS software, it is very important to understand when either of these attributes may be used. As was stated in the previous chapter, the MED is used on inter-autonomous system links. This attribute allows BGP to choose among multiple exit points to the same neighboring autonomous system. The following section describes how and when to use the MED attribute to influence the BGP path selection process. This example is based on the topology in Figure 7-1:
Fig.7-1. Using MED to Influence Inbound Path Selection
Referencing Figure 7-1, AS 65001, the enterprise, is peered to AS 2, the service provider in a stub multi-homed Border Gateway Protocol implementation. The enterprise owns the 150.252.0.0/24 address space. The enterprise has two paths to the service provider. The primary path, via R2, has 2 T1 links (approx. 3Mbps). The backup path, via R1, is a single T1 (1.544Mbps). The enterprise would like the service provider to send all traffic destined to their subnet via the primary path. The secondary path should only be used in the event that the primary path is not available, i.e. is physical circuits are down or the BGP neighbor relationship is not established.
Because the enterprise has no control over the configuration of the service provider routers, the solution must be implemented on the enterprise border routers. By advertising the 150.252.0.0/24 prefix with a higher metric (MED) out of R1 (towards the service provider), the enterprise is effectively suggesting that the service provider use the path with the lower metric instead. This is the preferred path, i.e. the path via P2 and R2. The following section goes through the path selection process on R3, which is receiving two paths for the 150.252.0.0/24 prefix – one from router P1 and the other from router P2. The path selected will be the one that this router uses to forward packets received from the Internet destined to this prefix.
- The first step in the path selection process is validating the NEXT_HOP. Assuming that the NEXT_HOP in the UPDATES received from P1 and P2 is valid, the BGP process on R3 continues with the path selection process…
- Next, the BGP process on R3 considers the WEIGHT. Assuming default configuration in the service provider BGP implementation, both UPDATES received by P3 from P1 and P2 have the same WEIGHT value. The path selection process continues…
- Next, the BGP process on R3 considers the LOCAL_PREF for both received UPDATES. Again, as the service provider is using default BGP parameters, the LOCAL_PREF for both paths is the same. The path election process continues…
- Because the path was not originated on the local router, the BGP process on R3 will skip this step and consider the AS_PATH. However, the AS_PATH for both UPDATES is the same. In order to break the tie, the path election process continues…
- Next, the ORIGIN is considered. We will assume that the 150.252.0.0/24 prefix has been injected into BGP using the network command on both routers R1 and R2. Based on this configuration, and assuming basic default BGP configuration on within the service provider network, the UDPATES that P3 receives from P1 and P3 have the same ORIGIN. In order to break the tie, the BGP path election process on R3 continues…
- Next, the BGP process will consider the MULTI_EXIT_DISC (MED) attribute. By default, as was stated in chapter 6, a BGP speaker will remove the MED value before advertising the prefix to an eBGP peer. However, by setting the MED values on the enterprise edge routers, these values will be advertised to routers P1 and P2. P1 and P2 will include the MED in the UPDATE messages sent to P3, their iBGP peer. This effectively means that P3 will select the path with the lowest MED value and use that to forward packets received from the Internet destined to the 150.252.0.0/24 prefix as shown in Figure 7-1
Setting the MULTI_EXIT_DISC is Cisco IOS Software
In Cisco IOS software, the MED is set within a route map using the set metric [metric] route map configuration command. When configuring the metric, lower values are preferred. Following the configuration of the route map, the neighbor [address] route-map [name] out command must be issued to apply the configured route map. Referencing the topology illustrated in Figure 7-1, the following output shows the state of the BGP RIB on router P3 prior to any attribute manipulation, i.e. following basic default configuration parameters:
| P3#show ip bgp 150.252.0.0/24 BGP routing table entry for 150.252.0.0/24, version 5 Paths: (2 available, best #2, table Default-IP-Routing-Table) Not advertised to any peer 65001 10.0.4.1 from 10.0.4.1 (2.2.2.2) Origin IGP, metric 0, localpref 100, valid, internal 65001 10.0.3.1 from 10.0.3.1 (2.1.1.1) Origin IGP, metric 0, localpref 100, valid, internal, best |
In the output above, router P3 has selected the path via 2.1.1.1 (P1) as the best path because, all else being equal, this path was received from a router with a lower router ID. In order to influence the path that AS 2 takes to the 150.252.0.0/24 prefix, R1 must be configured to send updates for this prefix with a higher MED value than by advertised by R2 to router P2. This configuration is implemented as follows on R1:
| R1(config)#ip prefix-list NET-150 seq 5 permit 150.252.0.0/24 R1(config)#route-map SET-MED permit 10 R1(config-route-map)#match ip address prefix-list NET-150 R1(config-route-map)#set metric 20 R1(config-route-map)#exit R1(config)#router bgp 65001 R1(config-router)#neighbor 10.0.0.2 route-map SET-MED out R1(config-router)#exit R1(config)#exit R1#clear ip bgp * soft out |
Before we move onto the configuration implemented on R2, we will first discuss the sequence of commands shown in the configuration above. First, a prefix list is configured to match the 150.252.0.0/24 prefix. Because the enterprise is advertising a single prefix to the service provider, it is not necessary to configure a prefix list; however, it is recommended practice.
Next, a route map is configured. This route map matches the configured prefix list and then sets a metric (MED) value of 20 to this prefix. In the third step, the route map is applied in the outbound direction for UPDATE messages sent to P1. In the final step, rather than waiting for the BGP Scanner process to run, the clear ip bgp * soft out command is issued to ensure that these changes take effect immediately. Following these steps, the BGP RIB on router P3 now shows that the path through router P2 is the best (preferred) path:
| P3#show ip bgp 150.252.0.0/24 BGP routing table entry for 150.252.0.0/24, version 7 Paths: (2 available, best #1, table Default-IP-Routing-Table) Flag: 0x800 Not advertised to any peer 65001 10.0.4.1 from 10.0.4.1 (2.2.2.2) Origin IGP, metric 10, localpref 100, valid, internal, best 65001 10.0.3.1 from 10.0.3.1 (2.1.1.1) Origin IGP, metric 20, localpref 100, valid, internal |
Influencing Inbound Path Selection using the AS_PATH Attribute
While the MED attribute works well when dual-homed to the same provider, as illustrated in Figure 7-1, the same attribute cannot be used when dual-homed to multiple providers. As an example, consider the topology illustrated in Figure 7-2:
Referencing Figure 7-2, route maps setting different MED values are configured on routers R1 and R2. These route maps match the 150.252.0.0/24 prefix. The MED is set to 20 for UPDATE messages sent from R1 to P1, while it is set to 10 for UPDATE messages sent from R2 to P2. While both AS 1 and AS 2 receive the different MED values for the 150; these same values are not included in UPDATE messages sent to AS 3 because the MED is a non-transitive attribute.
NOTE: Even if the MED value received from the enterprise was sent in the UPDATE messages from AS 1 and AS 2 to AS 3, by default, router P3 would not consider the MED as Cisco IOS software does not allow MED values to be compared for prefixes received from two different autonomous systems unless the bgp always-compare-medrouter configuration command was issued on router P3. In most cases, providers will not implement this command.
Given these two limitations, another attribute, the AS_PATH attribute should be used in such situations to influence the path into the network. In Cisco IOS software, this is performed by prepending the AS_PATH using a route map, which is then applied in the outbound direction for the specified BGP peer. This is illustrated in Figure 7-3:
Referencing Figure 7-3, AS 5 is prepended only once in UPDATE messages sent by R1 to P1. The result of this configuration is that when P3 receives the UPDATE messages for the 150.252.0.0/24 prefix from P1 and P2, the path via P2 is selected because the AS_PATH in the UPDATE is shorter than that in the UPDATE received from P1.
By prepending the AS_PATH once on R1, UPDATE messages that are sent to P1 show that the 150.252.0.0/24 prefix is two autonomous systems away. This includes the originating autonomous system and the singe prepended autonomous system. When P1 sends UPDATE messages to P3 for the 150.252.0.0/24 prefix, it includes its own autonomous system number. The AS_PATH for this prefix on router P3 now reflects three autonomous systems. Because no AS_PATH prepending was performed on R2, the AS_PATH in UPDATE messages sent to router P2 shows only a single autonomous system. When router P2 advertises this to P3, the AS_PATH shows that 150.252.0.0/24 is only two autonomous system hops away. This path is the shorter path and is therefore elected the best path, assuming all else is equal.
Prepending the AS_PATH is Cisco IOS Software
In Cisco IOS software, AS_PATH prepending is performed by configuring route maps which are then applied to BGP peers in the outbound direction. Within the route map, the set as-path prepend [as 1] [as 2] …set clause is used to prepend autonomous system numbers. When prepending autonomous systems, keep the following in mind:
- Prepend using only your assigned or registered AS number. Do not use an AS number that is registered to another entity
- Always prepend one AS at a time and continue in increments of one until the desired objective has been reached or attained
- Cisco IOS software supports a default of 255 AS_PATH segments in received inbound UPDATES. If a route is received with an AS_PATH segment that exceeds the limit, the BGP routing process will discard the route
It is extremely important to remember and adhere to these rules, especially when prepending the AS_PATH is production environments. Failure to do so can result in unexpected and undesirable BGP and routing operation. Before we delve into the specifics on prepending the AS_PATH in Cisco IOS software, the following shows the BGP RIB on router P3 for the 150.252.0.0/24 prefix prior to any attribute manipulation on any of the routers in Figure 7-2:
| P3#show ip bgp 150.252.0.0 255.255.255.0 BGP routing table entry for 150.252.0.0/24, version 4 Paths: (2 available, best #2, table Default-IP-Routing-Table) Not advertised to any peer 2 5 10.0.4.1 from 10.0.4.1 (2.2.2.2) Origin IGP, localpref 100, valid, external 1 5 10.0.3.1 from 10.0.3.1 (2.1.1.1) Origin IGP, localpref 100, valid, external, best |
In the output above, router P3 prefers the path via router P1 because, all else being equal, this path was received by the router with the lower RID. Now, assuming the enterprise wants traffic destined to the 150.252.0.0/24 prefix to ingress their network via router R2, the following AS_PATH prepending configuration would be implemented for outbound UPDATES on R1:
| R1(config)#ip prefix-list NET-150 seq 5 permit 150.252.0.0/24 R1(config)#route-map SET-AS-PATH permit 10 R1(config-route-map)#match ip address prefix-list NET-150 R1(config-route-map)#set as-path prepend 5 R1(config-route-map)#exit R1(config)#router bgp 5 R1(config-router)#neighbor 10.0.0.2 route-map SET-AS-PATH out R1(config-router)#exit R1(config)#exit R1# R1#clear ip bgp * soft out |
In the configuration above, the prefix list then is configured to match the 150.252.0.0/24 prefix. This prefix list is then matched in the route map named SET-AS-PATH. Following the match clause, the set clause in the route map prepends AS 5 to the AS_PATH for that prefix. This additional autonomous system number is included in UPDATES to router P1 and increases the length of the AS_PATH from one to two autonomous systems.
P1 then adds its own autonomous system in UPDATE messages sent to neighbor P3. When P3 receives this UPDATE, the AS_PATH shows three autonomous system hops for the 150.252.0.0/24 prefix. However, the AS_PATH for the UPDATE received from P2 shows only two autonomous system hops. This path is selected because of the shorter AS_PATH:
| P3#show ip bgp 150.252.0.0 255.255.255.0 BGP routing table entry for 150.252.0.0/24, version 5 Paths: (2 available, best #1, table Default-IP-Routing-Table) Not advertised to any peer 2 5 10.0.4.1 from 10.0.4.1 (2.2.2.2) Origin IGP, localpref 100, valid, external, best 1 5 5 10.0.3.1 from 10.0.3.1 (2.1.1.1) Origin IGP, localpref 100, valid, external |
In the output above, the path via P2 (2.2.2.2) is selected as the best path because the AS_PATH of 2,5 is shorter than that included in the UPDATE from P1 (2.1.1.1) which is 2,5,5. All traffic from AS 3 (and its upstream neighbors) will therefore use the path through AS 2 when sending packets to the 150.252.0.0/24 prefix. The path via AS 1 will be used when the primary path is unavailable or if the AS_PATH configuration in AS 5 is changed or updated.
Influencing Inbound Path Selection using Multiple Attributes
While the previous sections show two distinct instances in which both the MED and AS_PATH attributes can be used, it is imperative to understand that some implementations require that both of these attributes be used at the same time to influence inbound path selection. To further clarify this statement, consider the topology illustrated in Figure 7-4:
Fig.7-4. Understanding How to Use Multiple Attributes to Influence Inbound Path Selection
Figure 7-4 shows an enterprise network that has three edge or border routers. Border routers R1 and R2 are connected to the same ISP, while border router R3 is connected to another ISP. The enterprise would like all traffic destined to the 150.252.0.0/24 prefix to ingress the network through the SP1B-R2 path. In the event that this path is not available, the second most preferred path should be the SP1A-R1 path. And finally, if neither the SP1A-R1 nor SP2B-R2 paths are available, the traffic should ingress the network using the SP2A-R3 path.
In order to satisfy these requirements, the first configuration task would be to configure a route map on R3 and prepend the AS_PATH so that the AS_PATH in the UPDATE sent by AS 2 to the Internet is longer than the AS_PATH in the UPDATE sent by AS 1 to the Internet. In other words, the Internet routers will prefer the path via AS 1 to reach the 150.252.0.0/24 prefix.
Now that we have influenced which of the providers the traffic comes in through, the next task is to influence the specific path within AS 1 that is used for forward packets destined to this subnet. All else being equal, router SP1C in AS 1 would prefer the path via R1 because this router has the lower RID. Therefore, to ensure that the SP1B-R2 path is preferred, a route map would be configured on R1 with a higher MED (metric) for the 150.252.0.0/24 prefix than that advertised by R2. The end result is that SP 1 uses the SP1B-R2 path as the primary path to send packets destined to the 150.252.0.0/24 prefix. The SP1A-R1 will be used in the event that the primary path is unavailable. And finally, if neither of the paths via SP 1 are available, the routers in the Internet community will prefer the path via SP 2 as this will be the remaining valid path to the 150.252.0.0/24 prefix. This attribute manipulation is shown in Figure 7-5:
Fig.7-5. Using Multiple Attributes to Influence Inbound Path Selection
Now that we have a solid understanding of the two attributes that can be used to influence the path that an upstream autonomous system or multiple upstream autonomous systems take back into the enterprise network, the following section takes a look at the BGP attributes that can be used to influence the path that routers will take to exit the enterprise network.




