I've been looking at BGP recently and i've been confused a little by route prioritization when using a multi-homed ISP.
Here's the scenario, lets say I have a router with a primary and backup route to the Internet. I would like the traffic being forwarded to my router to always use the primary line. I've read Cisco docs that say I can use the set as-path prepend <as number> command when setting the BGP neighbor, this should be placed on the backup line to set a preference for the primary link. Can anyone expand on how this works in practice, in regards to how the message is propagated through to the other ISP routers. Or point me towards some documents that could clear this up for me? Would both the primary and backup links have to be using the same AS number for this to work?
Also while we're at it are there any alternative solutions to the above problem without using path prepending?
Any help appreciated.
BGP advertises routes by a concatenation of AS Numbers
So say you are AS 1 you pass the route to the next AS. The AS passes the route on but adds its own AS so people know how to get to your route.
So if we are sitting at the other side of the Internet we receive a route 100.150.200/24 1:2:3:4:5 so we goto to AS 5 then 4 etc
The backup circuit inserts its own AS a couple of times so when it arrives at the other end 1:1:1:2:3:4:5.
The remote router will always select the shortest AS path 1:2:3:4:5 rather than 1:1:1:2:3:4:5.
When the primary route fails it is removed from BGP and 1:1:2:3:4:5 is chosen
The remote packet arrives at 1 and realises does not need to go to 1: 1.
This process is called pre-pending.
If you have only one router then obviously the same AS. If you have two routers I have seen both views.
Jamie, Conwyn provided a good explanation of pre-pending. AS_PATH is an ordered list of AS vectors which show the path to the NLRI(aka, IP Prefix), which the BGP update relates to. The more AS #s in an AS_PATH, the less preferred the route. You have to take into account the entire BGP path selection process, but as far as AS_PATH is concerned, shorter is better. Path prepending is a straight forward way to increase the "cost" of a route.
As far as accomplishing this without pre-pending, you would need to work out an agreement with your carrier to use MED or perhaps communities to indicate preferred inbound paths.
It was demonstrating a concept not the contents of the AS_PATH vector. I am sure you be pretty lucky to have a sequence of AS numbers 1 2 3 4 5 in reality. As Travis said there is a whole range of methods you can use but I followed the title of the posting.
Not really. In reality as it passes through each AS the AS is prepend so when it arrives at the other end the first AS in the AS_PATH is the nearest node to the destination so the destination takes the first AS and the packet sets off and each time the AS removes the first entry. It has to do it this way otherwise it would need to know the length of the AS_Path to work out the next entry so the order set is 1 2 3 4 5 but is physically stored within the AS_PATH as 5 4 3 2 1.
Prepending your ASN is well and good, but keep in mind what you are trying to do at that point in influence SOMEONE ELSE's decision on how to get back to you. It has nothing to do with the path you will choose, so hope that's separated in your intent ok!
AS path is always "nearest" ---- "farthest" when reading left to right. The "?" you talk about is the origin code though, not as ASN. That means "unknown" or "incomplete". In the Cisco world that generally means the route was redistributed. A network command would give an "i" for the origin code.
From what I have learned that the as-path prepending method is trying/intended to influence incoming traffic towards your AS,
However I have seen in contrary implementation where this method is used to affect the outbound route-selection.
Let say if I put the route-map on inbound direction and set as-path prepend instead I use local-pref or weight instead.
Maybe the implementor had a thought to have a similar method influencing inbound and outbound traffic
or maybe he also wanted the AS below hub site get this kind of affection too since multiple AS are exist
Appreciate input from expert
You're going to want to use community strings if you can. Check with your ISP.
I have implemented as-path prepending in a multi homed bgp environment in an attempt to influence incoming traffic; it didn't work well at all. I had circuits from 2 ISPs one was 3Mbps and the other 20Mbps. Obviously the smaller was easily flooded and I wanted to use it only as a backup. I set the prepending, the prepending could be seen when I checked the path to my AS on the Internet; but the circuit still flooded. The ISP for the smaller link was AT&T and they had a community string that I used to prevent incoming traffic; it worked great. I wish I would have listened to the engineer who tried to warn me away from prepending to influence inbound; it would have saved me a few days of headaches.
Thanks for the replies everyone, I was indeed only referring to affecting inbound traffic.
Kristy - Did you ever find the reason why the prepend didnt work as it should? I thought that bgp essentially used AS hop count as its metric so I can't see how the prepend could be ineffective. Maybe I should be looking to use community strings instead.