would a network select /24 or /23 path with ospf or with BGP which one is preferred !!
2 Answers
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 1.1.0.0/23 pointing to 192.168.1.1 and a route for 1.1.0.0/24 pointing to 192.168.1.2, all traffic in 1.1.0.0/24 will go to 192.168.1.2 and all traffic in 1.1.1.0/24 will go to 192.168.1.1
/24 beats /23 eBGP beats OSPF beats iBGP