Community discussions

MikroTik App
 
larico
just joined
Topic Author
Posts: 3
Joined: Mon Sep 04, 2023 5:13 pm

2 WAN - 1 LAN

Mon Sep 04, 2023 5:18 pm

Hello good.
I have a Mk with two wan

WAN1 - IP STATIC
WAN2 - DHCP VLAN1
LAN - 192.168.11.0/24
Port: 31445 - 192.168.11.10 - WAN1
Port: 32445 - 192.168.11.10 - WAN2
Mascarade: WAN1

I need that if someone makes a request through port 31445, the traffic leaves through WAN1, but if the request is made through port 32445, the traffic leaves through WAN2.

How can it be configured?

Thank you so much.
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 22310
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: 2 WAN - 1 LAN

Mon Sep 04, 2023 6:23 pm

Mangling
 
larico
just joined
Topic Author
Posts: 3
Joined: Mon Sep 04, 2023 5:13 pm

Re: 2 WAN - 1 LAN

Fri Sep 08, 2023 4:59 pm

Could you help me configure it?
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 22310
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: 2 WAN - 1 LAN

Fri Sep 08, 2023 6:50 pm

That is but one snippet of the requirements. YOu need to be clear with all other traffic before any configuring.
How many subnets do you have, which wan should they use??
Do you have an users cominig in externally?
How do you propose to use your two WANS ?? ( share, primary/failover etc...)

You need a plan and requirements clearly spelled out before even considering starting a configuration.
 
larico
just joined
Topic Author
Posts: 3
Joined: Mon Sep 04, 2023 5:13 pm

Re: 2 WAN - 1 LAN

Sun Sep 10, 2023 2:34 pm

Logical. Right now the system is in production and working, but I want to add the following possibility. I will explain in more detail.

The Mikrotik router to use is CCR2116

You have contacted two ISPs.
ISP1 - Ip fija 98.X.X.X
ISP2 - DHCP y VLAN20 215.X.X.X

On the Lan side a subnet 192.168.10.0/24
I have a server with the IP 192.168.10.10 and it is an IPTV server.
In the NAT of the mikrotik I have the following ports open

ISP1 - 98.X.X.X -> Puerto 45100 - 192.168.10.10
ISP2 - 215.X.X.X -> Puerto 46100 - 192.168.10.10

What we need is that if from the outside we make a request for a channel, the traffic of that channel leaves through the same ISP through which it entered, for example

https://98.X.X.X:45100/X.m3u8 traffic is returned by ISP1

If we make a channel request with the url

https://215.X.X.X:46100/X.m3u8 traffic is returned by ISP2

I have configured two rules in nat

Masquerate - ISP1 - out interface - > ISP1
Masquerate - ISP2 - out interface - > ISP2

I have tried to create a route but I think I am not creating it correctly so that the router knows where to take the traffic.

What do I need to make it work?

Thank you so much.
 
IlKa
newbie
Posts: 38
Joined: Sun Jan 03, 2021 11:42 pm

Re: 2 WAN - 1 LAN

Sun Sep 10, 2023 2:57 pm

I think you can mark connection using firewall. Then, use this mark to route packet using policy routing
https://help.mikrotik.com/docs/display/ROS/Mangle
https://help.mikrotik.com/docs/display/ ... allMarking
https://help.mikrotik.com/docs/display/ ... cy+Routing
 
User avatar
anav
Forum Guru
Forum Guru
Posts: 22310
Joined: Sun Feb 18, 2018 11:28 pm
Location: Nova Scotia, Canada
Contact:

Re: 2 WAN - 1 LAN

Sun Sep 10, 2023 7:45 pm

(1) First it would appear that ISP1 gives you a static public IP?
It would appear that ISP2 gives you a dhcp dynamic public IP that changes from time to time?

The format for static IPs and sourcenat is
add chain=srcnat action=src-nat in-interface=ether1 to-address=98.X.X.X
add chain=srcnat action=src-nat in-interface=vlan20 to-address=215.X.X.X
{ assuming its a static WANIP }

default dynamic WANIP (if both were dynamic)
add chain=srcnat action=masquerade out-interface=ether1
add chain=srcnat action=masquerade out-interface=vlan20


(2) To ensure traffic coming on WAN1 goes out WAN1 etc, we need mangling.
/ip nat mangling
add chain=prerouting action=mark-connection connection-mark=no-mark \
in-interface=ether1 new-connection-mark=incomingW1 passthrough=yes
add chain=prerouting action=mark-connection connection-mark=no-mark \
in-interface=vlan20 new-connection-mark=incomingW2 passthrough=yes
add chain=output action=mark-routing connection-mark=incomingW1 \
new-routing-mark=useWAN1 passthrough=no
add chain=output action=mark-routing connection-mark=incomingW2 \
new-routing-mark=useWAN2 passthrough=no


Need to create two tables..
/routing table
add fib name=useWAN1
add fib name=useWAN2

Besides two standard routes to wan1 and wan2 need two additional routes
/ip route
add dst-address=0.0.0.0/0 gateway=WAN1-gateway-IP routing-table=useWAN1
add dst-address=0.0.0.0/0 gateway=WAN2-gateway-IP routing-table=useWAN2


And modify fastrack rule in forward chain to:
add action=fasttrack-connection chain=forward comment="defconf: fasttrack" \
connection-state=established,related hw-offload=yes connection-mark=no-mark