10-11-2012 12:21 AM - edited 03-04-2019 05:49 PM
Hi all,
I have router(HUB) and have two connection to branch(Spoke). 1 connection running over BGP and another running over OSPF. Now I would like to Load Balance between this two connection, in another word LB between OSPF and BGP
BGP distance - 20
OSPF distance - 110
I have changed OSPF distance to 20, but it still prefers BGP over OSPF. Does the router will count COST if the distance (AD) is same ?
I saw my BGP cost is 0, while my OSPF cost is 100. Is it by modifiying OSPF cost to 0 will achieve the goal?
Regards,
Nagis
10-11-2012 12:48 AM
Hi,
1) a router won't do load-balancing but load-sharing and it is the switching process which is responsible of that:
in case of CEF which is default it will do per src-dst IP pair load-sharing.
2) distance is only used when receiving same prefix/prefix-length by 2 different routing protocols or sources and the one with a higher AD will get installed in the Routing table. It can't be used for load-sharing because:
3) it can only be done for 2 prefixes of same longest match coming from the same protocol/source and in that case
the metric must be the same.
Regards.
Alain
Don't forget to rate helpful posts.
10-11-2012 01:09 AM
Hello Nagis,
changing AD should be the last method to be used, but in your case may be useful
>>I have changed OSPF distance to 20, but it still prefers BGP over OSPF. Does the router will count COST if the distance (AD) is same ?
BGP and OSPF will propose two routes one with (BGP) [20 0] and the other one with [20 100] (OSPF) at this point BGP route is preferred.
>>I saw my BGP cost is 0, while my OSPF cost is 100. Is it by modifiying OSPF cost to 0 will achieve the goal?
You cannot make the OSPF cost to be zero, but you may be able to set BGP metric to 100 on the remote end you need a route-map to set BGP metric ( MED)
example route-map SET-MED permit 10
set metric 100
router bgp XXXX
neigh y.y.y.y route-map SET-MED out
WARNING: this method works if the eBGP session is direct. if you are using an MPLS L3 VPN service your devices have a BGP session that is not direct end-to-end, but to the nearest colocated SP PE node. IF this is the case I'm not sure that you will be able to see a modified BGP metric on the router as MED cannot be passed between three ASes.
If this is the case you may be able to set the metric inbound (to be tested not all route-map combinations are allowed)
same route-map as above
router bgp xxxx
neigh z.z.z.z route-map SET-MED in
IOS can give an error if setting the MED inbound is not allowed.
A totally different approach could be used, that is to use a GRE p2p tunnel to run on the link with the BGP session and to run OSPF over it. the BGP session should be used only to advertise GRE endpoints.
The OSPF will be used to advertise remote subnets.
In this way you could make the comparison between two OSPF routes without changing AD,
Hope to help
Giuseppe
10-11-2012 01:34 AM
Hi Giuseppe,
Thanks. Anyway after i modified OSPF distance to 20, the AD for that specific route will be same for OSPF & BGP learned route. In this case, since AD is same, why router not LoadBalancing/Load Sharing it?
Is it because router now comparing COST after the AD is same for both route? Even if its running over 2 different routing protocol?
Regards,
Nagis
10-11-2012 02:28 AM
Hello Nagis, Alain,
the IP routing table is maintained by a process that receives from each routing protocol candidate routes.
Each routing protocol proposed its own best route.
Changing the AD of the OSPF routes to 20 like eBGP with a manual setting we make OSPF routes comparable to eBGP routes.
At this point the comparison goes a step further and the metric should be compared.
The eBGP route as noted by Nagis has metric 0, the OSPF route has metric 100 as a result of this only the BGP route is installed and used in the IP routing table.
The OSPF metric cannot be set to 0, because the way OSPF cost is calculated as cumulative cost of links with minimal link cost 1.
The only way to make the two routes comparable is to make the eBGP route metric to be 100.
If this happens the router should install both the OSPF and the eBGP routes and load balancing should occur.
However, this is a tricky solution, that as Alain has noted, should be tested.
So this a suggestion for a test to be performed by Nagis.
Nagis if you can test this and report results it would be very interesting.
Alain:
>> I thought the metric was used when both longest matches were coming from the same protocol, is it wrong ?
Making the AD the same should make the metric comparable as this is what we are asking to the router.
With default settings metric of routes proposed by different routing protocols are never compared as AD is different.
Hope to help
Giuseppe
10-11-2012 01:54 AM
Hi Giuseppe,
how can the router compare 2 different metrics ? I thought the metric was used when both longest matches were coming from the same protocol, is it wrong ?
Regards.
Alain
Don't forget to rate helpful posts.
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