Community discussions

MikroTik App
 
iCharlie
just joined
Topic Author
Posts: 2
Joined: Mon Mar 20, 2023 6:47 pm

Multiple default routes in main route table

Mon Mar 20, 2023 7:06 pm

Hello,

I have multiple default routes in the same "main" routing table.

Currently routes:
(suppose 10.10.10.0/24, 10.10.20.0/24, 10.10.30.0/24 are public IPs)
Print
#      DST-ADDRESS         GATEWAY              DISTANCE
0  As+ 0.0.0.0/0                  10.10.10.1                      20
1  As+ 0.0.0.0/0                  10.10.20.1                      20
2  As+ 0.0.0.0/0                  10.10.30.1                      20
I want to know what actions or steps I should take to have the specific IPs using the specific gateway only.
For example: all IPs from 10.10.10.0/24 using only gateway 10.10.10.1, and all IPs from 10.10.20.0/24 using only gateway 10.10.20.1
Since Zerotier doesn't let me chose routing table, so I want to use only main table.

Those three routes are automatically enabled with ECMP. Sometimes the connection from 10.10.10.0/24 will route to 10.10.20.1 since the ECMP is like load balancing.

I've tried to use mangle rules.
add action=route chain=prerouting disabled=yes passthrough=yes route-dst=[b]10.10.10.1[/b] src-address=[b]10.10.10.0/24[/b]
add action=route chain=prerouting disabled=yes passthrough=yes route-dst=[b]10.10.20.1[/b] src-address=[b]10.10.20.0/24[/b]
The default route 0 and 1 will become unreachable when checking gateway - ping selected after I enable the mangle rules.

I think I might be using the wrong method or missed something.
Hope I can get some advice regarding this setup, and thank you so much.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19099
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Multiple default routes in main route table

Tue Mar 21, 2023 2:14 pm

If its whole subnets, dont use mangling.
If its a few users, dont use mangling
Instead use routing rules ( and I wont use your example of lan subnets somehow being in the same structure as each WAN subnet ;-PPP )

Consists of 3 steps
{add tables}
/routing table add fib name=useWAN1
/routing table add fib name=useWAN2
/routing table add fib name=useWAN3

{add routes}
/ip route
add dst=0.0.0.0/0 gwy=ISP1 routing-table=main
add dst=0.0.0.0/0 gwy=ISP2 routing-table=main
add dst=0.0.0.0/0 gwy=ISP3 routing-table=main
add dst=0.0.0.0/0 gwy=ISP1 routing-table=useWAN1
add dst=0.0.0.0/0 gwy=ISP2 routing-table=useWAN2
add dst=0.0.0.0/0 gwy=ISP3 routing-table=useWAN3

{add routing rules}
/routing rule add action=lookup src-address=10.100.10.0/24 table=useWAN1
/routing rule add action=lookup src-address=10.100.20.0/24 table=useWAN2
/routing rule add action=lookup src-address=10.100.30.0/24 table=useWAN3

NOTE: You should realize that LAN to LAN traffic will not occur as traffic is being forced out the specific route!!
Therefore if you require lets say LAN1 to be reachable by LAN2 and LAN3 add a routing rule ORDER COUNTS, before the other rules.

/routing rule add action=lookup dst-address=10.100.10.0/24 table=main

+++++++++++++++++++++++++++++++++++++++++++++++++++++

What is missing are your requirements for failover or not. These can be quite detailed and can included everything from NO failover to something like:
1 goes to 2 then 3
2 goes to 1 then 3
3 goes to 1 then 2

If however, they are all from the same ISP then no point, if the ISP is down all three are not available.
Note the ROUTING RULE paramer of action is current set to: action=lookup.
This means if the table is not available, then go to the main table and find a working route!!
If you didnt want the LAN subnets being routed out any other WAN, then change action to : action=lookup-only-in-table
 
iCharlie
just joined
Topic Author
Posts: 2
Joined: Mon Mar 20, 2023 6:47 pm

Re: Multiple default routes in main route table

Wed Mar 22, 2023 11:16 pm

If its whole subnets, dont use mangling.
If its a few users, dont use mangling
Instead use routing rules ( and I wont use your example of lan subnets somehow being in the same structure as each WAN subnet ;-PPP )
Thank you so much for those instructions.

I have tried with different routing tables and it works fine.

What I'm looking for is to route 10.0.10.0/24 using gateway 10.0.10.1 and 10.0.20.0/24 using gateway 10.0.20.1, all within the same routing table.
(suppose 10.10.10.0/24, 10.10.20.0/24, 10.10.30.0/24 are public IPs)

Maybe using connection marks or packet marks, but couldn't find any tutorials.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19099
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Multiple default routes in main route table

Thu Mar 23, 2023 2:29 am

Sorry no capiche,

I understand users or LAN subnets wanting to go out specific WANs, WAn1, Wan2, Wan3.
Wans1-3 may be from the same or different ISPs.
They may have different connection types, standard cable, wifi, PPPOE, or starlink for example.

So your explanation does nothing to provide any fidelity for understanding of what you actually have and what you actually need to do.
Its about user requirements not the config. The Config can be derived with a proper understanding of the user requirements.

Who is online

Users browsing this forum: ivicask, onnyloh, tim427 and 103 guests