Community discussions

MikroTik App
 
M1keBT
just joined
Topic Author
Posts: 10
Joined: Mon May 09, 2022 11:20 am

2 WAN / 1 LAN with 2 IP ranges

Mon May 09, 2022 11:26 am

Hello,
I have 2 WAN connections with WAN1 in port 1 and WAN2 in port 2.
I have port 3 acting as LAN.
in port 3 there is 2 ranges: 192.168.1.10-192.168.1.100 and 192.168.1.110-192.168.1.200
I want to make the first range takes internet from WAN1 and the second range takes internet from WAN2.
that thing that i already know is to set IPs for WAN1 and WAN2, add DNS and Gateways.
What should I do next? (in NAT/Mangle tabs i guess)
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 19101
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: 2 WAN / 1 LAN with 2 IP ranges

Mon May 09, 2022 4:50 pm

Why not make life easier for yourself and create another subnet and use a different etherport for the other subnet??
If not yes, you are stuck with mangling traffic

What I would do is make WAN1 the primary WAN distance =1 and make WAN2 the secondary by distance=5
Then all traffic will go to WAN1 by the distance setting. This takes care of 1/2 your traffic. Now for the other half!
Create a firewall address group for the contiguous group you have identified should go to WAN2> 192.168.1.110-192.168.1.200 =second_group
Then mangle their traffic such that we mangle and IP route that traffic out WAN2.

THIS MAY NOT BE EXACTLY CORRECT BUT IS AN EXAMPLE OF WHERE I WOULD START

/ip firewall mangle
add chain=prerouting in-interface=ether3 src-address-list=second_group connection-state=new action=mark-connection new-connection-mark=WAN2_conn
add chain=prerouting in-interface=ether3 connection-mark=WAN2_conn action=mark-routing new-routing-mark=ISP2_route

/ip route
add dst-address=0.0.0.0./0 gwy=ISP1 distance=1
add dst-address=0.0.0.0./0 gwy=ISP2 distance=5
add dst-address=0.0.0.0/0 gwy=ISP2 distance=5 routing-mark=ISP2_route

There are a gazillion ways to approach this, but be aware in this example if WAN1 is not available the users in WAN 1 will switch to WAN2 and vice versa.
They will not go back to their original WAN if the original WAN comes back on line.
In other words you need to better articulate your requirements.
Last edited by anav on Mon May 09, 2022 5:08 pm, edited 6 times in total.
 
erlinden
Forum Guru
Forum Guru
Posts: 1920
Joined: Wed Jun 12, 2013 1:59 pm
Location: Netherlands

Re: 2 WAN / 1 LAN with 2 IP ranges

Mon May 09, 2022 4:56 pm

Do you have a specific reason for this approach?
And how will you divide the two ranges on the single port?
 
M1keBT
just joined
Topic Author
Posts: 10
Joined: Mon May 09, 2022 11:20 am

Re: 2 WAN / 1 LAN with 2 IP ranges  [SOLVED]

Tue May 10, 2022 9:26 am

Hello All!
I figured out how to do it.
the reason i want to make it is that some PCs i want to give them from the 1st connection and the others from the second but i want to keep it in the same subnet due to shared printer/storage things (one ether-out from the routerboard to an unmanaged switch).
The way i did it is as following:
1. configure 1st port for the first connection including IP address, DNS, and Gateway (in IP ->route)
2. configure 2nd port for the second connection
3. create DHCP server and pool and set the IPs of PCs to static with 2 ranges (e.g: 192.168.10.10-192.168.10.60 & 192.168.10.70-192.168.10.120)
4. in NAT, masquerade the 2 IN connections
5. in Mangle prerouting the first range to 1st connection and the 2nd range to the secong connection (mark route)
6. in IP route set the 1st connection gateway to the 1st marked connection and the 2nd gateway to the 2nd connection and that's it.
 
imanbordbar
just joined
Posts: 2
Joined: Fri Jan 06, 2023 10:06 am

Re: 2 WAN / 1 LAN with 2 IP ranges

Sun Jan 08, 2023 8:35 pm

I have the same problem and I don't know much about these stuff. I have 1st internet connection on ether1 and 2nd on ether2. Other devices are connected to router (mikrotik hap lite) via wlan. I want this ip range { 192.168.88.251 - 192.168.88.253 } use ether2 for internet connection and the rest of ips use ether1.
I have created DHCP client for both ether 1 and 2.
Could you please explain me step by step what should I do?

Who is online

Users browsing this forum: cdblue, ganymede, rarlup and 39 guests