Community discussions

MikroTik App
 
Byron
newbie
Topic Author
Posts: 32
Joined: Sun Jan 09, 2022 6:46 pm
Location: South Africa

[OSPF][iBGP] route filtering syntax help

Wed Jan 22, 2025 2:05 pm

Hi all,

ROS 7.17

refer to the beautiful paint drawing that I have attached.

Green - gateways
Black - backbone links
Red - backup backbone links
Blue - WAN Provider links
Yellow - Internet (Cloud)

How do I add cost to the backup backbone (Red) link so that when adjacency is formed, they will not be advertised? If I set the backup link into an ospf area, the routes from either side do not redistribute into one another. So basically I want the backup links to only advertise when it is active and the main links to their respective WANs drop.

For example, if a black link dies on either side, it must failover via the red link out to the opposite WAN/ Provider.

If I set it as a backbone area in OSPF this works but then all traffic uses a single provider (WAN) instead of their respective provider split as per the red link.

Help? my brain is tired.
You do not have the required permissions to view the files attached to this post.
Last edited by Byron on Wed Jan 29, 2025 2:05 pm, edited 3 times in total.
 
Byron
newbie
Topic Author
Posts: 32
Joined: Sun Jan 09, 2022 6:46 pm
Location: South Africa

Re: [OSPF] adding cost on backbone neighbor

Wed Jan 22, 2025 2:16 pm

As in attached on this post.

When red link is not setup in OSPF the traffic flows correctly as seen by the purple arrows.

When red link is setup in OSPF the traffic flows incorrectly as seen by the purple arrows.

Routes are then learned on the routing concentrator via one WAN link and has backups via the OTHER WAN link. I want it to show on the concentrator that routes are learned via the correct WAN and the respective backup link/ routes are learned via their respective WAN link.

If this makes sense. (left = correct but its not setup for failover via red link)
You do not have the required permissions to view the files attached to this post.
 
tdw
Forum Guru
Forum Guru
Posts: 2086
Joined: Sat May 05, 2018 11:55 am

Re: [OSPF] adding cost on backbone neighbor

Wed Jan 22, 2025 5:14 pm

How do I add cost to the backup backbone (Red) link so that when adjacency is formed, they will not be advertised? If I set the backup link into an ospf area, the routes from either side do not redistribute into one another. So basically I want the backup links to only advertise when it is active and the main links to their respective WANs drop.
OSPF does not work like that. Links are always advertised, the OSPF algorithm then determines the shortest path from all of the advertised links within an instance.

If the gateways with the external connections (those with blue links in your diagram) are set to redistribute default route if installed then the path cost from each of the other gateways is the sum of the intervening path costs, with the default cost of 10 the break would be as drawn.

If your concentrator is also part of the OSPF instance presumably you have virtual links across both of the Internet connections to wherever your concentrator is.
 
Byron
newbie
Topic Author
Posts: 32
Joined: Sun Jan 09, 2022 6:46 pm
Location: South Africa

Re: [OSPF] adding cost on backbone neighbor

Thu Jan 23, 2025 8:49 am

How do I add cost to the backup backbone (Red) link so that when adjacency is formed, they will not be advertised? If I set the backup link into an ospf area, the routes from either side do not redistribute into one another. So basically I want the backup links to only advertise when it is active and the main links to their respective WANs drop.
OSPF does not work like that. Links are always advertised, the OSPF algorithm then determines the shortest path from all of the advertised links within an instance.

If the gateways with the external connections (those with blue links in your diagram) are set to redistribute default route if installed then the path cost from each of the other gateways is the sum of the intervening path costs, with the default cost of 10 the break would be as drawn.

If your concentrator is also part of the OSPF instance presumably you have virtual links across both of the Internet connections to wherever your concentrator is.

Should I then be playing with the cost on the black links instead of the red link?

I know that the routes will be advertised at the WAN points no matter what. But I'm running iBGP to the concentrators and that's where my problem is with the routes being advertised into the concentrator table with the one WAN point for all and the second WAN point as a backup.
 
tdw
Forum Guru
Forum Guru
Posts: 2086
Joined: Sat May 05, 2018 11:55 am

Re: [OSPF] adding cost on backbone neighbor

Thu Jan 23, 2025 3:06 pm

Having only used OSPF and dynamic static routes (i.e. static routes attached to PPP secrets) I don't know how the metrics between routing protocols are handled in the Mikrotik BGP implementation.

The topic title doesn't really reflect the problem at hand, you may wish to edit it so others may see it be able to help. They will almost certainly want more information than just a network sketch.
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1690
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: [OSPF] adding cost on backbone neighbor

Thu Jan 23, 2025 6:52 pm

@Byron – I might have missed or misunderstood something, so this is just a guess:

I presume you’re advertising default gateways for both "network stacks" through the red (backup) link. To start troubleshooting, try checking one of the nodes and looking at the distance in the routing tables for the OSPF-generated default routes. Also, check for any static routes that might interfere, cause conflicts, or mess with redistribution.

Adjust the OSPF costs for each link of the stack and the backup link if necessary. Make sure the OSPF costs for the red (backup) link are high enough so it's only used when the black (primary) links fail. Also, double-check that the red backup link is in the right OSPF area for redistribution.

Toggle the backup link and monitor the distance for the OSPF-generated default routes on the node you’re troubleshooting. If you're using BFD, you should notice a change within a second. Otherwise, it will take the standard 10 seconds for ethernet and 30 seconds for non-broadcast links. If everything looks good, you can start toggling the "black" links and monitor the default routes.
 
Byron
newbie
Topic Author
Posts: 32
Joined: Sun Jan 09, 2022 6:46 pm
Location: South Africa

Re: [OSPF] adding cost on backbone neighbor

Fri Jan 24, 2025 8:31 am

Maybe I am thinking about this the wrong way. My OSPF within each stack is correct and to think about it advertising correctly.

The issue starts when each WAN point learns the OSPF routes via iBGP, My concentrator then sees the routes coming from both WAN points, picks 1 to get to all said routes, and uses the other as a backup to get to all routes.

the only logical thing I can think of is to add filters to add a weigh metric to the iBGP points for the needed network ranges.... I'm wonder if there is a "better" way of doing this.
 
Byron
newbie
Topic Author
Posts: 32
Joined: Sun Jan 09, 2022 6:46 pm
Location: South Africa

Re: [OSPF] adding cost on backbone neighbor

Fri Jan 24, 2025 8:35 am

@Byron – I might have missed or misunderstood something, so this is just a guess:

I presume you’re advertising default gateways for both "network stacks" through the red (backup) link. To start troubleshooting, try checking one of the nodes and looking at the distance in the routing tables for the OSPF-generated default routes. Also, check for any static routes that might interfere, cause conflicts, or mess with redistribution.

Adjust the OSPF costs for each link of the stack and the backup link if necessary. Make sure the OSPF costs for the red (backup) link are high enough so it's only used when the black (primary) links fail. Also, double-check that the red backup link is in the right OSPF area for redistribution.

Toggle the backup link and monitor the distance for the OSPF-generated default routes on the node you’re troubleshooting. If you're using BFD, you should notice a change within a second. Otherwise, it will take the standard 10 seconds for ethernet and 30 seconds for non-broadcast links. If everything looks good, you can start toggling the "black" links and monitor the default routes.
meant to quote you for the above reply.
 
User avatar
BartoszP
Forum Guru
Forum Guru
Posts: 3096
Joined: Mon Jun 16, 2014 1:13 pm
Location: Poland

Re: [OSPF][iBGP] adding cost on backbone neighbor

Fri Jan 24, 2025 9:45 am

I think that the problem could be that you broadcast OSPF with iBGP and when the route cost changes during DR, BDR election or/and some links go down then default gateways change. My config for OSPF anounces only OSPF links and lo interfaces to let them see each other and then only lo interfaces are used for BGP.
 
User avatar
jprietove
Trainer
Trainer
Posts: 222
Joined: Fri Jun 03, 2016 3:00 pm
Location: Cádiz, Spain
Contact:

Re: [OSPF][iBGP] adding cost on backbone neighbor

Fri Jan 24, 2025 10:54 am

I think you have to use external type 1 for the default route, so the cost will be the sum of external cost plus interface costs.

You can use filter like this:
if ( dst == 0.0.0.0/0 ) { set ospf-ext-type type1; accept }
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1690
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: [OSPF] adding cost on backbone neighbor

Fri Jan 24, 2025 2:06 pm

The issue starts when each WAN point learns the OSPF routes via iBGP, My concentrator then sees the routes coming from both WAN points, picks 1 to get to all said routes, and uses the other as a backup to get to all routes. the only logical thing I can think of is to add filters to add a weigh metric to the iBGP points for the needed network ranges.... I'm wonder if there is a "better" way of doing this.

I’m not entirely sure how OSPF interacts with iBGP on the yellow gateway nodes in this case. I assume you’re not running iBGP in parallel with OSPF on both "stacks", like in the drawing. Btw, what do you mean by the yellow nodes being connected to a single "concentrator" ("My concentrator," as you called it)?

Anyway, if OSPF is learning both default routes from iBGP and advertising them as a pair in the wrong order on both sides, it should be easily spotted in the routing tables on any of the black nodes. To fix it, you could, for example, set up and advertise static default routes from the yellow node to each black node, or try using filters to adjust route preferences.

In my world, the "better" way is the one that's easiest, takes the least effort, and causes the least interference with other stuff! ;)
 
Byron
newbie
Topic Author
Posts: 32
Joined: Sun Jan 09, 2022 6:46 pm
Location: South Africa

Re: [OSPF][iBGP] adding cost on backbone neighbor

Wed Jan 29, 2025 11:22 am

ok now I want to create a iBGP filter rule to execute this:

If ospf-type = external then set bgp-med +1 (As an example)

But I'm trying to figure out the syntax but I cant seem to get it right.

Thanks in advanced.
 
Byron
newbie
Topic Author
Posts: 32
Joined: Sun Jan 09, 2022 6:46 pm
Location: South Africa

Re: [OSPF][iBGP] route filtering syntax help

Tue Feb 04, 2025 1:12 pm

bump
 
User avatar
Larsa
Forum Guru
Forum Guru
Posts: 1690
Joined: Sat Aug 29, 2015 7:40 pm
Location: The North Pole, Santa's Workshop

Re: [OSPF][iBGP] adding cost on backbone neighbor

Tue Feb 04, 2025 3:35 pm

ok now I want to create a iBGP filter rule to execute this...

I thought you were having trouble with OSPF. What are you trying to solve with BGP? Some more background would help.