Community discussions

MikroTik App
 
jhaycutexp
just joined
Topic Author
Posts: 4
Joined: Wed Dec 21, 2016 4:39 am

Help Beginner Trying to Solidify my foundation

Tue Apr 23, 2019 7:28 pm

Good day sirs,

I am pretty much noob at MT I recently started again studying.. I kinda know how to make the router work.. I mean the
basic setup of RouterOS.. I thought the setup I know.. is the only thing I need.. like setting DHCP and src nat the ISP so that I
can have internet etc...

Recently I came accross a problem and I tried to solve it first on my own before I ask.. but since my foundation is not that strong
and I only use the case studies provided in the internet to work with.. but I cant seem to like find a case study that fits what I am trying to achieve.

What I am trying to achieve is this.. kindly see the photo..

Image
https://drive.google.com/file/d/1N1z643 ... sp=sharing

Well basically I tried the PCC load balancing.. and it actually works.. But I dont see how I can like filter the HTTP packets from both of the ISP I have
and use them.. the problem I am having with this kind of load balancing.. is this method randomly use whatever that is available for the client PC/station
and when one of the PC/station connects to the slower ISP.. the user experience is so bad.. like slow loading of pages.. when they try to play games in the house
its spikes/lag.. pretty much the experience is bad.. on the other hand.. when the user or client is on the ISP where there is low latency.. the experience is great.. because
of the high speed..
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=ISP1_con
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=ISP2_con

add chain=output connection-mark= ISP1_con action=mark-routing new-routing-mark=to_ISP1
add chain=output connection-mark= ISP2_con action=mark-routing new-routing-mark=to_ISP2

add chain=prerouting dst-address=192.168.100.0/24 action=accept in-interface=bridge-LAN
add chain=prerouting dst-address=192.168.0.0/24 action=accept in-interface=bridge-LAN

add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark= ISP1_con passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark= ISP2_con passthrough=yes

add chain=prerouting connection-mark=ISP1_con in-interface=Local action=mark-routing new-routing-mark=to_ISP1
add chain=prerouting connection-mark=ISP2_con in-interface=Local action=mark-routing new-routing-mark=to_ISP2
On the other hand.. I came across with this case study.. this works the best.. but It can only handle one connection.. I mean
the setup is for using only a single ISP.. If only I can use this method.. but with two ISP.. is this possible??
/ip firewall mangle
add action=mark-connection chain=prerouting new-connection-mark=local-cm \
    passthrough=yes src-address-list=local

add action=mark-packet chain=prerouting connection-mark=local-cm \
    new-packet-mark=http-pm passthrough=no protocol=tcp src-port=80,8080,443

add action=mark-packet chain=prerouting connection-mark=local-cm dst-port=\
    80,8080,443 new-packet-mark=http-pm passthrough=no protocol=tcp

add action=mark-packet chain=prerouting connection-mark=local-cm \
    new-packet-mark=roblox-pm passthrough=no src-address-list=roblox

add action=mark-packet chain=prerouting connection-mark=local-cm \
    new-packet-mark=other-pm passthrough=no

/ip firewall nat
add action=masquerade chain=srcnat comment=ISP1 out-interface=ether1 \
    src-address-list=local
add action=masquerade chain=srcnat comment=ISP2 out-interface=ether2 \
    src-address-list=local

/ip firewall address-list
add address=192.168.3.0/24 list=local

Can you please help me? or guide me in which direction should I take... if there is sample I can learn with
you please send me the links..
 
Sob
Forum Guru
Forum Guru
Posts: 9188
Joined: Mon Apr 20, 2009 9:11 pm

Re: Help Beginner Trying to Solidify my foundation

Fri Apr 26, 2019 5:18 am

Now you have two rules that balance everything:
/ip firewall mangle
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=ISP1_con passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=ISP2_con passthrough=yes
So just do something like this (jump saves you from repeating same parameters for several rules; should also save few cpu cycles, but probably not much):
/ip firewall mangle
add chain=prerouting connection-mark=no-mark dst-address-type=!local in-interface=Local action=jump jump-target=balancing
add chain=balancing protocol=tcp dst-port=666,6666 action=mark-connection new-connection-mark=ISP1_con passthrough=yes comment="fast ports"
add chain=balancing protocol=udp dst-port=777,7777 action=mark-connection new-connection-mark=ISP1_con passthrough=yes comment="fast ports"
add chain=balancing protocol=tcp dst-port=80,443 per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=ISP1_con passthrough=yes comment="web"
add chain=balancing protocol=tcp dst-port=80,443 per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=ISP2_con passthrough=yes comment="web"
add chain=balancing connection-mark=no-mark action=mark-connection new-connection-mark=ISP2_con passthrough=yes comment="everything else"