Community discussions

MikroTik App
 
MTRokie
just joined
Topic Author
Posts: 3
Joined: Tue Jul 19, 2022 4:25 am

Combining default route and BGP routing

Tue Jul 19, 2022 5:05 am

i have connected to 2 ISP, first ISP using PTP with default route 0.0.0.0/0 , the second one using BGP peer to connect. i want to know is there a way to routing client to using routing from default route and the same time using route from BGP.

lets say i have 2 network client (192.168.0.1/22 and 192.168.100.1/24). i route 192.168.0.1/22 to use default 0.0.0.0/0 using routing mark and 192.168.100.1/24 using main route which is BGP.
now, i want to route some ip address lets say 192.168.0.1/24 to route using spesific peer from BGP (BGP Have 2 Peer) and if the prefix do not exist on that peer then using default route from PTP.

if i can list prefix from a peer to address list. then i can simply mark routing client using that address list. but i dont know if its possible. any suggestion ?
 
eduplant
Member Candidate
Member Candidate
Posts: 122
Joined: Tue Dec 19, 2017 9:45 am

Re: Combining default route and BGP routing

Wed Jul 20, 2022 8:59 pm

I’ve read your post a couple of times and I’m struggling to understand the goal so I can be helpful. If you have a default from one ISP and then a collection of BGP routes from another with no default, the longest prefix match is already going to take care of the circumstance you describe. Traffic will go towards the BGP peers if there is a matching route and fall back to the default as a last resort.

You’d only need to get routing marks involved if you wanted some clients to behave differently. For example when you mention 192.168.0.1/22 using default, do you mean they use default for everything even if a better route exists from the BGP peers? You could do that with a routing mark if that is desirable for some reason.
 
MTRokie
just joined
Topic Author
Posts: 3
Joined: Tue Jul 19, 2022 4:25 am

Re: Combining default route and BGP routing

Thu Jul 21, 2022 7:13 am

I’ve read your post a couple of times and I’m struggling to understand the goal so I can be helpful. If you have a default from one ISP and then a collection of BGP routes from another with no default, the longest prefix match is already going to take care of the circumstance you describe. Traffic will go towards the BGP peers if there is a matching route and fall back to the default as a last resort.

You’d only need to get routing marks involved if you wanted some clients to behave differently. For example when you mention 192.168.0.1/22 using default, do you mean they use default for everything even if a better route exists from the BGP peers? You could do that with a routing mark if that is desirable for some reason.
sorry for my bad explanation, english not my main language.

yes, i want some client behave differently. i tried using routing mark but i dont know how to route the client based on prefix that i got from BGP peer. usually i used routing mark to route some client to spesific address (google.com for example).

it look like i want to do just like on this post viewtopic.php?t=8433
but it is an old post. maybe there is an update?
 
eduplant
Member Candidate
Member Candidate
Posts: 122
Joined: Tue Dec 19, 2017 9:45 am

Re: Combining default route and BGP routing

Thu Jul 21, 2022 10:45 am

No worries; your English is just fine I think it’s the networking concept that I’m missing.

If you want to route clients based on their source address, you can use :ip firewall mangle to set a new-routing-mark and then use :ip route rule to determine which routing table to lookup the next hop in. The routing tables are defined by setting routing-mark on individual routes, either manually for static routes, or by using BGP policy to set them as they come in. The wiki has some good explanation of this [1].

What I’m confused about is the objective. It seems like if you’re trying to build an address list based on the received BGP prefixes and then matching on the address rule in :ip firewall mangle to make sure clients use the BGP links for those destinations … that seems like you’re reinventing how the routing table already works but with more steps, right? By default, your client traffic will be routed based on longest prefix match and in the case where the alternative is just a default route to another provider, clients will already route towards the BGP provider(s) if a route exists and dynamically fall back to the default if no route exists or if the BGP sessions go away.

The only circumstance I can see where you’d want to intervene here is if a group of source addresses on your network should *never* use the BGP links even if a specific prefix exists. You might be able to do that by adding another default route with routing-mark=default-only or something. That way when your :ip route rule lookup happens, the BGP routes aren’t considered because it’s looked up against that specific table containing only the default route.


[1] https://wiki.mikrotik.com/wiki/Manual:R ... le_Matcher
 
MTRokie
just joined
Topic Author
Posts: 3
Joined: Tue Jul 19, 2022 4:25 am

Re: Combining default route and BGP routing

Fri Jul 22, 2022 4:52 pm

By default, your client traffic will be routed based on longest prefix match and in the case where the alternative is just a default route to another provider, clients will already route towards the BGP provider(s) if a route exists and dynamically fall back to the default if no route exists or if the BGP sessions go away.
you got it right. the problem is the limit bandwidth from providers.
2 providers with different bandwith limitation. if i use default routing, many clients traffic will go to the bgp routing and the bandwith will not enough. so my objective is to split traffic between 2 providers. i am thinking about load balancing but since the limit bandwith between 2 provider not the same, i am affraid clients traffic will be unstable. that's why i came out with get prefix from bgp peer to address list so i can route some client to it.
The wiki has some good explanation of this [1].
i think i can use this. just to be clear, all client that we specify on " /ip route rule " will match dst-address on that routing table first. if no route exist on that routing mark table then it will search in the "main" routing mark table. is it correct?
 
pe1chl
Forum Guru
Forum Guru
Posts: 8995
Joined: Mon Jun 08, 2015 12:09 pm

Re: Combining default route and BGP routing

Fri Jul 22, 2022 5:27 pm

i have connected to 2 ISP, first ISP using PTP with default route 0.0.0.0/0 , the second one using BGP peer to connect. i want to know is there a way to routing client to using routing from default route and the same time using route from BGP.
Yes you can create a second routing table (in addition to "main") and have BGP put its routes (including default route received from the other end) into that second routing table.
Then you have two routing tables for your two ISP and you can use whatever method you like to select them.
It is always a good idea to mark incoming traffic from each ISP so that reply traffic will go back via the same ISP. But for new outgoing traffic you can select any ISP.

Who is online

Users browsing this forum: Ahrefs [Bot] and 3 guests