Prepending ASNs to the AS Path

Problem

You want to increase the length of an AS Path so that one inbound path looks better than another.

Solution

In situations when you have multiple connections between ASs, you will often want to make remote networks prefer one inbound path when sending packets to your network. The easiest way to do this is to prepend your own ASN to the AS PATH several times, instead of just once, as it would do by default:

Router1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router1(config)#ip as-path access-list 15 permit ^$
Router1(config)#route-map PREPEND permit 10
Router1(config-route-map)#match as-path 15
Router1(config-route-map)#set as-path prepend 65500 65500 65500
Router1(config-route-map)#exit 
Router1(config)#route-map PREPEND permit 20
Router1(config-route-map)#exit 
Router1(config)#router bgp 65500
Router1(config-router)#neighbor 192.168.1.5 remote-as 65510
Router1(config-router)#neighbor 192.168.1.5 route-map PREPEND out
Router1(config-router)#exit
Router1(config)#end
Router1#

This example uses the same network shown in Figure 9-2, earlier in this chapter.

Discussion

We have already discussed methods for making your outbound traffic prefer one path over another in Recipe 9.7. But, as we mentioned in that recipe, that only affects your outbound path. If you also want to ensure that inbound traffic prefers one path over another, then you have to somehow trick the remote networks into believing that one path is better than ...

Get Cisco IOS Cookbook, 2nd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.