Community discussions

MikroTik App
 
Ivoshiee
Member
Member
Topic Author
Posts: 483
Joined: Sat May 06, 2006 4:11 pm

How to gain access to MT box itself in case of dual WAN?

Tue Jan 25, 2011 10:12 pm

I am having difficulties to get a MT box itself to answer outside requests in case of dual WAN.
My setup is not exactly a dual WAN as described at http://wiki.mikrotik.com/wiki/Load_Bala ... e_Gateways, but quite similar to that.
I can get access to MT box itself only from that WAN where I am setting a regular default gateway to the Internet.
How to set second default gateway to point to second WAN so every request originating from that WAN side will get answer going back to the very same WAN connection?
I tried to catch those connections by connection marking, but that seems to work only on those connections traversing the MT box, but all connection attempts to the MT box itself will fail.
 
Feklar
Forum Guru
Forum Guru
Posts: 1724
Joined: Tue Dec 01, 2009 11:46 pm

Re: How to gain access to MT box itself in case of dual WAN?

Tue Jan 25, 2011 10:50 pm

For connections destined to the router
add action=mark-connection chain=input comment="" disabled=no in-interface=ether1 new-connection-mark=input1_connection passthrough=yes
add action=mark-connection chain=input comment="" disabled=no in-interface=ether2 new-connection-mark=input2_connection passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=input1_connection disabled=no new-routing-mark=to_outside1 passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=input2_connection disabled=no new-routing-mark=to_outside2 passthrough=yes
For connections being forwarded to devices behind the router
add action=mark-connection chain=forward comment="" connection-state=new disabled=no in-interface=ether1 new-connection-mark=outside1_connection passthrough=no
add action=mark-connection chain=forward comment="" connection-state=new disabled=no in-interface=ether2 new-connection-mark=outside2_connection passthrough=no
add action=mark-routing chain=prerouting comment="" connection-mark=outside1_connection disabled=no new-routing-mark=to_outside1 passthrough=no
add action=mark-routing chain=prerouting comment="" connection-mark=outside2_connection disabled=no new-routing-mark=to_outside2 passthrough=no
In either case you need the appropriate routes in your routing table.
 
sw0rdf1sh
Frequent Visitor
Frequent Visitor
Posts: 50
Joined: Sun Nov 28, 2010 6:16 pm

Re: How to gain access to MT box itself in case of dual WAN?

Wed Jan 26, 2011 12:10 am

Thanks feklar for the answer.It sure solves my problems too.
I can use now the Wiki articl and your "input" rules and still have access to routerboard.
I have posted here the same issue with no answers:
http://forum.mikrotik.com/viewtopic.php?f=13&t=48005
 
Ivoshiee
Member
Member
Topic Author
Posts: 483
Joined: Sat May 06, 2006 4:11 pm

Re: How to gain access to MT box itself in case of dual WAN?

Wed Jan 26, 2011 12:12 am

Thanks a lot!
Somehow the "forward" chain tracking for a port redirecting (dstnat) didn't work, but another "prerouting" rule pointing to interface ether1 did the trick for me:
add action=mark-connection chain=input comment="" disabled=no in-interface=ether1 new-connection-mark=input1_connection passthrough=yes
add action=mark-routing chain=output comment="" connection-mark=input1_connection disabled=no new-routing-mark=to_outside1 passthrough=yes
add action=mark-connection chain=prerouting comment="" disabled=no in-interface=ether1 new-connection-mark=input1_connection passthrough=no
add action=mark-routing chain=prerouting comment="" connection-mark=input1_connection disabled=no new-routing-mark=to_outside1 passthrough=no
Note: I have no second WAN rules here because I have another MT box dealing with it, just a plain default gateway is pointing to that internal LAN gateway.

As that issue is set behind us then another routing extension:
how to make MT itself to ignore default gateway setting and direct all connections originating from itself to go out from ether1 and not take default gateway route?

It should be possible to read out what to manipulate from the packet flow diagram (http://wiki.mikrotik.com/wiki/Manual:Packet_Flow), but I fail to read it. For example what stages will the IP packet go through (is it always prerouting, input, forward, output and postrouting? etc) or where lies the RouterOS application layer on these diagrams?
 
Feklar
Forum Guru
Forum Guru
Posts: 1724
Joined: Tue Dec 01, 2009 11:46 pm

Re: How to gain access to MT box itself in case of dual WAN?

Wed Jan 26, 2011 4:57 pm

As that issue is set behind us then another routing extension:
how to make MT itself to ignore default gateway setting and direct all connections originating from itself to go out from ether1 and not take default gateway route?

It should be possible to read out what to manipulate from the packet flow diagram (http://wiki.mikrotik.com/wiki/Manual:Packet_Flow), but I fail to read it. For example what stages will the IP packet go through (is it always prerouting, input, forward, output and postrouting? etc) or where lies the RouterOS application layer on these diagrams?
It's a basic extension of the rules I posted, but doing it in your case may cause some unintended consequences, this is because the basic rule will force everything from the router (output chain) out of a specific interface, and there are some things like broadcast traffic you may not want to do this for. It's easier and better to assign the gateway you want the router to use by default a higher priority if at all possible.
/ip firewall mangle
add action=mark-connection chain=output comment="" new-connection-mark=output1 disabled=no passthrough=yes connection-state=new
/ip firewall nat
add action=src-nat chain=srcnat comment="" connection-mark=output disabled=no out-interface=ether1 to-addresses="Your WAN IP"
These two rules will mark anything leaving the router on the output chain, and then in NAT change the interface it will be sending traffic out of and change it's address so it uses the correct one for that interface. I don't remember if you need a mark routing rule as well that matches the mark connection in mangle or not. I used similar rules to accomplish PCC load balancing with the proxy as a test, but instead of NATing everything I just NATed port 80 to avoid any problems with local traffic on the router for those interfaces.

For the port forwarding rules, I actually have those as the last rules in my chain. If something else is firing before or after your forward rules, that is probably what is messing them up.
 
Ivoshiee
Member
Member
Topic Author
Posts: 483
Joined: Sat May 06, 2006 4:11 pm

Re: How to gain access to MT box itself in case of dual WAN?

Thu Jan 27, 2011 12:39 am

Thanks.