Consider this simple topology and let's get started.
To understand as path-prepend we must first understand how BGP selects a path using the path selection algorithm. I will not go into the whole list but the first few are:
- Is the next-hop reachable?
- Highest weight *Cisco proprietary* - Although many vendors are implementing it
- Prefer the path with the highest local preference (preference is only internal and does not get sent to eBGP neighbors)
- Prefer the path with the shortest AS PATH
Prefer the shortest AS PATH is the basis behind as path-prepend. Since the shortest as path will be preferred the idea is to prepend your own AS to the less preferred ISP before advertising the route (NLRI). Note that the AS PATH is a well known mandatory PA (Path Attribute) meaning it needs to be supported by all implementation for BGP and this PA should be advertised to all other neighbors.
Now that you have a basic understanding let's see it in action.
First let's get the basic interface settings configured.
Second let's get the BGP configured. Note that in this 2 ISP setup I am not configuring any filtering (incoming or outgoing) however it is good practice to do so.
Now let's see how can use as path-prepend to always prefer the 100meg ATT connection for incoming traffic.
- Create an access-list to match 18.104.22.168/24. You can also create a prefix list.
- Create a route-map to match the access-list and set as path-prepend and prepend your own AS.
- Apply this route map to the existing peer (slow internet peer).
- Clear the bgp relationship using clear ip bgp 22.214.171.124.
Note that to ISPB now prefers to go over the ATT connection (ISPA) to get to 126.96.36.199/24 (advertised by R1) than the direct connection it has to R1. Reason being -- the shortest AS PATH (2,1) is only 2 hops away where as the direct connection lists 4 hops (AS) away (1, 1, 1, 1). So the shortest AS path route gets installed into the routing table.
Many more articles to come so stay tuned. If you like what you read please comment/like/+1/join this site --->changes