04-19-2017 11:42 PM - edited 03-05-2019 08:23 AM
Hi,
i just want to clarify how will internet react on my prefix, let's say, i have two upstream, i advertised my /19 to it and advertised /24's on the 2nd, and the internet can reach me via:
upstream 1 with shorter AS path and with shorter prefix (/19)
upstream 2 with longer AS path and longer prefix (the /24's)
how will the internet or other BGP reach me? via shortest AS path or via most specific routes? its very confusing to that when you said BGP it is always shortest AS path when forwarding packets.
Solved! Go to Solution.
04-20-2017 07:01 AM
When it comes to routing the most specific prefix is always the first consideration before anything else and that is the same for all routing protocols.
It is only if you get multiple routes for the same length prefix that further decisions have to be made.
Firstly if the routes are received from different routing protocols then the AD of the routing protocol is used to select the best path. If you still end up with multiple routes within the same routing protocol then it comes down to that routing protocols algorithm for selecting the best route (or routes with IGPs).
With BGP that algorithm is quite complicated and the length of the AS path is only one of the factors taken into account so it is not always the AS path length that determines which route to use.
Jon
04-20-2017 12:19 AM
/24's will be preferred over a /19.
04-22-2017 06:37 AM
My knowledge of BGP is limited, so correct me if I am wrong but this is what I noticed when advertising routes in BGP. Lets say you have a static route to destination 1.2.3.0/25 via 2.2.2.2 and if you want to advertise this prefix in BGP it has be exact or it won't advertise (basically route advertisements has to mimic exactly your routing table). So if you are advertising 1.2.3.0/24 instead of 1.2.3.0/25 it won't be advertised in BGP even though it will take network command, but you won't actually find out unless you debug BGP at the time of issuing network statement, actually it won't give you any error while debugging but you will see that it didn't advertise the network. Question unrealted to this, is it possible to prepend a specifc prefix in BGP and without affecting other route advertisements?
04-22-2017 01:11 PM
Yes it is possible to prepend just a single prefix using a prefix list and a route-map.
04-22-2017 05:01 PM
Can you show with an example how would you do that? I tried using prefix list and route map in a lab environment but it stops advertisement of networks that are not listed in the prefix list. Basically I am using longer and smaller prefix for BGP route preference and it works fine, but there is one prefix lets say 1.1.1.0/25 where I can't advertise 1.1.1.0/24 because 1.1.1.128/25 is used by another site and upstream ISP router gets confused. please let me know what is it that I am doing wrong.
This is the configuration I used on the secondary router:
ip prefix-list bgp permit 1.1.1.0/25
!
route-map test permit 10
match ip address prefix-list bgp
set as-path prepend 123 123 123
!
router bgp 123
neighbor x.x.x.x route-map test out
04-22-2017 05:46 PM
A route-map has an implicit deny at the end. Add an extra route-map "permit" to allow everything else.
route-map test permit 20
04-22-2017 05:46 PM
That should have been so obvious and it didn't cross my mind. I am sure with this additional config. it will work the way I want it too. Thanks for your help.
04-22-2017 05:48 PM
Just tried that and it works fine. I was trying to mark your answer correct, but I guess you can only do that once on each thread. I owe you one. Thanks again for your help!
04-22-2017 05:53 PM
You're welcome.
04-20-2017 07:01 AM
When it comes to routing the most specific prefix is always the first consideration before anything else and that is the same for all routing protocols.
It is only if you get multiple routes for the same length prefix that further decisions have to be made.
Firstly if the routes are received from different routing protocols then the AD of the routing protocol is used to select the best path. If you still end up with multiple routes within the same routing protocol then it comes down to that routing protocols algorithm for selecting the best route (or routes with IGPs).
With BGP that algorithm is quite complicated and the length of the AS path is only one of the factors taken into account so it is not always the AS path length that determines which route to use.
Jon
04-20-2017 07:50 AM
As both Philip and Jon have noted, by default, shortest prefix should be used.
However, as part of the complexity of BGP algorithm (as noted by Jon), BGP supports many ways to override its route preference behavior. So, what one might expect to happen, might not happen, unless you're aware of all BGP policies end-to-end.
04-20-2017 07:52 AM
Longest prefix will be used :)
Jon
04-20-2017 10:29 AM
Suppose you had a filter to drop the /24, but kept the /19, then what would be used?
I know, the /19 would now be the longest prefix, but with BGP, you can easily do things like this. So, just because you advertise both the /19 and /24 doesn't guarantee traffic will use the /24 to send traffic to you. (Again, such is unlikely, but you really don't know unless you know what's actually being done, end-to-end, with BGP. I.e. Probably there's a 99.999%, or better, chance that longest prefix will be used, as noted by Jon and Philip, but it's not 100% guaranteed.)
04-21-2017 03:38 AM
-
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide