Community discussions

MikroTik App
 
DRep
newbie
Topic Author
Posts: 40
Joined: Sun Jan 27, 2013 2:41 am

Mikrotik DUAL WAN Load Balancing using PCC method

Mon Apr 29, 2013 4:05 am

Dear all,
I have seen the script from by zaiB under the following link:
http://aacable.wordpress.com/2011/07/27 ... t-by-zaib/
This fits very well what I Need, but I have more than 1 LAN port.

What I need to change in the script to work with 4 LAN ports?

I guess it is in this part:
add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local

Do I Need to add these two lines for each LAN Interface I have and thats it or do I need to change more in the script?

What will be the case if most of he traffic is coming from a other router, which is running NAT already? Would this script still work, as most of the traffic will come from the same source IP.
Any solution for that? NAT can not be disabled at this router.
 
User avatar
joshaven
Member
Member
Posts: 438
Joined: Fri May 06, 2011 1:50 am
Location: USA
Contact:

Re: Mikrotik DUAL WAN Load Balancing using PCC method

Mon Apr 29, 2013 5:02 am

if all of the interfaces are on the same switch chip then you can set the other interfaces to have the master port set to the first lan port... ie: ether2 could be the lan port, ether3 could be set to have the master port be ether2, etc.

Alternatively if they are not all on a switch port you can create a bridge port and call it something like Local. Then you can make each interface be a member of that bridge through bridge ports. Then you will configure all ip addresses, dhcp etc on that bridge rather then any individual interface.

For PPC to work your basically set up your local network and then setup two external networks. Both should work before you go further. You should be able to plug in only one and have internet then plugin the second and unplug the first and still have internet. The PCC allows you to add routing marks to connections. You can then setup default routes to each provider with a routing mark on the route. Then when you configure the PCC mangle rule the marked packets will match up with the routes and will choose be split over the multiple connections.

I hope this helps.
 
DRep
newbie
Topic Author
Posts: 40
Joined: Sun Jan 27, 2013 2:41 am

Re: Mikrotik DUAL WAN Load Balancing using PCC method

Wed May 01, 2013 8:23 pm

I do not want to use the switch or bridge functionality in the RB.
I Need these LAN ports routed and separated networks.

I I can not put them together with a Bridge.

What do I Need to Change in that case in the script?
Thanks
 
User avatar
joshaven
Member
Member
Posts: 438
Joined: Fri May 06, 2011 1:50 am
Location: USA
Contact:

Re: Mikrotik DUAL WAN Load Balancing using PCC method

Wed May 01, 2013 8:36 pm

You don't need to do anything to put them together if your routing. The interfaces route by default when an IP address is assigned to the interface. You'll see a route entry in the routing table with a "D" in front of it which means that it is a dynamic route. If a packet enters ether1 and is destined for an IP address that is within the subnet of a route for ether2 then it will exit ether2 unless there is a rule of some sort that you created to drop or otherwise change the default action.

If the packets are inside of the same subnet then you will have to bridge or switch the interfaces.

For example:
Assuming 192.168.1.1/24 is an address on ether1
and 192.168.2.1/24 is an address on ether2

the computer 192.168.1.5 attached to ether1 could route through 192.168.1.1 to the computer 192.168.2.5 attached to ether2

This will be because the router will have dynamic routes similar to the following:
DAC, 192.168.1.0/24, ether1, 0, 192.168.1.1
DAC, 192.168.2.0/24, ether2, 0, 192.168.2.1
 
DRep
newbie
Topic Author
Posts: 40
Joined: Sun Jan 27, 2013 2:41 am

Re: Mikrotik DUAL WAN Load Balancing using PCC method

Wed May 01, 2013 8:50 pm

OK, but what is with the script?
the code:
add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local
must be added then for any Local port (say Local1, Local2, Local3...) so that the script is working for all local ports on the LAN site?
Thank you
 
User avatar
joshaven
Member
Member
Posts: 438
Joined: Fri May 06, 2011 1:50 am
Location: USA
Contact:

Re: Mikrotik DUAL WAN Load Balancing using PCC method

Wed May 01, 2013 9:23 pm

OK, but what is with the script?
the code:
add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local
must be added then for any Local port (say Local1, Local2, Local3...) so that the script is working for all local ports on the LAN site?
Thank you
The config above only is applicable to the single interface "Local" so it will not accept packets from two interfaces even though it will from two subnets. If you remove the in-interface condition then it may work. Or you can specify the in-interface that that ip address is assigned to.

Looking at that config I would guess that the author expected something like ether1 renamed to Local and and ether2 set to switch with ether1. That is just speculation though.
 
DRep
newbie
Topic Author
Posts: 40
Joined: Sun Jan 27, 2013 2:41 am

Re: Mikrotik DUAL WAN Load Balancing using PCC method

Wed May 01, 2013 9:58 pm

I think I Need to adapt more:
add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local 

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=WAN1_conn 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=WAN2_conn passthrough=yes 

add chain=prerouting connection-mark=WAN1_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN1
add chain=prerouting connection-mark=WAN2_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN2
Maybe I Need to add These lines for each LAN Interface I have on my RB1200 like:
add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local1
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local1 

add chain=prerouting dst-address-type=!local1 in-interface=Local1 per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local1 in-interface=Local1 per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection new-connection-mark=WAN2_conn passthrough=yes 

add chain=prerouting connection-mark=WAN1_conn in-interface=Local1 action=mark-routing new-routing-mark=to_WAN1
add chain=prerouting connection-mark=WAN2_conn in-interface=Local1 action=mark-routing new-routing-mark=to_WAN2
Can someone confirm that if that is needed?
 
DRep
newbie
Topic Author
Posts: 40
Joined: Sun Jan 27, 2013 2:41 am

Re: Mikrotik DUAL WAN Load Balancing using PCC method

Tue May 07, 2013 3:54 pm

Thank you joshaven for your hint with the in-interface condition.
Installed it yesterday and it works.
Thank you again.

Who is online

Users browsing this forum: CGGXANNX and 4 guests