Community discussions

MikroTik App
 
Urajmal
just joined
Topic Author
Posts: 23
Joined: Thu Jul 26, 2018 6:23 pm

Redirect specific Website traffic to WAN2

Tue Jan 19, 2021 10:55 pm

Hi all!

I am facing a new challange, if I may say so, with Mikrotik at new job.

The situatuion is:
I have to configure a mikrotik device with 2 WANs - On the WAN1 (eth1), there is a PPPoe connection with static IP, on WAN2 (eth2) there is an DHCP requested IP (client).
My mission is that computers that will be connected to LAN will have internet access via WAN1, and in the same time there will run software that uses specific ip 13.10.10.1 - 13.10.10.100 will be able to connect through WAN2.

If I understand right I need to:
1. Configure WAN1 to PPPoe and WAN2 to client to obtain IP
2. Create FW address list with IP range 13.10.10.1 - 13.10.10.100
3. Create Mangle rule with prerouting, marking all the above address lists
4. Create Route with Dst. address 0.0.0.0/0, routing mark above and getaway to WAN2
5. Create a NAT masquerade rule with src. list of above IP range and out interface to WAN2

My questions are:
1. is that a correct topology - for those with big brains and good visualization ;) ?
2. how can I configure DHCP and address eth3, eth4 and eth5 with above solution ?

Thank you all!
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 23451
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Redirect specific Website traffic to WAN2

Tue Jan 19, 2021 11:06 pm

Well I believe this can be accomplished fairly easily via IP routes.
After the two standard IP routes are created.....

1. Ensure WAN1 has a shorter distance so that will always be the preferred routing for all LAN traffic in general.
2. To force specific traffic to WAN2,
a. create another/second IP route for WAN2 but add a routing mark (call it special_LAN)
b. create an IP Route rule that points to the subnet (or interface) and with ACTION - lookup only in TABLE
Table entry is "special_LAN"

All traffic from that subnet/interface will go out WAN2.
 
Urajmal
just joined
Topic Author
Posts: 23
Joined: Thu Jul 26, 2018 6:23 pm

Re: Redirect specific Website traffic to WAN2

Tue Jan 19, 2021 11:10 pm

Well I believe this can be accomplished fairly easily via IP routes.
After the two standard IP routes are created.....

1. Ensure WAN1 has a shorter distance so that will always be the preferred routing for all LAN traffic in general.
2. To force specific traffic to WAN2,
a. create another/second IP route for WAN2 but add a routing mark (call it special_LAN)
b. create an IP Route rule that points to the subnet (or interface) and with ACTION - lookup only in TABLE
Table entry is "special_LAN"

All traffic from that subnet/interface will go out WAN2.
Thank you! That won't be hard to set. What do you think of my point 5. and how can I achieve DHCP on eth3, eth4 and eth5 that will follow all the above ?
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 23451
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: Redirect specific Website traffic to WAN2

Tue Jan 19, 2021 11:19 pm

I would not do anything different from standard for your outgoing traffic to the wan.
In my case I have two wans.......
/ip firewall nat
add action=masquerade chain=srcnat comment="SCR_NAT FOR LAN - FibreOP" \
ipsec-policy=out,none out-interface=vlanbell
add action=masquerade chain=srcnat comment="SCR_NAT for LAN - Cable" \
ipsec-policy=out,none out-interface=Eastlink_eth7

In your case whatever the active interface is for each link, you are stating please NAT returning traffic properly through these interfaces.
Its not specific to the lan subnets, well doesnt need to be.

(1) Routing: YOu have told the router all traffic from the unique LAN has to go out WAN2
(2) NAT: The masquerade rule simply says any traffic going out each WAN should be given the IP address of that WAN and be returned to the correct LAN originator upon return traffic.