all things packets and internetworks
BGP Influencing Inbound Routing – AS Path
One of the items to remember with BGP is setting outbound attributes will influence inbound traffic. For instance, if you want the traffic into your AS to enter a specific router, you can do accomplish this by setting an outbound attribute. In this post I’ll do AP Path manipulation example.
AS Path is a well known mandatory BGP attribute and is included in all BGP updates. In BGP’s best path selection, it is the 5th attribute compared and is treated like a hop count. The lower the number of AS paths in the list, the more preferred the path.
The following topology will be used.

Each router has a loopback in the format of 100.x.x.x where x.x.x = the routerID. All of the loopbacks are installed into BGP. Looking at R4 the networks from R1, R2 and R3 are installed.
R4#show ip bgp | b Network Network Next Hop Metric LocPrf Weight Path * 100.1.1.1/32 10.1.34.3 0 100 i *> 10.1.14.1 0 0 100 i * 100.2.2.2/32 10.1.14.1 0 100 i *> 10.1.34.3 0 100 i * 100.3.3.3/32 10.1.14.1 0 100 i *> 10.1.34.3 0 0 100 i *> 100.4.4.4/32 0.0.0.0 0 32768 i
Lets say all routes from even routers (R2) should come in to R1, and from odd routers (R1, R3) should come in R3 from R4. Lets use AS path to accomplish this.
If we want R4 to use R1 to get to even routes, we’ll AS prepend the local AS for even routes from R3. Therefore, the path to R1 will have a shorter AS path (or hop count) and will prefer this path. For the odd router routes we just reverse the logic.
Let’s try setting up the configuration for this.
**** R1 Configuration
R1(config)#ip prefix-list ODD_ROUTER_ROUTES seq 10 permit 100.1.1.1/32 R1(config)#ip prefix-list ODD_ROUTER_ROUTES seq 20 permit 100.3.3.3/32 R1(config)#route-map TO_R4_OUT per 10 R1(config-route-map)#match ip add prefix-list ODD_ROUTER_ROUTES R1(config-route-map)#set as-path prepend 100 100 100 R1(config-route-map)#route-map TO_R4_OUT per 100 R1(config-route-map)#router bgp 100 R1(config-router)#neighbor 10.1.14.4 route-map TO_R4_OUT out
***** R3 Configuration
R3(config)#ip prefix-list EVEN_ROUTER_ROUTES per 100.2.2.2/32 R3(config)#route-map TO_R4_OUT per 10 R3(config-route-map)#match ip address prefix-list EVEN_ROUTER_ROUTES R3(config-route-map)#set as-path prepend 100 100 100 R3(config-route-map)#route-map TO_R4_OUT per 100 R3(config)#router bgp 100 R3(config-router)#neighbor 10.1.34.4 route-map TO_R4_OUT out
Check the results.
R4#show ip bgp | b Network Network Next Hop Metric LocPrf Weight Path *> 100.1.1.1/32 10.1.34.3 0 100 i * 10.1.14.1 0 0 100 100 100 100 i *> 100.2.2.2/32 10.1.14.1 0 100 i * 10.1.34.3 0 100 100 100 100 i * 100.3.3.3/32 10.1.14.1 0 100 100 100 100 i *> 10.1.34.3 0 0 100 i *> 100.4.4.4/32 0.0.0.0 0 32768 i
All is working as expected. The even router routes prefer the next hop of 10.1.14.1 and the odd one prefer 10.1.34.3. The paths can be verified with the traceroute command if desired.
| Print article | This entry was posted by packetpundit on May 6, 2011 at 8:05 pm, and is filed under Uncategorized. Follow any responses to this post through RSS 2.0. You can leave a response or trackback from your own site. |