would a network select /24 or /23 path with ospf or with BGP which one is preferred !!

  • Did any answer help you? If so, you should accept the answer so that the question doesn't keep popping up forever, looking for an answer. Alternatively, you could provide and accept your own answer.
    – Ron Maupin
    Commented Apr 1, 2018 at 22:49

2 Answers 2


The route with the longest mask (/24) is always preferred regardless of how it’s learned. The protocol doesn’t matter.


Most specific match (longest subnet mask match) will win regardless of routing protocol. If the subnet masks are equal, the route with the lowest administrative distance wins. In this case eBGP routes (learned from routers in different BGP Autonomous Systems) have a lower AD than OSPF routes, which have a lower AD than iBGP routes (learned from routers in the same BGP AS).

Worth noting - if the /24 is inside the /23, the other half of the /23 route will be honored. In other words, if you have a route for pointing to and a route for pointing to, all traffic in will go to and all traffic in will go to

/24 beats /23 eBGP beats OSPF beats iBGP


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.