Community discussions

MikroTik App
 
Kingberns
just joined
Topic Author
Posts: 3
Joined: Sun Mar 12, 2023 1:26 am

Priority LAN to WAN connection

Sun Mar 12, 2023 5:05 pm

Hi,

Tried to search through internet but it doesn't get any solution or guide.
Is this possible in Mikrotik? want to set.up src address to priority WAN per LAN.

LAN1 Priority route ISP1
Backup route ISP2

LAN2 Priority route ISP2
Backup route ISP1

Thank you in advance
You do not have the required permissions to view the files attached to this post.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19125
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Priority LAN to WAN connection

Mon Mar 13, 2023 1:03 pm

EASY WAY TO DO THIS - avoids mangling

Step1 - create routes
/ip route
distance=5 dst-address=0.0.0.0/0 gwy=ISP1-gatewayIP table=main check-gateway=ping
distance=10 dst-address=0.0.0.0/0 gwy=ISP2-gatewayIP table=main


From this alone, you have ALL USERS going to ISP1 and if that is not available the router will send them to ISP2.
We took advantage of distance different in routes to do this.

Step2 - Force LAN2 users out ISP2 ( add table, route and routing rule)
/routing table
add fib name=useWAN2


/ip route
add distance=5 dst-address=0.0.0.0/0 gwy=ISP1-gatewayIP table=main check-gateway=ping
add distance=10 dst-address=0.0.0.0/0 gwy=ISP2-gatewayIP table=main
add dst-address=0.0.0.0/0 gwy=ISP2-gatewayIP table=useWAN2[/i]

/routing rule
add action=lookup src-address=LAN2-subnet table=useWAN2


The result is that ALL lan2 traffic will now be forced out WAN2. If WAN2 is not available the router will go to the main table for a working route and will find WAN1.
This is function of using action=lookup, if you had used action=lookup-only-in-table, there would be no option for the router to look for an alternate route.

Step3 - Consider LAn to LAn traffic.
Think about it, we are routing anything leaving LAN2 to WAN2, and that is all traffic, even that lets say heading to LAN1.
The way to ensure LAN2 to LAN2 traffic can work we need a second routing rule. Order is critical here.......

/routing rule
add action=lookup-only-in-table dst-address=LAN1-subnet table=main[/b]
add action=lookup src-address=LAN2-subnet table=useWAN2
 
Kingberns
just joined
Topic Author
Posts: 3
Joined: Sun Mar 12, 2023 1:26 am

Re: Priority LAN to WAN connection

Mon Mar 13, 2023 5:00 pm

Thank you Anav. I will try this one and revert back for the update.
 
User avatar
broderick
Member Candidate
Member Candidate
Posts: 242
Joined: Mon Nov 30, 2020 7:44 pm

Re: Priority LAN to WAN connection

Tue Mar 14, 2023 2:09 pm

@anav
I tested your setup in a virtual environment and it seems to be working as expected. Very good!

one question:

this rule needs no distance setup? Just the default 1?
add dst-address=0.0.0.0/0 gwy=ISP2-gatewayIP table=useWAN2
Thanks
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19125
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Priority LAN to WAN connection

Tue Mar 14, 2023 5:40 pm

Correct, distance has no bearing on that non main table entry.
 
User avatar
broderick
Member Candidate
Member Candidate
Posts: 242
Joined: Mon Nov 30, 2020 7:44 pm

Re: Priority LAN to WAN connection

Wed Mar 15, 2023 9:32 am

Correct, distance has no bearing on that non main table entry.
oh, interesting. I didn't know that distance doesn't affect a non-main table entry.
Thank you

Who is online

Users browsing this forum: No registered users and 10 guests