Hello. I'm running ospf from a router against two other routers on the same ethernet segment. Those two routers a both capable of routing given prefixes, but I prefer one of them to do the actual routing and use the other one as a backup router in case of emergencies. How can I set such a preference? I thought of using ospf_metric2, but it is supposed to work only when ospf_metric1 isn't set, which is (checked using show route all). For some reason the configuration does what I need, but I can't figure out why. Could anyone shed some light on this? thanks mk
Martin Kraus píše v Út 27. 10. 2009 v 19:21 +0100:
Hello. I'm running ospf from a router against two other routers on the same ethernet segment. Those two routers a both capable of routing given prefixes, but I prefer one of them to do the actual routing and use the other one as a backup router in case of emergencies. How can I set such a preference? I thought of using ospf_metric2, but it is supposed to work only when ospf_metric1 isn't set, which is (checked using show route all). For some reason the configuration does what I need, but I can't figure out why. Could anyone shed some light on this?
thanks mk
I think this is not feasible using OSPF. You could possibly split this one broadcast network to two nonbroadcast networks and then define different costs on each of them. David
On Tue, Oct 27, 2009 at 07:21:54PM +0100, Martin Kraus wrote:
Hello. I'm running ospf from a router against two other routers on the same ethernet segment. Those two routers a both capable of routing given prefixes, but I prefer one of them to do the actual routing and use the other one as a backup router in case of emergencies. How can I set such a preference? I thought of using ospf_metric2, but it is supposed to work only when ospf_metric1 isn't set, which is (checked using show route all). For some reason the configuration does what I need, but I can't figure out why. Could anyone shed some light on this?
I suppose that both routers propagate some external route and you want to set metric for that external route. For this purpose, you can use Type 1 metric (ospf_metric1) or Type 2 metric (ospf_metric2), both will work. Just set smaller value to more preferred router. If router receives both routes and both use Type 2 metric, then it compares just these metrics and uses the smaller one. If router receives both routes and both use Type 1 metric, then it compares these metrics icreased by IGP metric between both routers, which is the same value for both routes in your case. RFC 2328: Type 1 external metrics are expressed in the same units as OSPF interface cost (i.e., in terms of the link state metric). Type 2 external metrics are an order of magnitude larger; any Type 2 metric is considered greater than the cost of any path internal to the AS. -- Elen sila lumenn' omentielvo Ondrej 'SanTiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
On Tue, Oct 27, 2009 at 08:03:39PM +0100, Ondrej Zajicek wrote:
I suppose that both routers propagate some external route and you want to set metric for that external route.
For this purpose, you can use Type 1 metric (ospf_metric1) or Type 2 metric (ospf_metric2), both will work. Just set smaller value to more preferred router.
If router receives both routes and both use Type 2 metric, then it compares just these metrics and uses the smaller one. If router receives both routes and both use Type 1 metric, then it compares these metrics icreased by IGP metric between both routers, which is the same value for both routes in your case.
RFC 2328: Type 1 external metrics are expressed in the same units as OSPF interface cost (i.e., in terms of the link state metric). Type 2 external metrics are an order of magnitude larger; any Type 2 metric is considered greater than the cost of any path internal to the AS.
I'm still a bit confused. If both routes use type 2 then bird compares type 2. If both routes use type 1 then bird compares type 1. But if both contain type 2 as well as type 1, which of those two rules is used? Both routes have type 1 metric 100 and one of them has type 2 10000 and the other has 10500. Bird selects the first route with smaller type 2 metric, but it doesn't fit those two rules for selecting routes. Bird shows all routes from ospf, internal as well as external, as having type 1 metric which is equal to the sum of costs from this router to the destination. How can you configure a route to use only type 2 metric? If I have two external routes, first with type1 = 1 and type2 = 100 and the other one with type1 = 5 and type2 = 50 (as is show by show route all), which will be used? thanks mk
On Tue, Oct 27, 2009 at 08:31:25PM +0100, Martin Kraus wrote:
On Tue, Oct 27, 2009 at 08:03:39PM +0100, Ondrej Zajicek wrote:
I suppose that both routers propagate some external route and you want to set metric for that external route.
For this purpose, you can use Type 1 metric (ospf_metric1) or Type 2 metric (ospf_metric2), both will work. Just set smaller value to more preferred router.
If router receives both routes and both use Type 2 metric, then it compares just these metrics and uses the smaller one. If router receives both routes and both use Type 1 metric, then it compares these metrics icreased by IGP metric between both routers, which is the same value for both routes in your case.
RFC 2328: Type 1 external metrics are expressed in the same units as OSPF interface cost (i.e., in terms of the link state metric). Type 2 external metrics are an order of magnitude larger; any Type 2 metric is considered greater than the cost of any path internal to the AS.
I'm still a bit confused. If both routes use type 2 then bird compares type 2. If both routes use type 1 then bird compares type 1. But if both contain type 2 as well as type 1, which of those two rules is used?
If external route has defined valid ospf_metric2 metric, it is Type 2 external route (flag E2 in 'show route'), if not, it is Type 1 external route (flag E1 in 'show route'). Replace 'use Type X metric' with 'is a Type X external route' in mentioned rules. Field ospf_metric1 is defined in all OSPF route types and contains contains IGP metric (+ possibly initial value of Type 1 metric for type 1 external routes)
Both routes have type 1 metric 100 and one of them has type 2 10000 and the other has 10500. .. If I have two external routes, first with type1 = 1 and type2 = 100 and the other one with type1 = 5 and type2 = 50 (as is show by show route all), which will be used?
In both cases they are Type 2 external routes and are compared according to ospf_metric2. -- Elen sila lumenn' omentielvo Ondrej 'SanTiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
On Tue, Oct 27, 2009 at 09:17:23PM +0100, Ondrej Zajicek wrote:
If external route has defined valid ospf_metric2 metric, it is Type 2 external route (flag E2 in 'show route'), if not, it is Type 1 external route (flag E1 in 'show route'). Replace 'use Type X metric' with 'is a Type X external route' in mentioned rules.
Field ospf_metric1 is defined in all OSPF route types and contains contains IGP metric (+ possibly initial value of Type 1 metric for type 1 external routes)
Both routes have type 1 metric 100 and one of them has type 2 10000 and the other has 10500. .. If I have two external routes, first with type1 = 1 and type2 = 100 and the other one with type1 = 5 and type2 = 50 (as is show by show route all), which will be used?
In both cases they are Type 2 external routes and are compared according to ospf_metric2.
Thanks for the explanation. So if I've got two E2 routes with the same type 2 metric to the same destination several hops away from a given router to which there are two ways, it doesn't mean the shorter way will be used based on type 1 metric. One (hopefuly) final question. How does bird determine what route to designate as E1? All I've got from bird are either E2 or Internal routes. thanks again mk
On Tue, Oct 27, 2009 at 10:00:07PM +0100, Martin Kraus wrote:
In both cases they are Type 2 external routes and are compared according to ospf_metric2.
Thanks for the explanation. So if I've got two E2 routes with the same type 2 metric to the same destination several hops away from a given router to which there are two ways, it doesn't mean the shorter way will be used based on type 1 metric.
Really, in the case of a tie, shorter way will be used. I omitted this case for simplicity. There is a simple explanation: consider there is just one metric, which is a triple (K, M2, M1), where K is a kind of a route (0 for I, 1 for E1, 2 for E2), M2 is ospf_metric2 for E2, zero for others and M1 is ospf_metric1. Then the route with smaller triple is preferred (the triples are lexicographically ordered).
One (hopefuly) final question. How does bird determine what route to designate as E1? All I've got from bird are either E2 or Internal routes.
If external route is exported to OSPF, you can set ospf_metric1 or ospf_metric2 using filters. If just ospf_metric1 is set, route becomes E1. If just ospf_metric2 is set, route becomes E2. If nothing is set, E2 with ospf_metric2 = 10000 is the default. If both are set (uninteresting corner case), ospf_metric2 is ignored. -- Elen sila lumenn' omentielvo Ondrej 'SanTiago' Zajicek (email: santiago@crfreenet.org) OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net) "To err is human -- to blame it on a computer is even more so."
On Tue, Oct 27, 2009 at 11:09:46PM +0100, Ondrej Zajicek wrote:
Really, in the case of a tie, shorter way will be used. I omitted this case for simplicity.
There is a simple explanation: consider there is just one metric, which is a triple (K, M2, M1), where K is a kind of a route (0 for I, 1 for E1, 2 for E2), M2 is ospf_metric2 for E2, zero for others and M1 is ospf_metric1. Then the route with smaller triple is preferred (the triples are lexicographically ordered).
One (hopefuly) final question. How does bird determine what route to designate as E1? All I've got from bird are either E2 or Internal routes.
If external route is exported to OSPF, you can set ospf_metric1 or ospf_metric2 using filters.
If just ospf_metric1 is set, route becomes E1. If just ospf_metric2 is set, route becomes E2. If nothing is set, E2 with ospf_metric2 = 10000 is the default. If both are set (uninteresting corner case), ospf_metric2 is ignored.
Great. Now it makes sense to me. I've read through the various documentation, even rfc(log time ago), but it never made much sense and I've never needed to know how the metrics really work until now. thanks for the clarification mk
participants (3)
-
David Rohleder -
Martin Kraus -
Ondrej Zajicek