At the end of my last article, “Using AS path prepending to influence inbound routing“, I mentioned:
“Notice anything weird there? Yeah, traffic from R6 is first going to R7, then to R9 over that T1 connection, NOT the much faster 100 Mbit/s connection! How can we change that? The next article will continue on from here and we’ll change the configuration of our routers in AS 67 to address that.”
We’re going to continue where we left off and create another route-map, this time to manipulate the local preference value assigned to routes received from one of our BGP neighbors. We want to do this so that the fastest connection out of our AS is the preferred one for outgoing traffic.
Here’s the topology we’re dealing with:
We want all outgoing traffic to exit our AS over the 100 Mbit/s connection between R7 and R8, assuming it is available.
The default local-preference, or “local pref”, value assigned to routes is 100. Let’s look at the BGP table on R7 and examine what paths we have received to get to 172.16.99.0/24 (R9):
R7# sh ip bgp | be Network Network Next Hop Metric LocPrf Weight Path *>i172.16.66.0/24 172.31.67.6 0 100 0 i *> 172.16.67.0/24 0.0.0.0 0 32768 i *> 172.16.88.0/24 172.31.78.8 0 0 88 i * 172.31.79.9 0 99 88 i * i 172.31.67.6 0 100 0 88 i * 172.16.99.0/24 172.31.78.8 0 88 99 i *> 172.31.79.9 0 0 99
We can see that we have received a total of two routes to 172.16.99.0/24, one via R8 in AS 88 and the other from R9 in AS 99. Because the path directly to AS 99 is shorter than the path that traverses AS 88, it has been selected as the best path. Traffic destined to AS 99 will exit our AS over the (slow, in comparison) T-1 connection between R7 and R9. We want to change that and ensure that all traffic exits over our 100 Mbit/s connection into AS 88.
Easy as pie. Just like manipulating the AS Path, we’re going to create a simple route-map that takes care of this for us. The route map sets the local preference of received routes to 500 (remember, the default is 100) — higher local preference values win out. We’ll apply this route map to the BGP session between R7 and R8 and be done with it:
R7(config)# route-map LOCALPREF permit 10 R7(config-route-map)# set local-preference 500 R7(config-route-map)# router bgp 67 R7(config-router)# neighbor 172.31.78.8 route-map LOCALPREF in
Now we need to clear the inbound BGP session with R8. Fortunately, we used the “neighbor soft-reconfiguration inbound” command so we can do a route refresh without having to tear down the BGP session and bring it back up:
R7# clear ip bgp 172.31.78.8 soft in
Let’s look at R7′s BGP table now:
R7# sh ip bgp | be Network Network Next Hop Metric LocPrf Weight Path *>i172.16.66.0/24 172.31.67.6 0 100 0 i *> 172.16.67.0/24 0.0.0.0 0 32768 i *> 172.16.88.0/24 172.31.78.8 0 500 0 88 i * 172.31.79.9 0 99 88 i *> 172.16.99.0/24 172.31.78.8 500 0 88 99 i * 172.31.79.9 0 0 99 i
Notice that the routes we have received from 172.31.78.8 now have a local preference value of 500 assigned to them. The preferred route to 172.16.99.0/24 is via 172.31.78.8 (R8 in AS 88), even though the AS Path is longer! How cool is that? If we run the same traceroute from R6 to R9 again, we’ll see that the traffic does, indeed, take this new, preferred path:
R6# traceroute 172.16.99.1 source 172.16.66.1 Type escape sequence to abort. Tracing the route to 172.16.99.1 1 172.31.67.7 8 msec 4 msec 4 msec 2 172.31.78.8 4 msec 12 msec 8 msec 3 172.31.89.9 4 msec * 28 msec