Our BGP class is coming up!  This class is for learners who are pursuing the CCIP track, or simply want to really master BGP.  I have been working through the slides, examples  and demos that we’ll use in class, and it is going to be excellent.  :) If you can’t make the live event, we are recording it, so it will be available as a class on demand, after the live event.    More information, can be found by clicking here.

One of the common questions that comes up is “Why does the router choose THAT route?

We all know, (or at least after reading the list below, we will know), that BGP uses the following order, to determine the “best” path.

bgp bestpath

So now for the question.   Take a look at the partial output of the show command below:

bgp bestpath

Regarding the network, why did this router select the next hop route, over the one just below it?

Post your ideas, and we will have a drawing next week, before the BGP class begins.   We’ll give 1 lucky winner some rack tokens for our preferred rack vendor, Graded Labs.   Everyone who comments, will be entered into the drawing.  I will update the post with the lucky winner.

Thanks for your ideas, and happy learning.

Thank you to all who responded.  eBGP is preferred over iBGP, and that is what it came down to.

The winner of the graded labs tokens is Jon!  Congratulations.

You can leave a response, or trackback from your own site.

82 Responses to “Riddle me this BGP man…”

  1. Malick Ndiaye says:

    because of local pref

  2. Brian says:

    eBGP, having a lower administrative distance, is preferred over iBGP.

    • AD for eBGP is 20, and iBGP is 200, that is true. But the reason for the BGP preference between the two was that eBGP are preferred over iBGP for the best path selection process. After the router decides the best BGP route, it then may go into the global routing table if there is no other route or the AD for BGP is better than a competing protocol, such as EIGRP or RIP.

      Thanks for your post!

  3. Dylan says:

    Hi All,

    the reason why the router choose as the next-hop is because the first 5 rules are tie the only different is that 1 route is from eBGP 1 is from iBGP and the next-hop is learn via IBGP, therefore the rule EBGP route over IBGP route is enforced.

    To think about it logically, IBGP AD is 200 EBGP AD is 20, so the router will choose the lowest AD route to be in the routing table.

  4. Marco Rizzi says:

    Hi Keith,
    It prefers the path through because it’s an eBGP learned path, the other is iBGP learned, as the “i” on left side.
    Local preference is not set for the first entry, so the default value of 100 is assumed, preventing local preference to be the tie breaker.


  5. Aryan says:

    Next-hop not reachable ?

  6. mustang7071 says:

    Route learnt from eBGP neighbor; beats the “i” route on AD?

    • mustang7071 – The eBGP route beats the iBGP routes in the best selection process. It also is true that eBGP is AD 20 and iBGP is 200 regarding getting the best BGP route into the global routing table.

      Thanks for posting.

  7. Mat says:

    the route towards is learned through an eBGP neighbor, while the other route is learned through an iBGP neighbor, the route through the eBGP neighbor is always prefered.
    All previous step are a tie, including MED, since by default the router will allocate the lowest MED (0) to routes that do not have the MED attribute.


  8. Peter says:

    Just one note to the path selection steps. Isn’t there at least two steps missing?

    0. Don’t consider routes if next-hop unreachable
    1. Synchronization rule
    2. Weight …

    At the end of the list one rule is missing imho. One that is used for redundant BGP sessions between two routers on two separate interfaces (two sessions, one for every link). In this scenario last rule is not enough on the slides and router will choose a route from session to lower neighbor IP address. So lower neighbor IP address can be imho added to the end of the list.

    If you think otherwise (one can always be wrong), respond.

    • Peter -

      In the original table, in the post, the first two items were the next hop, and weight, in that order and you are right, those are the first two.

      The synchronization rule, if enabled, would apply equally to these two routes.

      Near the end of the list, it also mentions the oldest route, router-id, etc.

      Thanks for your post.

  9. Youssef says:

    Hello Keith, the router selected because it is an eBGP learned route, preferred over iBGP.

  10. CK1976 says:

    The was selected because judging from the status code, the route was learned via eBGP vs iBGP learned routes. It looks like it would have been local preference but that is a default of 100 anyways.

  11. Dan says:

    It chooses as next hop because it’s an EBGP learned route.

  12. Jon says:

    R6 receives 2 routes for the prefix ( and prefers the route that is learnt via the EBGP peer over the IBGP neighbor.

    R6 learnt this prefix ( via 2 paths. One is via the EBGP peer which is directly connected and its next hop ip address of and another path via the IBGP neighbor with the next-hop address of that is the IP address of the EBGP Peer that peers between R6′s IBGP neighbor and its EBGP Peer (Assuming there are only 2 routers in the same AS, i.e. R6 and Rx)

    In Summary, here is the topology,
    Assume R6 and its IBGP neighbor(Rx) are located in AS20.

                         R6 (AS 20) ---- IBGP ---- Rx (AS 20)
                              |                                    |
                              |                                    |
                          EBGP                                 EBGP
                              |                                    |
                              |                                    |
                          (AS 89)                               (AS 11)
                              \                                   /
                               \                                 /
                              EBGP                          EBGP
                                  \                             /
                                   \                          /
                               (AS 22) - Orignates
  13. manibvr says:

    Please correct me , if i am wrong, just started preparing for ccie (r&s)

    Answer : received paths across AS prepended and only
    advertised the best paths to R6

  14. manibvr says:

    regex ^ a filter is used to select the routes locally
    advertised in this AS

  15. MaulaJutt420 says:

    By default local-preference for any AS is 100 and wouldn’t show in “show ip bgp” output, only moddified local-preferences will show.

    Default local-preference for this AS has been changed to 100+ which isn’t showing in “show ip bgp” output and that is why router selected next hop route, over

    I want my rack tokens, YES NOW :p

    • MaulaJutt420 -

      Great thought. If we did a show ip BGP for this specific route, it would show a value of 100 for local preference for both prefixes. I like your thinking though. We could have changed the default value.

      Thanks for the post.

  16. Walter Gibbons says:

    Because the router doesn’t know how to get to the next hop

  17. Sokabi Moses says:

    BGP neighbour type…EBGP routes preferred over IBGP routes.

    The Next hop address is an EBGP Neighbour.

  18. Adrian says:

    It will chose the lowest AD of 20, the IGP learned route will have a metric of 200.

    • The BGP bestpath process chooses eBGP over iBGP, because they wrote it that way. Once we choose the best BGP route, it then may make it into the global routing table if there is no other route that matches, or if there is a conflict if the BGP AD is better (lower) than the competing route.

      Thanks for the post.

  19. Iman Mansouri says:

    As I guess, according to the information one route is received via iBGP peer and the other is via eBGP peer. As can be seen from the output the both have same attributes ( weight, Local Pref(100), As-Path lenght, Origin and MED).
    So the next attribute to compare will, Preferring eBGP learned path via iBGP. So the route via next-hop will be chosen …

  20. David Meier says:

    I would have to take a stab at the global configuration contains a line such as ‘bgp default local-preference ‘ where value is higher than 100 (which is the default). In this situation since the next hop of would look less preferable.

    That’s my guess Keith and I’m signed up for the class next week, but not sure how much I’ll be able to attend live. Looking forward to it!

  21. memphis003 says:

    At glance router is configured with “bgp default local-preference 100″ and bestpath is selected based on EBGP learned route over iBGP.

  22. Will says:

    The route for with next hop was chosen because it was learned via External BGP. The other route has a higher Local_Pref, but Local_Pref is only used with Internal BGP learned routes. So that part of the best path process was skipped. If both routes where Internal BGP learned then the outcome may have been different.

    • Will -

      Thanks for the post! If we looked at the detail for this route, we would see that both entries have 100 as a local preference. If these were both eBGP or both iBGP, it would have come down to the smallest IGP metric to the next hop to decide the best route.

  23. Khaleel says: is EBGP route

  24. Serg says:

    eBGP is preferred over iBGP with being an eBGP peer.

  25. NET_OG says:

    I think the winning route was learned from an eBGP peer.

    Have fun teaching the BGP course.

  26. Yasir Ashfaque says:

    lowest IGP metric to the BGP next hop

  27. bdk says:

    Local prefs are identical (short of one being set via a route-map or something means to ’100′). The path selection stops at Cisco’s step #10 ‘Received First’ (Oldest route).

    More BGP Riddles/Stumpers please!



  28. Renan says:

    Hi Keith,

    Can you please post the R6# show ip bgp ouput to display the detailed result as opposed to the one you shown.

    • Hello Renan -

      Great question. The local preference is set to 100 for both of the routes. That would be good information to know, as well as if the global routing table could reach both of the next hops.

      Thanks for the post.

  29. Ahmed Harras says:

    Because this route is an EBGP route while the second route is an iBGP route. This is the tie breaker here.

  30. Somit Maloo says:

    Point 1 – Path is internal
    Point 2 – Synchronization is enabled
    Point 3 – Route not in the IGP
    Result of above 3 points = Do not consider the route as best path.

    I may be wrong though. Waiting for others to reply:)

  31. Sam says:

    I think, eBGP is preferred over iBGP path, hence best path for is via

    May be the topology will be;

    R6 ——ebgp——router(AS 89)—-ebgp—–router(AS 22)
    ! !
    ibgp !
    ! !
    R3——-ebgp——-router(AS 11)—-ebgp——-!

    here R3 is configured with next-hop-self command.

  32. Karsten says:

    As the Local Preference is only shown for non-default values, and the second entry shows “100″, the default is changed on this router to something better (higher).

  33. bdk says:

    I take back what I said earlier…

    The route from is an externally learned BGP route and therefore has a lower AD then the internally learned route.


  34. Nendy Hernandez says:

    eBGP is preferred over iBGP learned routes

  35. Melvin Reyes says:

    BGP choose the next-hop for the network because eBGP is preferred over iBGP. I mean bgp run the algorithm top down until match occurs, in this case the match was in “eBGP learned routes over iBGP learned routes”

  36. Amit says:

    Hi Keith,

    In this case, eBGP learned route is preferred over iBGP learned route.

  37. Karsten says:

    Additionally to the higher default-local-preference there could be another reason: Also if the default-LocPref is set to a value less then 100, the route could be preferred because of a pre-bestpath POI.

  38. Eugene Khabarov says:

    1) may be inaccessible
    2) R6 have bgp default local-preference command set to value, higher than 100 and first prifix is advertised with local-preference=R6 default local-preference

  39. Bob says:

    Having obvious lo0 loopbacks (that you have here) makes it easier, but I would say that it’s because EBGP peer better than IBGP learned routes.

  40. Prasad says:

    Both the networks have the local preference of 100 ( As default value is 100). The network is selected because it is the external learned network. (Prefer eBGP over iBGP paths).

  41. nodo says:

    Because route is EBGP-learned and second is IBGP learned,

  42. czarny says:

    Router select the next hop route because he prefer EBGP learned routes over iBGP

  43. Stojanco says:

    The IGP cost for is lower then IGP cost to

  44. Leonardo says:

    The first route is an EBGP learned router, whereas the second one is IBGP learned. EBGP routes are preferred than IBGP routes.

  45. fitri says:

    Probably because of the next hop to is not reachable …

  46. the ebgp path is selected over ibgp path because ebgp path has better loop prevension mechanism through as-path attribute. So is selected as next-hop for route in question.

  47. segzyinc says:

    The next-hop is selected bcos:
    1) the next hop is reachable, which is the very first rule in bgp path selection, and R6 is a direct neighbor of the router advertising the route from AS89 which as a result the next-hop changes to the edge router advertising it to R6 and can be reachable otherwise they would not peer in the first place.
    2) the route from the next hop is an ibgp route from the “i” status code on the left and it as being modified bcos the in ibgp world the as-path,local-pref, next-hop don’t change unless modified, as a result of that we can see from the output that the local-pref was modified which strongly suggest that it is an ibgp route and the next-hop is unreachable bcos ibgp routers dont modify their next-hop which should be done on the edge router advertising the route into ibgp network but is not changed.
    3) i would have said ebgp is selected before ibgp but before we get to that rule local-pref is considered, which i dont think there is a way of skipping the local-pref rule before getting to ebgp routes to be selected before ibgp routes unlike in as-path you can use bgp bestpath as-path ignore.
    i hope i am right

  48. Adonys Cruz says:

    The tie breaker is “eBGP learned routes over iBGP learned routes”, regardless of the fact that eBGP defaults to a lower AD compared to iBGP.

  49. Fragilemohi says:

    the network is advertised with network statement …that for sure ..and as if it is and edge router learning the route from IBGP AND EBGP neighbor..boz by default local preference is 100 for iBGP as of best path selection list… has lower AD 20 … so it selected based on that as a preferred path ( eBGp prefrence over i bgp) …

  50. Manjunath J says:

    Becoz the routes learned via is through iBGP session, bgp prefers eBGP over iBGP.

  51. johnpgonz says: /24 was EBGP learned by next hop and iBGP learned by EBGP routes are preferred over iBGP.

  52. Rodney Treadvance says:

    The second route shows as an IGP route, and the first route is next hop away which is directly connected, next hop is higher in the bgp bestpath selection process

  53. Laolu Sijuwola says:

    The chosen best route (with a next-hop of was learnt from EBGP peer, and in BGP route selection process, routes learnt via EBGP peers are preferred to routes learnt via IBGP. This essentially breaks the tie in this case.

  54. Neil says:

    eBGP routes preferred to iBGP routes

  55. Hemanth Raj says:

    R6 chooses as a next hop for network instead of network because of 2 reasons

    1) is not reachable is not present in routing table
    2) due to synchronisation rule, cannot be used

    Eventhough is having a higher local preference than network ,before local preference is validated, the next hop and synchronisation rule is first checked and then after local preference then it will check for locally originated or external route

  56. is an external BGP neighbor which is preferred over the internal BGP neighbor

  57. Sarathlal says:

    Since, is an EBGP nei, it is prefered over the IBGP nei

  58. Somit Maloo says:

    We will reach the “ebgp vs ibgp comparison” step in the BGP best path selection, only when we clear the initial synchronization step i.e. “If the path is internal, synchronization is enabled, and the route is not in the IGP, do not consider the route. ”

    Can the topology be shared and the global routing table too.

  59. Eugene Khabarov says:

    Hi, we really need to know what default values is used next time. Riddle was easier than I (and not only) expected. Woe from Wit.

  60. MO says:

    Lowest AD is considered after the longest prefix :)

  61. Mohamed says:

    Looking at this, it is preferred the oldest router


Leave a Reply


CCIE Bloggers