Вы находитесь на странице: 1из 46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Syed Jahanzaib Personnel Blog to Share Knowledge !

July 27, 2011

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB
Filed under: Mikrotik Related Tags: dsl, dual wan load balance, load balance, mikrotik, pcc Syed Jahanzaib / Pinochio~:) @ 10:16 AM

i
45 Votes

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB
Following is a complete script for Mikrotik to combine/load balance two DSL lines. In this example I used MikrotikT RB750 5 ports router.
2 ports were connected with two difference DSL Routers,
and 3rd port was connected with User LAN.
Both DSL are of same speed , i.e 10Mb each.
DSL MODEM IPS
DSL MODEM 1 = 192.168.1.1
DSL MODEM 2 = 192.168.2.1
Also dont forget to rename the interface names accordingly.
In my personnel experience , If users request are directly hitting Mikrotik configured with PCC , then you will get good load balancing. Use src-address as
classifier, this way you will get rid of problems like https/broken link, streaming issues etc. Load balancing using this PCC technique (src-address) will be
effective and balanced approach when more and more connections (from clients) that occurred. I also recommend to use SQUID proxy server along with
mikrotik , either parallel or in front or backend , for better response time and it will also increase good browsing experience to users.
If somehow you are not satisfied with the src-address approach,play with the PCC-Classifier, then Try both addresses and ports as the classifier. While this
will randomize things the most and in theory give you the most fair allocation of bandwidth, BUT there is also a good chance that it will break certain things
like banking web sites and some forums. This is because often times a HTTP requests will generate several connections, so there is a chance that some
requests may go out a different route than the initial one, and that will break secure web sites. For that reason I usually stick with src-address for PCC load
balancing.
Regards
Syed Jahanzaib
1
2
3
4
5
6
7
8
9
10
11
12
13

/ip
add
add
add

address
address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
address=192.168.1.2/24 network=192.168.1.0 broadcast=192.168.1.255 interface=WAN1
address=192.168.2.2/24 network=192.168.2.0 broadcast=192.168.2.255 interface=WAN2

/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=221.132.112.8,8.8.8.


/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2

http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

1/46

8/10/2014

14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

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=


add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/1 action=
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
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade

All Done ! Now Test the link by putting user load, the more multiple users load you put on it, the better Load Balance result you will get

PCC WITH UN-EQUAL WAN LINKS


If you have Un-Equal WAN Links, for example WAN,1 is of 4MB and WAN,2 is of 8 Mb, and you want to force MT to use WAN42link more then other
because of its capacity, Then you have to Add more PCC rules assigning the same two marks to a specific link i.e WAN2 , something like
Code:
1
2
3

add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/0 action=m


add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/1 action=m
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=m

PCC WITH HOTSPOT (Reference)


1

/ip firewall nat add action=accept chain=pre-hotspot disabled=no dst-address-type=!local hotspot=auth


(
) ZaiB (

About these ads

Comments (317)

317 Comments
1. hi
plz contact me..
and tell me where you live
am Shahzad form pakistan/multan
my phone number # 0092312-6460823
Comment by shahzad July 31, 2011 @ 5:42 AM
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

2/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Reply
You can contact me at my email address.
aacable [at] hotmail.com / 0092333.xxxxxxx
Comment by Pinochio / zaib July 31, 2011 @ 6:05 AM
Reply
Dear, how can you make the router make load balancing on tow interfaces i will use one for my hotspote and the other for my internal LAN
Comment by mtaherhassanin December 27, 2012 @ 9:59 AM
Describe in details.
Comment by Syed Jahanzaib / Pinochio~:) December 27, 2012 @ 3:06 PM
I Have RB 750GL with 5 Ports i will use 3 Ports for WANs DSL Routers , the rest 2 Ports i will Use them 1 For my LAN and 1 For My HotSpot
Bullet. i Used your Script from the Above as the followng
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512
servers=41.128.225.225,41.128.225.226,163.121.128.135
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local This for my Lan
add chain=prerouting dst-address=192.168.3.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local2 this for my Hotspot
add chain=prerouting dst-address=192.168.3.0/24 action=accept in-interface=Local2
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=WAN2_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=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection
new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local2 per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection
new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local2 per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection
new-connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local2 per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection
new-connection-mark=WAN1_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
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.2.254 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.3.254 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.254 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.3.254 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
/ip firewall nat add action=accept chain=pre-hotspot disabled=no dst-address-type=!local hotspot=auth
but i belive that my hot spot Not Acting well
Comment by mtaherhassanin December 30, 2012 @ 5:20 AM
Hello Dear
Well i have a Question
in RB 750 Mikrotik
Local Interface Pluged To ISA Server
Local2 Pluged To Hotspot System
I am Behind the ISA Server
how can i mange to make the PING to the Hotspot system succeded
Local 192.168.88.0/24
Local2 192.168.80.0/24
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

3/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Comment by mtaherhassanin December 31, 2012 @ 10:29 AM


Dear sir can it possible on 3g modem? EVO PTCL
Comment by Rana Aamir July 20, 2012 @ 9:35 PM
Reply
Plz help me with a scrip for a b750
3 adsl 4mb
wan
192.168.2.1 dns 196.7..7.7
192.168.3.1
192.168.4.1
lan
192.168.7.1
hotspot
192.168.8.1
thanks
ben
Comment by Ben Heydenrych June 29, 2013 @ 10:06 PM
Reply
2. How can i achieve load balancing with these typr of setup.
2 wan and 1 hotspot LAN.
normal web/light browsing traffic should be directed to WAN1 while heavy and other traffic should go to WAN 2.
Comment by Collins August 1, 2011 @ 3:26 PM
Reply
You have to do policy base load balancing.
or you can mark packets for specific traffic and route it to your desired WAN link.
Comment by Pinochio / zaib August 4, 2011 @ 6:03 AM
Reply
3. i am also enabled proxy because WAN1 is billing me based on volume of data i use.
Comment by Collins August 1, 2011 @ 4:01 PM
Reply
4. hello sir i am aman can you help me how mikrotik load balasing and modem setting what is your mobile no and your E-mail
Comment by Aman Manifarooqi August 1, 2011 @ 4:05 PM
Reply
5. plz sir help me
Comment by Aman Manifarooqi August 1, 2011 @ 4:06 PM
Reply
6. my name is Aman farooqi plz you help me from pakistan RAWAlpindi mikrotik load balascing how make and how modem settend
Comment by Aman Manifarooqi August 1, 2011 @ 4:11 PM
Reply
you can contact me at
aacable at hotmail.com
Comment by Pinochio / zaib August 4, 2011 @ 6:03 AM
Reply
skyp id plz 03112910453
Comment by faisal March 30, 2014 @ 5:11 AM
Reply
jhanzaib sb skyp ke id ager ap deyea tu baat ho sakti hay ya cell fone mai 03112910453
Comment by faisal March 30, 2014 @ 5:13 AM
Reply
aacable79
Comment by Syed Jahanzaib / Pinochio~:) March 31, 2014 @ 3:51 PM
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

4/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

7. / ip address
add address=1.1.0.5/24 network=1.1.0.0 broadcast=1.1.0.255 interface=Local comment= disabled=no
add address=10.0.0.10/24 network=10.0.0.0 broadcast=10.0.0.255 interface=wan1 comment= disabled=no
add address=7.7.7.10/24 network=7.7.7.0 broadcast=7.7.7.255 interface=wan2 comment= disabled=no
/ ip firewall mangle
add chain=prerouting in-interface=Local connection-state=new nth=2,1 action=mark-connection new-connection-mark=conn1 passthrough=yes
comment= disabled=no
add chain=prerouting in-interface=Local connection-mark=conn1 action=mark-routing new-routing-mark=conn1 passthrough=no comment=
disabled=no
add chain=prerouting in-interface=Local connection-state=new nth=1,1 action=mark-connection new-connection-mark=conn2 passthrough=yes
comment= disabled=no
add chain=prerouting in-interface=Local connection-mark=conn2 action=mark-routing new-routing-mark=conn2 passthrough=no comment=
disabled=no
/ ip firewall nat
add chain=srcnat connection-mark=conn1 action=masquerade out-interface=wan1 comment= disabled=no
add chain=srcnat connection-mark=conn2 action=masquerade out-interface=wan2 comment= disabled=no
/ ip route
add dst-address=0.0.0.0/0 gateway=10.0.0.138 scope=255 target-scope=10 routing-mark=conn1 comment= disabled=no
add dst-address=0.0.0.0/0 gateway=7.7.7.7 scope=255 target-scope=10 routing-mark=conn2 comment= disabled=no
Comment by Aman Manifarooqi August 4, 2011 @ 11:21 PM
Reply
8. ware is this problam khaa par masllha ho sakta hai kia modem ki setting bhi karni hai aghr karni hai to kia ya is main problam, hai
Comment by Aman Manifarooqi August 4, 2011 @ 11:25 PM
Reply
9. / ip address
add address=1.1.0.5/24 network=1.1.0.0 broadcast=1.1.0.255 interface=Local comment= disabled=no
add address=1.1.0.77/24 network=1.1.0.0 broadcast=1.1.0.255 interface=wan1 comment= disabled=no
add address=5.5.5.1/24 network=5.5.5.0 broadcast=5.5.5.255 interface=wan2 comment= disabled=no
/ ip firewall mangle
add chain=prerouting in-interface=Local connection-state=new nth=2,1 action=mark-connection new-connection-mark=conn1 passthrough=yes
comment= disabled=no
add chain=prerouting in-interface=Local connection-mark=conn1 action=mark-routing new-routing-mark=conn1 passthrough=no comment=
disabled=no
add chain=prerouting in-interface=Local connection-state=new nth=1,1 action=mark-connection new-connection-mark=conn2 passthrough=yes
comment= disabled=no
add chain=prerouting in-interface=Local connection-mark=conn2 action=mark-routing new-routing-mark=conn2 passthrough=no comment=
disabled=no
/ ip firewall nat
add chain=srcnat connection-mark=conn1 action=masquerade out-interface=wan1 comment= disabled=no
add chain=srcnat connection-mark=conn2 action=masquerade out-interface=wan2 comment= disabled=no
/ ip route
add dst-address=0.0.0.0/0 gateway=1.1.0.5 scope=255 target-scope=10 routing-mark=conn1 comment= disabled=no
add dst-address=0.0.0.0/0 gateway=5.5.5.1 scope=255 target-scope=10 routing-mark=conn2 comment= disabled=no
Comment by Aman Manifarooqi August 5, 2011 @ 6:57 PM
Reply
First turn off dhcp server seetings in modem than trygood luck
Comment by Faisal August 13, 2011 @ 10:31 PM
Reply
10. ab yeh sahi kar bhi liya hai tab bhi net nahi chal rahaa hai plz help me ab kia karo yeh load balasing is liye kar rha hoo is se net ki 4mb aur 4mb ke speed
8 ati hai is liye plz ab dekhye kia karoblam hai
Comment by Aman Manifarooqi August 5, 2011 @ 6:59 PM
Reply
This is nth base load balancing which will give you some problems in steaming , https web sites etc. but try it anyways since its the simplest way to do
load balance.
Make some changes to your ip scheme.
Change Local interface ip to 10.0.0.1
Change WAN1 ip to 192.168.1.1
Change WAN2 ip to 192.168.2.1
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

5/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Change WAN1 DSL ROUTER LAN ip to 192.168.1.2


Change WAN2 DSL ROUTER LAN ip to 192.168.2.2
Now moving on to script.
/ ip address
add address=10.0.0.1 network=10.0.0.0 broadcast=10.0.0.255 interface=Local comment= disabled=no
add address=192.168.1.1/24 network=192.168.1.0 broadcast=192.168.1.255 interface=wan1 comment= disabled=no
add address=192.168.2.1/24 network=192.168.2.0 broadcast=192.168.2.255 interface=wan2 comment= disabled=no
/ ip firewall mangle
add chain=prerouting in-interface=Local connection-state=new nth=2,1 action=mark-connection new-connection-mark=conn1 passthrough=yes
comment= disabled=no
add chain=prerouting in-interface=Local connection-mark=conn1 action=mark-routing new-routing-mark=conn1 passthrough=no comment=
disabled=no
add chain=prerouting in-interface=Local connection-state=new nth=1,1 action=mark-connection new-connection-mark=conn2 passthrough=yes
comment= disabled=no
add chain=prerouting in-interface=Local connection-mark=conn2 action=mark-routing new-routing-mark=conn2 passthrough=no comment=
disabled=no
/ ip firewall nat
add chain=srcnat connection-mark=conn1 action=masquerade out-interface=wan1 comment= disabled=no
add chain=srcnat connection-mark=conn2 action=masquerade out-interface=wan2 comment= disabled=no
/ ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.2 scope=255 target-scope=10 routing-mark=conn1 comment= disabled=no
add dst-address=0.0.0.0/0 gateway=192.168.2.2 scope=255 target-scope=10 routing-mark=conn2 comment= disabled=no
Comment by Pinochio / zaib August 6, 2011 @ 6:32 AM
Reply
would you please give me Mikrotik DUAL WAN Load Balancing using PCC method in simple word i need 4WAN merging
Comment by zain ul abdin January 26, 2012 @ 4:16 PM
Can you be more specific what you meant by Simple Words
The tutorial is complete reference guide. You can use it and modify it according to your need.
Comment by Syed Jahanzaib / Pinochio~:) January 27, 2012 @ 11:23 AM
11. thnaks you it is work
Comment by Aman Manifarooqi August 15, 2011 @ 11:06 PM
Reply
12. plz sir help me how pcc load balasing 3.22
Comment by Aman Manifarooqi August 15, 2011 @ 11:08 PM
Reply
13. I have implemented DUAL (2) WAN Load Balancing using PCC method and it is working fine without hotspot. But I want to implement this PCC
method with hotspot service. Please let me know what I should do now.
Comment by Kafi August 22, 2011 @ 11:45 AM
Reply
Dear Kafi,
I have never tested load balancing with HOTSPOT scenario, but what I have heard or read at forums, hotspot messes with load balancing method. But
give it a try and share your experience with us.
Comment by Pinochio / zaib August 22, 2011 @ 11:51 AM
Reply
14. Salam bhai
see pics below is this possible or not
http://forum.mikrotik.com/download/file.php?id=7740
http://forum.mikrotik.com/download/file.php?id=7739
http://forum.mikrotik.com/download/file.php?id=7738
Comment by usmans August 23, 2011 @ 12:49 PM
Reply
Yes this is very much possible achieving this kind of load balancing. Even RRD can get equal LB, but I will not recommend you to use RDD base
algorithm as it have some issues with many sites n protocols. Use PCC instead.
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

6/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Just make sure that all users are hitting Mikrotik directly (where PCC is configured)
The more users load you put on PCC, the better load balancing you will be able to get.
Comment by Pinochio / zaib August 24, 2011 @ 10:50 AM
Reply
Wow. Amazing..
How to do this with 2 WAN only?
Comment by Danish Jamil April 3, 2012 @ 1:52 PM
Reply
15. bhai mai ny 2 pc mai mikrotik install kia hai 1 mai load balancing ki hai aur dosry mai user add hai aur per connetion classifier ko ma ny dst address pa
set kia hai. kia yeh sahi hai yaha is sy b better ho akta hai..
dsl1
dsl2mikrotik pcc (dst address)mikrotik pppoe server-clients
dsl3
Comment by usmans August 28, 2011 @ 1:01 AM
Reply
usman bhai mujay apna koi contect nuber dain plz mene loadbalsing ki kuch help lani hai app se
Comment by sadaq July 30, 2012 @ 8:38 AM
Reply
16. dst-address works fine too. All depend on your usage scenario.
You can configure pcc and pppoe on the same server. in this way you can use src-address as your classifier.
Comment by Pinochio / zaib August 28, 2011 @ 10:54 AM
Reply
17. bhai agar mai pcc aur pppoe same sever mai configure karta ho to jab mai us mai thunder cache ka mangle rule add karta ho to wo work nai kartais liy
mai 2 server use kar raha ho.
Comment by usmans August 28, 2011 @ 2:07 PM
Reply
18. Great to use PCC to load balance, but I dont know Im using nth is better at my network
Comment by another mikrotik tips September 24, 2011 @ 9:30 AM
Reply
PCC is a very customizable and enhanced version of Load balancing as compared to NTH . Using PCC you can get rid of many problems found in
NTH, for example, broken http/https link, streaming issues and some others. (Using pcc with src-address as classifier.)
Anyhow if NTH is fulfilling your requirements and you are satisfied with the results, you can stick with it as loon as it doesnt bother you
Comment by Pinochio~:) September 24, 2011 @ 10:30 AM
Reply
19. im having one wan link- 4 Mb ,another one is 2Mb,
is it is possible to loadbalance with pcc
Comment by tamilmaran October 28, 2011 @ 8:31 AM
Reply
yes you can,
Just give create more pcc rule to give priority to 4mb rule, so 2mb will be used twice as compare to 2 mb, to get some balanced load balancing.
Comment by Pinochio~:) October 28, 2011 @ 12:33 PM
Reply
can u pls , edit n give me the script,
im poor in scripting
Comment by tamilmaran June 26, 2012 @ 12:02 AM
20. Hi,
I also have rb750. Now I want to do load balancing on 2 dsl lines. How will I know that port 1 is Local, port 2 is WAN1 ans so on?
Also for WAN1 dsl is the ip address 192.168.1.1?
And for WAN2 dsl is the ip address 192.168.2.1?
Comment by Nouman Aziz November 12, 2011 @ 4:59 PM
Reply
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

7/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

You can check port status by various ways.


Following command will blink the port light.
/interface ethernet blink ether1
OR
/interface ethernet monitor ether1
/interface ethernet monitor ether2
/interface ethernet monitor ether3
Comment by Pinochio~:) November 14, 2011 @ 10:38 AM
Reply
Sir
I want to access winbox from wan port.please advice ,,,,,i have public static ip at my adsl router .i have add port forwading in router port is
8291 : what i do at my 750GL router .microtik router wan ip is 192.168.0.100 and adsl router lan ip is 192.168.0.1please advice \
Regards
Comment by faisalmirzapk April 10, 2013 @ 7:18 PM
21. dear sir,
i want to implement fcc method with pppoe server in 1mikrotik OS x86 pc..
how to do that?
kindly help me ASAP;)
Comment by fareed November 16, 2011 @ 9:14 AM
Reply
PCC with PPPoE Server on single Mikrotik Server. Read the following link
http://aacable.wordpress.com/2011/08/29/mikrotik-4-wan-load-balancing-using-pcc-with-pppoe-server-complete-script/
Comment by Pinochio~:) November 16, 2011 @ 10:33 AM
Reply
22. i have 2 Satellite internet connections and i want to do loadbalancing and i have 2 diffrent public ips.
Comment by fareed November 16, 2011 @ 9:17 AM
Reply
23. Thankx For Help
Comment by Mazhar Sheikh November 16, 2011 @ 3:28 PM
Reply
24. 3 wan load balancing, no need to set static IP to the interfaces;
multiple ADSL services and the Mikrotik PCC rules along with some inbound mangling to allow a single router to load balance traffic across as many
non bonded links as required.
credits to: http://www.mikrotik-routeros.com/?p=12
Note that none of this config requires the use of IP addresses at all, as it simply uses the pppoe-client interfaces and your lan interface to mark traffic. In
my example wan1-pppoe,wan2-pppoe,wan3-pppoe are used and lan
/ip route
add check-gateway=arp comment=WAN 3 Distance 1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan3-pppoe routing-mark=wan3
add check-gateway=arp comment=WAN 2 Distance 1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan2-pppoe routing-mark=wan2
add check-gateway=arp comment=WAN 1 Distance 1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan1-pppoe routing-mark=wan1
add check-gateway=arp comment=WAN 1 Distance 2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan2-pppoe routing-mark=wan1
add check-gateway=arp comment=WAN 2 Distance 2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan3-pppoe routing-mark=wan2
add check-gateway=arp comment=WAN 3 Distance 2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan1-pppoe routing-mark=wan3
add check-gateway=arp comment=WAN 1 Distance 3 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan3-pppoe routing-mark=wan1
add check-gateway=arp comment=WAN 2 Distance 3 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan1-pppoe routing-mark=wan2
add check-gateway=arp comment=WAN 3 Distance 3 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan2-pppoe routing-mark=wan3
add check-gateway=arp comment=Default Route Distance 1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan1-pppoe
add check-gateway=arp comment=Default Route Distance 2 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan3-pppoe
add check-gateway=arp comment=Default Route Distance 3 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan2-pppoe
add check-gateway=arp comment=Static Route WAN1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan1-pppoe routing-mark=static-wan1
add check-gateway=arp comment=Static Route WAN2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan2-pppoe routing-mark=static-wan2
add check-gateway=arp comment=Static Route WAN3 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan3-pppoe routing-mark=static-wan3

/ip firewall mangle


http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

8/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

/ip firewall mangle


add action=mark-connection chain=input comment=Mark new inbound connection wan1 connection-state=new disabled=no in-interface=wan1-pppoe
new-connection-mark=wan1 \
passthrough=yes
add action=mark-connection chain=input comment=Mark new inbound connection wan2 connection-state=new disabled=no in-interface=wan2-pppoe
new-connection-mark=wan2 \
passthrough=yes
add action=mark-connection chain=input comment=Mark new inbound connection wan3 connection-state=new disabled=no in-interface=wan3-pppoe
new-connection-mark=wan3 \
passthrough=yes
add action=mark-connection chain=prerouting comment=Mark established inbound connection wan1 connection-state=established disabled=no ininterface=wan1-pppoe \
new-connection-mark=wan1 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark established inbound connection wan2 connection-state=established disabled=no ininterface=wan2-pppoe \
new-connection-mark=wan2 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark established inbound connection wan3 connection-state=established disabled=no ininterface=wan3-pppoe \
new-connection-mark=wan3 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark related inbound connection wan1 connection-state=related disabled=no ininterface=wan1-pppoe \
new-connection-mark=wan1 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark related inbound connection wan2 connection-state=related disabled=no ininterface=wan2-pppoe \
new-connection-mark=wan2 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark related inbound connection wan3 connection-state=related disabled=no ininterface=wan3-pppoe \
new-connection-mark=wan3 passthrough=yes
add action=mark-routing chain=output comment=Mark new inbound route wan1 connection-mark=wan1 disabled=no new-routing-mark=static-wan1
passthrough=no
add action=mark-routing chain=output comment=Mark new inbound route wan2 connection-mark=wan2 disabled=no new-routing-mark=static-wan2
passthrough=no
add action=mark-routing chain=output comment=Mark new inbound route wan3 connection-mark=wan3 disabled=no new-routing-mark=static-wan3
passthrough=no
add action=mark-connection chain=prerouting comment=Mark traffic that isnt local with PCC mark rand (3 possibilities) option 1 connectionstate=new disabled=no \
dst-address-type=!local in-interface=lan new-connection-mark=wan1_pcc_conn passthrough=yes per-connection-classifier=both-addresses:3/0
add action=mark-connection chain=prerouting comment=Mark traffic that isnt local with PCC mark rand (3 possibilities) option 2 connectionstate=new disabled=no \
dst-address-type=!local in-interface=lan new-connection-mark=wan2_pcc_conn passthrough=yes per-connection-classifier=both-addresses:3/1
add action=mark-connection chain=prerouting comment=Mark traffic that isnt local with PCC mark rand (3 possibilities) option 3 connectionstate=new disabled=no \
dst-address-type=!local in-interface=lan new-connection-mark=wan3_pcc_conn passthrough=yes per-connection-classifier=both-addresses:3/2
add action=mark-connection chain=prerouting comment=Mark established traffic that isnt local with PCC mark rand (3 possibilities) option 1
connection-state=\
established disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan1_pcc_conn passthrough=yes per-connection-classifier=\
both-addresses:3/0
add action=mark-connection chain=prerouting comment=Mark established traffic that isnt local with PCC mark rand (3 possibilities) option 2
connection-state=\
established disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan2_pcc_conn passthrough=yes per-connection-classifier=\
both-addresses:3/1
add action=mark-connection chain=prerouting comment=Mark established traffic that isnt local with PCC mark rand (3 possibilities) option 3
connection-state=\
established disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan3_pcc_conn passthrough=yes per-connection-classifier=\
both-addresses:3/2
add action=mark-connection chain=prerouting comment=Mark related traffic that isnt local with PCC mark rand (3 possibilities) option 1 connectionstate=related \
disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan1_pcc_conn passthrough=yes per-connection-classifier=bothaddresses:3/0
add action=mark-connection chain=prerouting comment=Mark related traffic that isnt local with PCC mark rand (3 possibilities) option 2 connectionstate=related \
disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan2_pcc_conn passthrough=yes per-connection-classifier=bothaddresses:3/1
add action=mark-connection chain=prerouting comment=Mark related traffic that isnt local with PCC mark rand (3 possibilities) option 3 connectionstate=related \
disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan3_pcc_conn passthrough=yes per-connection-classifier=bothaddresses:3/2
add action=mark-routing chain=prerouting comment=Mark routing for PCC mark option 1 connection-mark=wan1_pcc_conn disabled=no newrouting-mark=wan1 passthrough=\
yes
add action=mark-routing chain=prerouting comment=Mark routing for PCC mark option 2 connection-mark=wan2_pcc_conn disabled=no newrouting-mark=wan2 passthrough=\
yes
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

9/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

add action=mark-routing chain=prerouting comment=Mark routing for PCC mark option 3 connection-mark=wan3_pcc_conn disabled=no newrouting-mark=wan3 passthrough=\
yes
Comment by adrian November 26, 2011 @ 7:25 AM
Reply
Hi, what about NAT rules ? (script in IP-Firewall-NAT)
Comment by esalehnet November 29, 2012 @ 1:30 AM
Reply
25. is is working OK to me, after I modified a bit to use only 2 wans on my router
Comment by adrian November 26, 2011 @ 7:29 AM
Reply
26. Jahanzaib Bhai I need your help Would you.
Comment by Umair Hanif December 4, 2011 @ 8:28 PM
Reply
Regarding ???
Comment by Pinochio~:) December 7, 2011 @ 10:42 AM
Reply
i have mikrotik 3.22 and i want to use 2 WAN link load balancing
Comment by umair December 13, 2011 @ 11:03 PM
You need at least ver 3.30 for pcc base load balancing.
Comment by Pinochio~:) December 14, 2011 @ 10:42 AM
27. I have upgraded to version 3.30
Comment by umair December 14, 2011 @ 11:46 PM
Reply
28. These are great scripts, but could you possibly explain how to change the gateway check to check a remote IP address rather than the gateway IP address
(for instances where the DSL line may be down, but the modem still up) im sure its not as easy as just changing the ip address in the check?
Comment by David December 22, 2011 @ 4:26 PM
Reply
You are right, its not that easy to integrate netwatch with the PCC.
I stopped working on this script long time ago. I will do some r&d on it and will update the article accordingly.
Comment by Pinochio~:) December 23, 2011 @ 10:59 AM
Reply
Salam Dear Sir ,
Sir ap kasy hai .umied hai k ap thek hai .ALLAH ap per desta shufqat rakha.Sir main UBNT wireless setup laga raha hun.Aur sir mujha ap say kuch
help ke zaroorat hai .wo ya k main us k liya mikrotik ka kon sa ver use karun uar mikrotik ruterbord kon sa purchas karun.qk es ma humara pass
dedicated links be hai .aur SIR humara owner ya chata hai k ptcl jasie wireless modem ma setting ho.
SIR Cache server be creat karna hai kindly ap us ka be bta dijya ga. Sir main umied karta hun k ap jaldi aur bhater jawab send kary gia.
Waqas sabir from Faisalabad.
E-mail = the2ndlastguy@yahoo.com
Mob= 03157215729
Comment by Muhammad Waqas Sabir August 30, 2012 @ 10:54 PM
Reply
29. Hi,
Sir I have done dual wan load balancing on MK RB750 v 5.9. I have two 4 mbps connection.
The problem I am facing is the second dsl line is not much is use. Sometimes I get 7-8 mB speed but sometimes it drops out so I just left with the 4MB.
Any thoughts or suggestions?
Thanks.
Comment by Nouman Aziz December 23, 2011 @ 1:05 AM
Reply
If sometimes you able to get 7-8 mbps , then your PCC is configure okay.
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

10/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

If sometimes you able to get 7-8 mbps , then your PCC is configure okay.
what classifier are you using?
Comment by Pinochio~:) December 23, 2011 @ 10:57 AM
Reply
30. I am using Dst.Address for both lines.
Comment by Nouman Aziz December 25, 2011 @ 12:10 AM
Reply
It will happen if you use dst-address, for example if there are 10 online users and 8 of them are using you tube.com, then PCC will bind you-tube at
first dsl link, and other web at other link.
You have to read a lot on PCC classifier, goto wiki and read thoroughly then play with this option.
Comment by Pinochio~:) December 25, 2011 @ 9:44 AM
Reply
31. So which classifier should I use?
Comment by Nouman Aziz December 25, 2011 @ 10:09 AM
Reply
32. Can you please explain me which classifier do I change and how?
Thanks.
Comment by Nouman Aziz December 25, 2011 @ 12:43 PM
Reply
Dear Noman,
I guess its time for you to do some research and read teh mikrotik wiki on How PCC works. Please start with this one and you will get idea on which
classifier is best for you.
http://wiki.mikrotik.com/wiki/How_PCC_works_(beginner)
After all its your network and you have to decide what classifer to use depends on your network usage. Please Read, Read and Read.
Comment by Pinochio~:) December 25, 2011 @ 10:17 PM
Reply
33. ok Thanks/.
Comment by Nouman December 26, 2011 @ 1:04 AM
Reply
34. sir muhe yee bataye ke x86 main bhi pcc load balasing ho sakti hai
Comment by noman December 31, 2011 @ 7:20 PM
Reply
It doesnt matter what architecture you use , you can do it on x86 or any RB.
Just make sure you use ver 3.30 or above.
preferably latest 5.x series.
Comment by Pinochio~:) December 31, 2011 @ 9:17 PM
Reply
min ne computer par install kia hai mikrotik ko pcc load balasing chaliy gi
Comment by noman December 31, 2011 @ 9:23 PM
yes if u configure it properly.
Comment by Syed Jahanzaib / Pinochio~:) January 2, 2012 @ 9:59 AM
35. Sir, This load balancing works great when we put a load on it (browse heavy site, or watch youtube). Is there any way to keep both WANs alive and
working equally.
For example even when we browse lite sites it should use both lines 50/50.
Thanks
Comment by nominet January 4, 2012 @ 3:45 PM
Reply
Try using different classifier.
There are 8 various, test which one works for you best
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

11/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Comment by Syed Jahanzaib / Pinochio~:) January 4, 2012 @ 4:03 PM


Reply
36. I have tried them and I liked scr-address and both-addresses and ports one.
Comment by Nouman January 5, 2012 @ 12:26 AM
Reply
37. Sir what is failover?
Comment by Ayoob January 6, 2012 @ 1:30 AM
Reply
Failover It will always check the modem status before sending any packets, If the modem is not reachable it will not send the packets.
Comment by Syed Jahanzaib / Pinochio~:) January 6, 2012 @ 10:55 AM
Reply
38. I want to add another WAN3 with the ip 192.168.3.1
Can you please write a script for me thanks.
Comment by Asad January 6, 2012 @ 11:27 AM
Reply
/ip route
add check-gateway=arp comment=WAN 3 Distance 1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan3-pppoe routing-mark=wan3
add check-gateway=arp comment=WAN 2 Distance 1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan2-pppoe routing-mark=wan2
add check-gateway=arp comment=WAN 1 Distance 1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan1-pppoe routing-mark=wan1
add check-gateway=arp comment=WAN 1 Distance 2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan2-pppoe routing-mark=wan1
add check-gateway=arp comment=WAN 2 Distance 2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan3-pppoe routing-mark=wan2
add check-gateway=arp comment=WAN 3 Distance 2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan1-pppoe routing-mark=wan3
add check-gateway=arp comment=WAN 1 Distance 3 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan3-pppoe routing-mark=wan1
add check-gateway=arp comment=WAN 2 Distance 3 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan1-pppoe routing-mark=wan2
add check-gateway=arp comment=WAN 3 Distance 3 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan2-pppoe routing-mark=wan3
add check-gateway=arp comment=Default Route Distance 1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan1-pppoe
add check-gateway=arp comment=Default Route Distance 2 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan3-pppoe
add check-gateway=arp comment=Default Route Distance 3 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan2-pppoe
add check-gateway=arp comment=Static Route WAN1 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=wan1-pppoe routing-mark=staticwan1
add check-gateway=arp comment=Static Route WAN2 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=wan2-pppoe routing-mark=staticwan2
add check-gateway=arp comment=Static Route WAN3 disabled=no distance=3 dst-address=0.0.0.0/0 gateway=wan3-pppoe routing-mark=staticwan3
/ip firewall mangle
add action=mark-connection chain=input comment=Mark new inbound connection wan1 connection-state=new disabled=no in-interface=wan1pppoe new-connection-mark=wan1 \
passthrough=yes
add action=mark-connection chain=input comment=Mark new inbound connection wan2 connection-state=new disabled=no in-interface=wan2pppoe new-connection-mark=wan2 \
passthrough=yes
add action=mark-connection chain=input comment=Mark new inbound connection wan3 connection-state=new disabled=no in-interface=wan3pppoe new-connection-mark=wan3 \
passthrough=yes
add action=mark-connection chain=prerouting comment=Mark established inbound connection wan1 connection-state=established disabled=no ininterface=wan1-pppoe \
new-connection-mark=wan1 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark established inbound connection wan2 connection-state=established disabled=no ininterface=wan2-pppoe \
new-connection-mark=wan2 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark established inbound connection wan3 connection-state=established disabled=no ininterface=wan3-pppoe \
new-connection-mark=wan3 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark related inbound connection wan1 connection-state=related disabled=no ininterface=wan1-pppoe \
new-connection-mark=wan1 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark related inbound connection wan2 connection-state=related disabled=no ininterface=wan2-pppoe \
new-connection-mark=wan2 passthrough=yes
add action=mark-connection chain=prerouting comment=Mark related inbound connection wan3 connection-state=related disabled=no ininterface=wan3-pppoe \
new-connection-mark=wan3 passthrough=yes
add action=mark-routing chain=output comment=Mark new inbound route wan1 connection-mark=wan1 disabled=no new-routing-mark=staticwan1 passthrough=no
add action=mark-routing chain=output comment=Mark new inbound route wan2 connection-mark=wan2 disabled=no new-routing-mark=statichttp://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

12/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

wan2 passthrough=no
add action=mark-routing chain=output comment=Mark new inbound route wan3 connection-mark=wan3 disabled=no new-routing-mark=staticwan3 passthrough=no
add action=mark-connection chain=prerouting comment=Mark traffic that isnt local with PCC mark rand (3 possibilities) option 1 connectionstate=new disabled=no \
dst-address-type=!local in-interface=lan new-connection-mark=wan1_pcc_conn passthrough=yes per-connection-classifier=both-addresses:3/0
add action=mark-connection chain=prerouting comment=Mark traffic that isnt local with PCC mark rand (3 possibilities) option 2 connectionstate=new disabled=no \
dst-address-type=!local in-interface=lan new-connection-mark=wan2_pcc_conn passthrough=yes per-connection-classifier=both-addresses:3/1
add action=mark-connection chain=prerouting comment=Mark traffic that isnt local with PCC mark rand (3 possibilities) option 3 connectionstate=new disabled=no \
dst-address-type=!local in-interface=lan new-connection-mark=wan3_pcc_conn passthrough=yes per-connection-classifier=both-addresses:3/2
add action=mark-connection chain=prerouting comment=Mark established traffic that isnt local with PCC mark rand (3 possibilities) option 1
connection-state=\
established disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan1_pcc_conn passthrough=yes per-connection-classifier=\
both-addresses:3/0
add action=mark-connection chain=prerouting comment=Mark established traffic that isnt local with PCC mark rand (3 possibilities) option 2
connection-state=\
established disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan2_pcc_conn passthrough=yes per-connection-classifier=\
both-addresses:3/1
add action=mark-connection chain=prerouting comment=Mark established traffic that isnt local with PCC mark rand (3 possibilities) option 3
connection-state=\
established disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan3_pcc_conn passthrough=yes per-connection-classifier=\
both-addresses:3/2
add action=mark-connection chain=prerouting comment=Mark related traffic that isnt local with PCC mark rand (3 possibilities) option 1
connection-state=related \
disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan1_pcc_conn passthrough=yes per-connection-classifier=bothaddresses:3/0
add action=mark-connection chain=prerouting comment=Mark related traffic that isnt local with PCC mark rand (3 possibilities) option 2
connection-state=related \
disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan2_pcc_conn passthrough=yes per-connection-classifier=bothaddresses:3/1
add action=mark-connection chain=prerouting comment=Mark related traffic that isnt local with PCC mark rand (3 possibilities) option 3
connection-state=related \
disabled=no dst-address-type=!local in-interface=lan new-connection-mark=wan3_pcc_conn passthrough=yes per-connection-classifier=bothaddresses:3/2
add action=mark-routing chain=prerouting comment=Mark routing for PCC mark option 1 connection-mark=wan1_pcc_conn disabled=no newrouting-mark=wan1 passthrough=\
yes
add action=mark-routing chain=prerouting comment=Mark routing for PCC mark option 2 connection-mark=wan2_pcc_conn disabled=no newrouting-mark=wan2 passthrough=\
yes
add action=mark-routing chain=prerouting comment=Mark routing for PCC mark option 3 connection-mark=wan3_pcc_conn disabled=no newrouting-mark=wan3 passthrough=\
yes
after that all you need to do is make your 3 pppoe client conections coresponding to your wans, pppoe client cone3ctions with user and pass provided
from yout ISP, and in NATmake a masquerade in ip firewall nat click + to add net nat rule, Chain scrnat.than go to Action tab and select
masquerade that is all
this config is the config that I am using on a rb750, for 3 wans
Comment by Acidu January 6, 2012 @ 6:40 PM
Reply
39. Hi Sir,
What is the function of distance in routes?
Comment by Asad January 6, 2012 @ 8:34 PM
Reply
40. Hi, thanks for the great howto. I have a setup with 2 WANs and when I vpn to the router I can no longer ping or connect to the local addresses.
Local interface is: 192.168.0.0/24
VPN local address is: 10.0.1.100
VPN remote address is: 10.0.2.100
Before setting up the load balancing I was able to connect to 192.168.0.102 or 192.168.0.101.
Comment by quinametin January 18, 2012 @ 10:05 AM
Reply
Just create an address list (vpn subnet included) and on the mangle rules exclude them , e.g src-address-list=!pptpusers and dst-addresslist=!pptpusers
For more info, read comments in following article, few guiys made it worked with pcc.
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

13/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

http://aacable.wordpress.com/2011/06/04/mikrotik-4-wan-load-balance-pcc-complete-script-by-zaib/
Comment by Syed Jahanzaib / Pinochio~:) January 18, 2012 @ 10:38 AM
Reply
Ok, found it

I had to add to firewall -> nat a masquerade with the source 10.0.2.0/24

Comment by quinametin January 18, 2012 @ 11:14 AM


Reply
gr8.
Comment by Syed Jahanzaib / Pinochio~:) January 18, 2012 @ 11:18 AM
41. Which classifier should I use? I want 4 + 4 = 8. So traffic should spread aross them two links.
Thanks.
Comment by Bablu January 18, 2012 @ 1:54 PM
Reply
Use both addressess and ports approach.
Comment by Syed Jahanzaib / Pinochio~:) January 18, 2012 @ 5:37 PM
Reply
42. Jitna b Geo Khushi se Geo. Ye Bablu ki dua ha Jahanzaib Bhai.
Comment by Bablu January 19, 2012 @ 3:29 PM
Reply
Comment by Syed Jahanzaib / Pinochio~:) January 20, 2012 @ 10:46 AM
Reply
43. Hello,
Thank you for helpful posts,
I little bit confused with IP addresses and how to setup load balance with my RB750G.
I have 2 ADSL from same ISP with 2 linksys modems with static external IP and 10M speed each.I cannot access the modems they r locked by ISP. I just
getting internal IP by DHCP in range 192.168.1.1/254.
On both modems are same gateway address 192.168.1.1 and same IP range.
How can I configure load balancing????
Please help!!!! Need ASAP!!!
Thank you in advance!!!
Nikos
Comment by Nikos January 25, 2012 @ 2:11 AM
Reply
Move them on different subnet.
For example
ISP DSL Modems:
DSL1 = 192.168.1.1
DSL2 = 192.168.2.1
Mikrotik:
WAN1 = 192.168.1.2 / GW > 192.168.1.1
WAN2 = 192.168.2.2 / GW > 192.168.2.1
This way things will get simpler and manageable for you.
You can use static ip on you mikrotik wan interface of same subnet series provided by the modem.
Comment by Syed Jahanzaib / Pinochio~:) January 25, 2012 @ 10:56 AM
Reply
Thank you for fast response,
The problem is that I cannot change DSL2 to 192.168.2.1 its locked by ISP and both DSL modems had same 192.168.1.1.
In my scenario it will be something like this :
DSL1:192.168.1.1==>WAN1=192.168.1.2
DSL2:192.168.1.1==>WAN2=192.168.1.3
This will work or NOT???
Please advice !!!
Thank you in advance
Nikos
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

14/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Comment by Nikos January 25, 2012 @ 7:12 PM


I have not tested such scenario, in my opinion it should not work.
Comment by Syed Jahanzaib / Pinochio~:) January 26, 2012 @ 10:55 AM
!Try defining the outbound interface.
For example replace this.
/ip route
add dst-address=0.0.0.0/0 gateway=1.2.3.4 routing-mark=to_wan-ISP1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=1.2.3.4 routing-mark=to_wan-ISP2 check-gateway=ping
With following
/ip route
add dst-address=0.0.0.0/0 gateway=1.2.3.4%eth1-ISP routing-mark=to_wan-ISP1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=1.2.3.4%eth2-ISP routing-mark=to_wan-ISP2 check-gateway=ping
Replace the eth1-ISP with your own wan itnerface name , use the notation % for sure.
If it works , let me know
Regards
Comment by Syed Jahanzaib / Pinochio~:) October 21, 2013 @ 11:59 AM
Reply
44. Alsalamu Alaykom
Dear Brother can you please send me a Backup file for RB 750 Load Balance ?
Comment by Moataz Ibrahem January 30, 2012 @ 11:02 PM
Reply
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/
Comment by Syed Jahanzaib / Pinochio~:) January 30, 2012 @ 11:08 PM
Reply
45. sir main ne pcc load balasing ki hai load balasing to sahi hai par dhcp par webproxy nahi chal rahey plz help me
Comment by mani January 31, 2012 @ 12:05 AM
Reply
If you upgrade to 4.x thats relatively easy to do because it has a feature that can match connections that do not yet have a connection mark.
I will not recommend you to use mikrotik webproxy with pcc on same box, It is recommended to use external proxy like SQUID or ISA. Upgrade to
new version and it will be easy for you to use mikrotik web proxy.
/ip firewall mangle
add chain=output connection-mark=no-mark action=mark-connection new-connection-mark=Internet1_conn passthrough=yes per-connectionclassifier=both-addresses:2/0
add chain=output connection-mark=no-mark action=mark-connection new-connection-mark=Internet2_conn passthrough=yes per-connectionclassifier=both-addresses:2/1
On 3.x the rule set would be quite much more complicated to make sure you dont interfere with potentially existing connection marks that must not
be changed, so hopefully you can upgrade to 4.x
Comment by Syed Jahanzaib / Pinochio~:) January 31, 2012 @ 2:31 PM
Reply
46. sir this script not work as failover it works only when modem turned off
in the case when modem power is on but the modem is disconnect failover not work 100% sure
sir i want a solution for failover free or paid not matter but perfect solution
my id is zohaib.shakeel1@yahoo.com
Comment by salman January 31, 2012 @ 10:45 PM
Reply
47. Aslam O Alikum Syed Jahanzaib Bahi
My DSL 4MB PTCL
I m Use Hotspot Par User 1MB Speed And 512k My Thinking Is a User End Download Speed Is Limited
But Browsing Full 4MB Speed Please Add This Script And Send Me
My ID waseemahmed147@yahoo.com
I m use 3.22 v
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

15/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Thank You
Comment by WASEEM AHMED February 1, 2012 @ 5:12 AM
Reply
48. hi
i have 16 mb pipe connected with 4 wan tplink load balancer , and load balancer connect with mikro tik OS installed on pc i configured dns, firewall, web
proxy correctly but my browsing speed is too slow. is in mikrotik there is place to mention wan link rate, means does mikro tik required the link rate in
Wan link. if yes then plzz tell me becoz i m watching all time my wan link in interface option it never rich to 16 mb infect it is not crossing 4 mb in all time
pick time non pick time guide me as soon as possible thxzzzzzzzzzzzzz
Comment by rehmat ali gulwating February 7, 2012 @ 3:50 AM
Reply
Slow browsing , hmmm there can be multiple issue, I told you earlier, make sure all of your client is using your mikrotik as there primary DNS
server,
secondly, using IDM , try to download 10-15 multiple files (Big downloads) and see if you can able to download from all links.
Comment by Syed Jahanzaib / Pinochio~:) February 7, 2012 @ 9:34 AM
Reply
49. DEAR.
YES I CAN USE 16 MB PIPE WITH IDM BUT 1 TROUBLE I FIND THAT WHEN I PING TO TPLINK IP 192.168.205.1 REPLY IN 1 OR 2 MS CONTINUE
SLY BUT WHEN I PING PTCL MODEM LAN IP (192.168.201.1 MODEM 1,192.168.202.1 MODEM 2, 192.168.203.1 MODEM 3,192.168.204.1 MODEM 4)
SOME TIME PING REPLY IN 6 TO 7 MS AND SOME TIMES REQUEST TIME OUT OCCURS I CHANGE LAN CARDS OF MIKROTIK BUT NOTHING
HAPPENED AND WHEN I CONNECT TPLINK LOADBALANCER DIRECT 2 WINDOWS PC PING REPLIES IN 1 MS AND ALL WORKED FINE.
THEN Y PING IS BREAKING WITH MIKROTIK PLEASE GUIDE ME AND SHOOT THIS TROUBLE WITH UR GOOD EXPERIENCE THANKING
YOU,
Comment by rehmat ali gulwating February 10, 2012 @ 3:15 AM
Reply
You probably have a bad network design topology.
Also check with your queueing section, Try to disable all Queues, and thenc heck the ping reply. If ping works fine after disabling the Queue, try the
following.
http://aacable.wordpress.com/2011/12/07/mikrotik-howto-give-ping-icmp-high-priority/
Comment by Syed Jahanzaib / Pinochio~:) February 10, 2012 @ 8:58 AM
Reply
50. my name habib
Comment by a February 10, 2012 @ 9:27 PM
Reply
51. are you on line in wordpress
Comment by a February 10, 2012 @ 9:28 PM
Reply
52. Hi,
Work fine, but both-addresses-and-ports per connection classifier creates problems (eg ftp client: passive ports are open on another WAN, so the ftp
server considers it as a security violation). I recommend an both addresses pcc configuration to avoid this.
Best regards
Comment by Alexandre Alouit February 13, 2012 @ 10:33 PM
Reply
Yes you are right, both address provides more reliable connections. But for some operators who demands more bandwidth rather then reliability,
both-addresses-and-ports gives overall better load balancing, but they face broken link issues.
Comment by Syed Jahanzaib / Pinochio~:) February 14, 2012 @ 8:48 AM
Reply
53. Salam,
this is rehmat, i trace problem in my network it is from client side. i means my clients have a lots of viruses, Trojans and spammers and their pcs use tcp
and udp ports to access wan.ports are 445,80,23 which i trace out i have problem with port 80 becoz its a browsing port (http) please send me rules or any
script to block viruses,Trojans and spammers completely. or any other guide to resolve this issue. thxxxxxxxxxxx
Comment by rehmat ali gulwating February 14, 2012 @ 2:51 AM
Reply
Monitor your network closely using monitoring tools like TORCH (built-in mikrotik tool)
and block all suspected ports.)
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

16/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Few examples are here.


http://aacable.wordpress.com/2011/08/15/mikrotik-howto-prevent-mt-host-from-invalid-login-attempts-from-lanwan-users/
Comment by Syed Jahanzaib / Pinochio~:) February 14, 2012 @ 8:51 AM
Reply
54. Hi. Salam jahanzaib bhai. jahanzaib bhai i have 4 mb connection of PTCL. and main mikrotik 3.30 pay hotspot server use kr raha hun. i have 30 clients on
it . 300 gb limit ki waja say now i want to add one more 4 mb connection. Plz guide me k main kesay on ki load balancing krun. is wqt meray WAN ka
address 192.168.1.150 and LAN ka address 192.168.0.150 hai. yaa to ap yay guide kr dain k dono 4 mb ka 50/50 use ho ya phr ya bta dain k main half
clients WAN1 pay kesay krun and half WAN2 pay ? because main downloading limit ko cross nhi krna chahta. its too expensive for me if downloading
limit crossed.
Comment by SHAFQAT FARHAN February 22, 2012 @ 10:45 AM
Reply
55. and dono connections ptcl say liyay hain main nay so . dono ka ip address same hai yani k DSL1 192.168.1.1 and DSL2 192.168.1.1 and i dont have
authority to change this address.
Comment by SHAFQAT FARHAN February 22, 2012 @ 10:51 AM
Reply
First thing first.
Both links must be on different subnet, otherwise you wont be able to do proper load balance.
One workaround is to put another router (any cheap brand like tplink etc) in between mikrotik WAN2 and DSL2 and give it another subnet ip.
For example like this.
DSL1 ======> === >> MIKROTIK ROUTER ETH1
192.168.1.1 192.168.1.2
DSL2 ======> TPLINK ROUTER === >> MIKROTIK ROUTER ETH2
192.168.1.1 192.168.5.1 192.168.5.2
Also check this It might help you.
http://aacable.wordpress.com/2011/10/27/mikrotik-policy-routing-based-on-client-ip-address/
Comment by Syed Jahanzaib / Pinochio~:) February 23, 2012 @ 9:16 AM
Reply
56. thank you so much sir. now i will change the ip address of one of the DSL router. now plz tell me how could i do load balancing on hotspot server. and i
want k dono DSLs equally use hun. i mean agar total downloading (from clients) 200 GB howi hai to DSL1 say 100 GB and DSL2 say 100 GB ho. i mean i
want the average download from both of the DSL.
Comment by SHAFQAT FARHAN February 23, 2012 @ 11:51 AM
Reply
To use PCC with HOTSPOT , use the following.
http://aacable.wordpress.com/2012/02/12/mikrotik-pcc-with-hotspot/
You cant define on that how much exact amount of data should be used from each wan link.
Comment by Syed Jahanzaib / Pinochio~:) February 23, 2012 @ 11:59 AM
Reply
57. to phr kya is trah ho skta hai k main half clients WAN1 pay kr dun and half WAN2 pay. ??
Comment by SHAFQAT FARHAN February 23, 2012 @ 12:06 PM
Reply
Yes you can, see the link i have sent earlier. policy/ip base client routing
Comment by Syed Jahanzaib / Pinochio~:) February 23, 2012 @ 1:37 PM
Reply
jahanzaib bhai os policy main 2 LAN output hain. jab k meray pass situation kuch yun hai k meray pas bulletm2 hai. main wireless k through
clients ko net provide kr raha hun. so agar main 2 output krta hun to bullet main to aik he input jaey gi.
Comment by SHAFQAT FARHAN February 23, 2012 @ 8:26 PM
You can use single output (LAN) also.
The example showed in the article was not using 2 output, Both users are on same LAN.
Comment by Syed Jahanzaib / Pinochio~:) February 24, 2012 @ 9:28 AM
58. sir, give me a script of queue tree bandwith setting mikrotik rb750G please.. note: I use dual wan about it wan
Comment by aanet February 24, 2012 @ 7:22 AM
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

17/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Reply
59. dear sir
Syed Jahanzaib
sir main ne TWO wan ore ONE lan ka mikrotik server
banya hai jis ka scrpit ye hai.
((
/ip address
add address=192.168.5.1/24 network=192.168.5.0 broadcast=192.168.5.255 interface=LAN
add address=192.168.0.2/24 network=192.168.0.0 broadcast=192.168.0.255 interface=WAN1
add address=192.168.2.2/24 network=192.168.2.0 broadcast=192.168.2.255 interface=WAN2
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=208.67.220.220,208.67.222.222
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting dst-address=192.168.0.0/24 action=accept in-interface=LAN
add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=LAN
add chain=prerouting dst-address-type=!LAN in-interface=LAN per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection newconnection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!LAN in-interface=LAN per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting connection-mark=WAN1_conn in-interface=LAN action=mark-routing new-routing-mark=to_WAN1
add chain=prerouting connection-mark=WAN2_conn in-interface=LAN action=mark-routing new-routing-mark=to_WAN2
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.0.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.0.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
sir jab main internet
use karta hun tu mera server srif os wan ka interinet
use karta hai jis ki speed kam hoti hai jab k meri dosri
wan per speed kafi achi hoti hai
ek wan meri 3mbps ki hai ore dosri 4 mbps ki hai
kindly tell me a script jis se main in dono wan ko use
kar sekon yan phier asa ho in dono wan main se jis ki
speed zaida ho server os wan ko use karey kindly send
me a script jis se mera masla hal ho jaye
Comment by ali February 24, 2012 @ 9:50 PM
Reply
Your script seems fine.
Try playing with the distance value.
Comment by Syed Jahanzaib / Pinochio~:) February 25, 2012 @ 12:51 PM
Reply
yes i have licnes call me 03245001960 pta
Comment by noman March 1, 2012 @ 11:01 AM
Reply
60. jahanzaib bhai do u have some info that how can i get license of ISP from PTCL or PTA . and how much cost it have ??
Comment by SHAFQAT FARHAN February 25, 2012 @ 9:54 PM
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

18/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Reply
61. hi.. im using this script right now and i want to port forward (23156) from WAN1 to internet.. can u help me sir
Comment by nick March 5, 2012 @ 8:58 PM
Reply
62. sir meine aap ka dual wan configuration wala script use kia hai leikin mere aik wan se reply nahin aaraha
Comment by Yasir March 9, 2012 @ 9:04 PM
Reply
What is the impact you are getting because of this?
Check the DISTANCE VALUE.
Comment by Syed Jahanzaib / Pinochio~:) March 12, 2012 @ 9:04 AM
Reply
63. mein mikrotik ka os ver 3.3 use kerraha hoon
Comment by Yasir March 9, 2012 @ 9:09 PM
Reply
64. hello !
the difference with this scenario is that i have
modem 1 IP : 79.106.15.44 ( bridge with PPPoE connection with username and password) or it doesnt influence in the configuration
modem 2 IP : 79.106.15.45 ( bridge with PPPoE connection with username and password)
with gateway 79.106.14.1 or dynamic
LAN : 192.168.2.1/24
can you please help me with the configuration
regards
Comment by sidio March 12, 2012 @ 3:52 AM
Reply
65. salaam sir how are u
main pppoe server use kar rahaa hooo aap mjhe yeh batao ke dil up par kon se colore use hote hai main ne net ki waire se bjiliy gozarni hai plz tell me
Comment by musa March 19, 2012 @ 9:57 AM
Reply
66. hi,
this is Rehmat ali have to ask one thing is that i follow script given by u on this page ( http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-loadbalancing-using-pcc-method-complete-script-by-zaib/ ) .
problem is
only 1 wan is using internet named wan1 but 2nd wan named wan4 is not using similarly means with pcc method i m able to use both links in same
time? if yes then please solve this issue because it cant use both links in same time.
Wan1 route is shows as AS and in black color but Wan4 route is shows as S and in blue color.
i think problem is with ip route. reply me as soon as possible.
thanking you,
Comment by Rehmat Ali Gulwating March 20, 2012 @ 3:34 PM
Reply
67. Very Very Thanks Mr,Zaib With this script you changed my life
Comment by Haroon nimroozy March 29, 2012 @ 11:17 AM
Reply
68. Dear Bro, I m using MIKROTIK from last 2 years with these settings.
I have 4 WANS and 1 LAN. 1 wan 4Mbs, 2nd 4Mb, 3rd 6Mb and 4th is 2Mb. i splice the ip with differnet subnets and send traffic through routes. 1 group
ips gets 4 2nd group ip also 4 3rd group 6 mb and 4th group 2mb. and all users or on PPPOE.
But now i want to combine all traffic and then send it to 1 LAN. means 4 lans = 1 lan ,4+4+6+2=16 Mb. I contact many Mikrotik persons for this issue but
all in vain.
I am using RB750G 3.22v.
Need help..
Comment by Junaid April 1, 2012 @ 11:02 PM
Reply
A quick search on google can save you from posting queries
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

19/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

http://aacable.wordpress.com/2011/06/04/mikrotik-4-wan-load-balance-pcc-complete-script-by-zaib/
Comment by Syed Jahanzaib / Pinochio~:) April 2, 2012 @ 8:33 AM
Reply
Thanks a lot Brother..ill work on it then ill let u know if i faced any error..
Comment by Junaid April 4, 2012 @ 1:04 PM
69. Jahanzaib Bhai, i it Possible to have Load Balancer and Hotspot on same Machine?
Comment by Danish Jamil April 4, 2012 @ 11:42 PM
Reply
Yes its possible.
http://aacable.wordpress.com/2012/02/12/mikrotik-pcc-with-hotspot/
Comment by Syed Jahanzaib / Pinochio~:) April 5, 2012 @ 8:53 AM
Reply
70. Dear Syed,
How can we use the web proxy with your configuration (not on a box of course..)?
Comment by Alex Alouit (@alexalouit) April 8, 2012 @ 7:49 PM
Reply
You mean like the one showed here ???
http://aacable.wordpress.com/2011/12/29/howto-to-enable-mikrotik-routeros-web-proxy-in-transparent-mode/
Comment by Syed Jahanzaib / Pinochio~:) April 9, 2012 @ 8:34 AM
Reply
Yes,
unfortunately, for me it does not work.
The proxy works fine from outside (lan network), but the internal drift does not work.
My current config is:
nat
0 chain=srcnat action=masquerade src-address=192.168.2.0/24 out-interface=wan1
1 chain=srcnat action=masquerade src-address=192.168.2.0/24 out-interface=wan2
2 chain=dstnat action=redirect to-ports=3128 protocol=tcp src-address=192.168.2.0/24 dst-port=80
mangle
0 chain=input action=mark-connection new-connection-mark=WAN1_conn passthrough=yes in-interface=wan1
1 chain=input action=mark-connection new-connection-mark=WAN2_conn passthrough=yes in-interface=wan2
2 chain=output action=mark-routing new-routing-mark=to_WAN1 passthrough=yes connection-mark=WAN1_conn
3 chain=output action=mark-routing new-routing-mark=to_WAN2 passthrough=yes connection-mark=WAN2_conn
4 chain=prerouting action=accept dst-address=X.X.X.X/24 in-interface=lan
5 chain=prerouting action=accept dst-address=X.X.X.X/24 in-interface=lan
6 ;;; 80
chain=prerouting action=mark-connection new-connection-mark=WAN1_conn passthrough=yes protocol=tcp dst-address-type=!local ininterface=lan dst-port=80 per-connection-classifier=both-addresses-and-ports:2/0
7 chain=prerouting action=mark-connection new-connection-mark=WAN1_conn passthrough=yes dst-address-type=!local in-interface=lan perconnection-classifier=both-addresses:2/0
8 ;;; 80
chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes dst-address-type=!local in-interface=lan perconnection-classifier=both-addresses-and-ports:2/1
9 chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes dst-address-type=!local in-interface=lan perconnection-classifier=both-addresses:2/1
10 chain=prerouting action=mark-routing new-routing-mark=to_WAN1 passthrough=yes in-interface=lan connection-mark=WAN1_conn
11 chain=prerouting action=mark-routing new-routing-mark=to_WAN2 passthrough=yes in-interface=lan connection-mark=WAN2_conn
proxy
enabled: yes
src-address: 0.0.0.0
port: 3128
parent-proxy: 0.0.0.0
parent-proxy-port: 0
cache-administrator: webmaster
max-cache-size: none
cache-on-disk: yes
max-client-connections: 600
max-server-connections: 600
max-fresh-time: 3d
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

20/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

serialize-connections: no
always-from-cache: no
cache-hit-dscp: 4
cache-drive: primary-slave
The router runs on Router OS 5.14
Do you see that does not work?
Regards
Comment by Alex Alouit (@alexalouit) April 9, 2012 @ 8:25 PM
Error in copy/paste, my mangle config number 8 is:
chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes protocol=tcp dst-address-type=!local ininterface=lan dst-port=80 per-connection-classifier=both-addresses-and-ports:2/1
but it does affect my web proxy problem.
The problem I encounter is also valid to intercept DNS requests (cache dns transparent).
The firewall is it not challenged?
Comment by Alex Alouit (@alexalouit) April 10, 2012 @ 10:04 PM
use notepad +paste there and then copy from there and paste in new terminal
Comment by Acidu April 11, 2012 @ 1:08 AM
For the copy/paste error, I spoke about the comment, not the CLI configuration of the router..
Regards
Comment by Alex Alouit (@alexalouit) April 11, 2012 @ 5:43 PM
71. Dear Sir
I want to know these configuration also use with 750up router board ?
I want load balancing with 2 wan on 750up router board please help .
I also want load balancing using hotspot
Regards
Comment by faisalmirzapk April 8, 2012 @ 8:15 PM
Reply
The script posted in this article will work on any version of routerboard.
to use it with hotspot you should follow this.
http://aacable.wordpress.com/2012/02/12/mikrotik-pcc-with-hotspot/
Comment by Syed Jahanzaib / Pinochio~:) April 9, 2012 @ 8:33 AM
Reply
72. Dear Sir
plz help me mere pass RB750GL hai mey us pe 3 wan chalana chata ho with bondig (means merge all bandwidth ?) mere pass ye configuration hai.
4Mb = 1st DSL router address = 192.168.0.1 => ehter1 WAN
4Mb = 2nd DSL router address = 192.168.2.1 => ehter2 WAN
6Mb = 3rd DSL router address = 192.168.3.1 => ehter3 WAN
Bandwidth merge = 4Mb + 4Mb + 6Mb = 14Mbps
local network = 192.168.1.1 => ehter5
DHCP server on local network => ehter5
Bandwidth controlling in Kbps on specific IP (local address)
or kia interface ka name bhi change karna parey ga wo kese hoga ??? n plz help me step by step
mey ne apki batae hui script mey changes ki hai wo nichy hai is mey koi mistake hai ? or baqi complete script send karden
Thanks

rename the interface


?????

/ip address
02 add address=192.168.1.1/24 network=192.168.1.0 broadcast=192.168.1.255 interface=Local
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

21/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

03 add address=192.168.0.2/24 network=192.168.0.0 broadcast=192.168.0.255 interface=WAN1


04 add address=192.168.2.2/24 network=192.168.2.0 broadcast=192.168.2.255 interface=WAN2
05 add address=192.168.3.2/24 network=192.168.3.0 broadcast=192.168.3.255 interface=WAN3
06 /ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=221.132.112.8,8.8.8.8
07
08 /ip firewall mangle
09 add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
10 add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
11 add chain=input in-interface=WAN3 action=mark-connection new-connection-mark=WAN3_conn
12 add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
13 add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
14 add chain=output connection-mark=WAN3_conn action=mark-routing new-routing-mark=to_WAN3
15 add chain=prerouting dst-address=192.168.0.0/24 action=accept in-interface=Local
16 add chain=prerouting dst-address=192.168.2.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.3.0/24 action=accept in-interface=Local
17
18 add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection newconnection-mark=WAN1_conn passthrough=yes
19 add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection newconnection-mark=WAN2_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 newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection newconnection-mark=WAN3_conn passthrough=yes
20
21 add chain=prerouting connection-mark=WAN1_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN1
22 add chain=prerouting connection-mark=WAN2_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN2
23 add chain=prerouting connection-mark=WAN3_conn in-interface=Local action=mark-routing new-routing-mark=to_WAN3
24 /ip route
25 add dst-address=0.0.0.0/0 gateway=192.168.0.1 routing-mark=to_WAN1 check-gateway=ping
26 add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
27 add dst-address=0.0.0.0/0 gateway=192.168.3.1 routing-mark=to_WAN3 check-gateway=ping
28 add dst-address=0.0.0.0/0 gateway=192.168.0.1 distance=1 check-gateway=ping
29 add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
30 add dst-address=0.0.0.0/0 gateway=192.168.3.1 distance=3 check-gateway=ping
31 /ip firewall nat
32 add chain=srcnat out-interface=WAN1 action=masquerade
33 add chain=srcnat out-interface=WAN2 action=masquerade
34 add chain=srcnat out-interface=WAN3 action=masquerade

DHCP SERVER also

Bandwith controlling
???????
THANKS
Regards
Ehtisham Ul Haq
Comment by Ehtisham Ul Haq April 11, 2012 @ 12:18 PM
Reply
change the lines from
18 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
19 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 dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/1 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection newconnection-mark=WAN3_conn passthrough=yes
TO below lines
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

22/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

TO below lines
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:3/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:3/1
action=mark-connection new-connection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:3/2
action=mark-connection new-connection-mark=WAN3_conn passthrough=yes
Comment by Syed Jahanzaib / Pinochio~:) April 11, 2012 @ 1:14 PM
Reply
thanks Sir plz send me also interface rename script and DHCP server
Comment by Ehtisham Ul Haq April 11, 2012 @ 1:47 PM
Dear Sir
this script is working in my case ??
ip dhcp-server> setup
Select interface to run DHCP server on
dhcp server interface: local
Select network for DHCP addresses
dhcp address space: 192.168.1.0/24
Select gateway for given network
gateway for dhcp network: 192.168.1.1
Select pool of ip addresses given out by DHCP server
addresses to give out: 192.168.1.25-192.168.1.254
Select DNS servers
dns servers: 192.168.1.1
Select lease time
lease time: 3d
Comment by Ehtisham Ul Haq April 11, 2012 @ 2:11 PM
73. Dear Bro. how can we use User Manager and manage users and their accounting on v3.3 with level4 license. if their some solution please tell me how can
i do it.
Comment by Junaid April 11, 2012 @ 4:49 PM
Reply
74. Hi, I have an address-list and want to force that all addresses in address-list ISP1 always goes to to WAN1, what should I do?
Comment by Ari April 26, 2012 @ 11:55 PM
Reply
Read This.
http://aacable.wordpress.com/2011/10/27/mikrotik-policy-routing-based-on-client-ip-address/
Comment by Syed Jahanzaib / Pinochio~:) April 27, 2012 @ 9:14 AM
Reply
75. Hello, have you ever noticed redirect problem with NAT? I have the latest version of RouterOS on ESXi 5.
I Cant use the redirect (eg web proxy transparent, or transparent DNS cache).
Comment by Alex Alouit (@alexalouit) April 27, 2012 @ 3:59 PM
Reply
Here is my configuration:
/ip firewall filter
add action=drop chain=input disabled=no dst-port=3128 in-interface=wan1 protocol=tcp
add action=drop chain=input disabled=no dst-port=3128 in-interface=wan2 protocol=tcp
/ip firewall mangle
add action=mark-connection chain=input disabled=no in-interface=wan1 new-connection-mark=WAN1_conn passthrough=yes
add action=mark-connection chain=input disabled=no in-interface=wan2 new-connection-mark=WAN2_conn passthrough=yes
add action=mark-routing chain=output connection-mark=WAN1_conn disabled=no new-routing-mark=to_WAN1 passthrough=yes
add action=mark-routing chain=output connection-mark=WAN2_conn disabled=no new-routing-mark=to_WAN2 passthrough=yes
add action=accept chain=prerouting disabled=no dst-address=0.0.0.0/24 in-interface=lan
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

23/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

add action=accept chain=prerouting disabled=no dst-address=0.0.0.0/24 in-interface=lan


add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=lan new-connection-mark=WAN1_conn
passthrough=yes per-connection-classifier=both-addresses:2/0
add action=mark-connection chain=prerouting disabled=no dst-address-type=!local in-interface=lan new-connection-mark=WAN2_conn
passthrough=yes per-connection-classifier=both-addresses:2/1
add action=mark-routing chain=prerouting connection-mark=WAN1_conn disabled=no in-interface=lan new-routing-mark=to_WAN1
passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN2_conn disabled=no in-interface=lan new-routing-mark=to_WAN2
passthrough=yes
/ip firewall nat
add action=masquerade chain=srcnat disabled=no out-interface=wan1 src-address=0.0.0.0/24
add action=masquerade chain=srcnat disabled=no out-interface=wan2 src-address=0.0.0.0/24
add action=redirect chain=dstnat comment=Transparent Web Cache disabled=yes dst-port=80 protocol=tcp to-ports=3128
/ip proxy
set always-from-cache=no cache-administrator=webmaster cache-hit-dscp=4 cache-on-disk=yes enabled=yes max-cache-size=unlimited max-clientconnections=600 max-fresh-time=3d max-server-connections=600 \
parent-proxy=0.0.0.0 parent-proxy-port=0 port=3128 serialize-connections=no src-address=0.0.0.0
/ip route
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=0.0.0.0 routing-mark=to_WAN1 scope=30 target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=0.0.0.0 routing-mark=to_WAN2 scope=30 target-scope=10
add disabled=no distance=1 dst-address=0.0.0.0/0 gateway=0.0.0.0 scope=30 target-scope=10
add disabled=no distance=2 dst-address=0.0.0.0/0 gateway=0.0.0.0 scope=30 target-scope=10
Comment by Alex Alouit (@alexalouit) April 27, 2012 @ 4:11 PM
Reply
I never used Mikrotiks Web Proxy service with PCC. Only heard that it do make some problems if you have all setup on single box i.e PCC / Firewall
/ WEBPROXY. Its better to use external proxy for cache.
Comment by Syed Jahanzaib / Pinochio~:) April 28, 2012 @ 4:21 PM
Reply
76. Hello
Could you help me please.
I am using 2 wan load balancing with PCC rules. But I want to use WAN1 generally and WAN2 if WAN1 is full.
How can I do it.
Also I use load balancing PCC with hotspot but there are problems when browsing https sites.
Thanks a lot
Best Regards
Eynulla Samadov
Comment by Eynulla Samadov May 7, 2012 @ 7:11 PM
Reply
You cant shift user to wan2 if wan1 is FULL using mikrotik AFAIK.
Try using Load Balancing scenario. or policy base routing.
E.g:
http://aacable.wordpress.com/2011/10/27/mikrotik-policy-routing-based-on-client-ip-address/
Comment by Syed Jahanzaib / Pinochio~:) May 8, 2012 @ 3:16 PM
Reply
77. Best tutorial, works from first attempt.
Thank you for that.
I have a small problem and wish that you can help me with.
My board is RB493G (9 ports), I am using 2 ports for load sharing. Other ports for local net.
The problem is that I fail to communicate with other ports now (I cannot access the shares nor ping my hosts ).
I wish that you could help me solving this problem.
Comment by Taha May 12, 2012 @ 3:40 AM
Reply
Are you using HOTSPOT ?
Comment by Syed Jahanzaib / Pinochio~:) May 14, 2012 @ 8:57 AM
Reply
78. Thank you problem is solved no need to worry about it.
What should be done is just create a prerouting chain with accept to each network segment. in /ip firewall mangle
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

24/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Comment by Taha May 12, 2012 @ 7:17 PM


Reply
79. Yes I am using hotspot .
All I did to solve the problem is to create a mangle rule with accept from each segment to the other one.
I have one problem left which is not related to the script of yours but being an expert in Mikrotik I would like to
get your opinion on it.
My RB is 493G (V5.16) with no wireless cards installed, instead I have an AP connected to one of the ETH2.
I have 2 iPhones jail broken, connected to the same AP acting as the wireless HS I cannot see the shares between them.
I have installed Multicast package still not working.
If I connect the Iphones to an AP before the RB everything works fine. I would appreciate sharing your experience on solving this problem.
Comment by Taha May 14, 2012 @ 1:48 PM
Reply
turn off Universal NAT to enable users communicate with each other. because hotspot poison the network to forece every device to use HS as there
default gateway.
http://aacable.wordpress.com/2011/09/12/mikrotik-hotspot-quick-setup-guide-cli-version/
Comment by Syed Jahanzaib / Pinochio~:) May 14, 2012 @ 2:13 PM
Reply
80. 1 /ip hotspot set address-pool=none- could not do.. what are you referring to ?
2 OR
3 /ip hotspot set numbers=hotspot1 address-pool=none done
4 OR
5 /ip firewall nat add chain=pre-hotspot dst-address-type=!local hotspot=auth action=accept was already thereAnd problem is still there
Comment by Taha May 14, 2012 @ 2:47 PM
Reply
81. hum apne server ki secript kaise jan sakte hain k hum ne us ko kia kia script di hai
Comment by obaid May 22, 2012 @ 8:49 PM
Reply
You can use Export command to get all mikrotik configuration in human readable format which will show you every bit of your router config.
Comment by Syed Jahanzaib / Pinochio~:) May 25, 2012 @ 8:53 AM
Reply
82. sir i use your this script my mikrotik 3.30 L6 but just i wan line work not both at a time what happen? one time just 1 WAN work if i unplug 192.168.1.1
WAN1 then WAN2 work if i unplug wan2 then wan1 work but not both , if 2 wan are connectd wit then just WAN1 worked ? pleas help me what hapen?
Comment by obaid May 23, 2012 @ 10:50 AM
Reply
Reset to default. then re.configure.
Comment by Syed Jahanzaib / Pinochio~:) May 25, 2012 @ 8:52 AM
Reply
83. Helloi have a blue router address in Route List..and one wan is working each time i disable the other not both at a time.any ideas??!!
Comment by Leado June 4, 2012 @ 10:08 PM
Reply
84. Hi. I do have two dsl routers in bridge mode (different isps) and i need to have the pppoe (client) in my mikrotik 750. i need to have all the available
bandwidth in one PC (192.168.200.50). what is the best script to use?
router 1 is 10/1 Mbps with IP 192.168.2.1/24
router 2 is 4/1Mbps with IP 192.168.10.254/24
lan is 192.168.200.0/24
some help plz!
Comment by vortex June 14, 2012 @ 9:56 PM
Reply
any ideas?
Comment by vortex June 15, 2012 @ 9:24 PM
Reply
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

25/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

85. Hello Sir,


Thank you for this great tutorial. it worked for me in first attempt. I have one question though. I use download accelerator and when I download youtube
videos with the download accelerator it spreads the load on the 2 wan interfaces that I have which is perfect. but when I watch youtube videos it only
uses one of my wans.
I tried to change the classifier to both-addresses-and-ports but still when watching youtube videos it only uses one. I am now using both-ports which
works great for me in download accelerator, utorrent, and browsing. but still no luck when watching youtube videos.
any advice.
Your brother from Iraq
Badr
Comment by Badr June 15, 2012 @ 4:26 PM
Reply
PCC dont merge WAN Links, it only load balance request accross multiple connection.
The more link you put on it, the better results you will get.
Comment by Syed Jahanzaib / Pinochio~:) June 16, 2012 @ 10:11 AM
Reply
how will i be able to merge wan links?
Comment by vortex June 16, 2012 @ 11:24 AM
86. Hello Sayed Jahanzaib.
Thank you for your quick reply. Do you have any tutorial on how to merge wan links or just something to start with?
Thanks
Comment by Badr June 16, 2012 @ 3:07 PM
Reply
87. Hi, zaiB
I am Ali Muhamad from indonesia, could you help me please. I want to disable user using Software download manager eg: IDM or Toorent.
My conection only 2 Mbps and will be use 20 pc client. If you can help me here is my email: oceaniatravel [AT ] DOT com
Comment by Ali Muhamad June 18, 2012 @ 7:52 AM
Reply
Actually it is difficult to block torrent.
The best way is to limit there whole download bandwidth or impose bandwidth quota.
OR you can mark packets for mp3 exe iso etc and restrict them using queue.
OR another approach is to use Radisu and select quota plenty, for example if a user reaches 1 Gb quota for the day, his bandwidth drops half e.g from
512k to 256k.
Comment by Syed Jahanzaib / Pinochio~:) June 18, 2012 @ 8:45 AM
Reply
88. i have WAN1=2mbps ip=192.168.1.64 gateway= 192.168.1.254 /WAN2=5mbps ip=192.168.2.100 gateway 192.168.2.1
IS THIS CORRECT???
/ip address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
add address=192.168.1.64/24 network=192.168.1.0 broadcast=192.168.1.255 interface=WAN1
add address=192.168.2.100/24 network=192.168.2.0 broadcast=192.168.2.255 interface=WAN2
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=8.8.4.4,8.8.8.8
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
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 newconnection-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 newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

26/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

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
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.254 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.1.254 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
Comment by Eduardo June 21, 2012 @ 1:55 AM
Reply
Looks fine to me, test it.
Comment by Syed Jahanzaib / Pinochio~:) June 21, 2012 @ 10:52 AM
Reply
89. rb450g is enough for this operation with 50 hotspot clients?
Comment by zeeshan June 21, 2012 @ 6:01 PM
Reply
yes
Comment by Syed Jahanzaib / Pinochio~:) June 22, 2012 @ 8:50 AM
Reply
90. As-Salam-Alaikum h r u .. dear..???
i m new to use mikrotik server.. i dont know abt it i need ur help .. how to edit script .. and how to add .. 4mb and 1 mb lines in load balancing.. i have
requested to upgrade my 1mb link to 4mb and hopefully it will be withing a couple of days sir plx tell me how to edit hai configure script
Regards
Kashif Ali
Comment by Kashif Ali June 21, 2012 @ 6:37 PM
Reply
The script provided in this article is complete script to load balance 2 wan links.
copy paste them in notepad and edit it as per your network / mikrotik configuration.
You have to first learn basics of mikrotik. Goto forum / wiki / google , there are very good guides available there.
Comment by Syed Jahanzaib / Pinochio~:) June 22, 2012 @ 8:56 AM
Reply
91. Helloi have a blue router address in Route List..and one wan is working each time i disable the other not both at a time.any ideas??!!
Comment by Leado June 22, 2012 @ 7:37 PM
Reply
92. Could u please tell me how to add Script (notepad) file in Mikrotik???
i dont know about script editing.. please make a script for me .. one for load balancing and other for hotspot server.
i have two 4mb DSL link of ptcl..
Comment by Kashif Ali June 23, 2012 @ 8:25 PM
Reply
93. Hello Mr Syed
Im using load balancin with NTH method because it collect the line , for ex. WAN1 (4M) + WAN2 (4M) = Download (8M) got transfer rat with IDM 1000
KB/S
did PCC method do that ??? and can you help me how can i make port forward with NTH
Comment by Ahmed Morgan July 13, 2012 @ 8:29 PM
Reply
Many thanks I tried and i worked fine with (ADSL 2m + ADSL 2m + ADSL 4m) = ADSL 8M
Comment by Ahmed Morgan July 30, 2012 @ 10:04 PM
Reply
Great
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

27/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Comment by Syed Jahanzaib / Pinochio~:) August 3, 2012 @ 7:51 AM


94. Hello,
this one doesnt work for me:
PCC WITH UN-EQUAL WAN LINKS
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
there is no traffic on this one
Can I use 3/0 for 1st, 3/1 for 2nd and 3/2 for wan1 again?
I use per-connection-classifier=src-address.
Best regards,
Petar
Comment by Petar July 30, 2012 @ 1:02 AM
Reply
95. Hello being unable to access my account in order to create a new post I would like to ask the question here:
Is there a way to access the Mikrotik file system ? I have an RB450G and would like to delte some files at NAND level say : voltage.ko file.
Thank you indvane for yrour help.
Taha
Comment by Taha August 2, 2012 @ 7:38 AM
Reply
Yes if your RB have serial connection, you can access it.
Read following articles
http://manio.skyboo.net/mikrotik/
(Below one is for x86 versions)
http://aacable.wordpress.com/2012/01/14/howto-recover-mikrotik-admin-account-forgotten-password/
Comment by Syed Jahanzaib / Pinochio~:) August 3, 2012 @ 7:28 AM
Reply
hi
I am using routerboard 750 for load balancing 2 4mb lines.Everything is good except secure sites or websites which does not allow ip change.FTP
through firezilla also not working properly. I dont know how to use src-address as pcc classifier. Will it do the work. Can you guide me to proper
tutorial? I have read your tutorial http://aacable.wordpress.com/2012/04/14/howto-exempt-any-user-website-from-mikrotik-pcc/ but can it be done
for ssl sites.
Comment by usman January 11, 2013 @ 5:08 PM
Just replace both-addresses-and-ports with src-address
Comment by Syed Jahanzaib / Pinochio~:) January 12, 2013 @ 10:15 AM
96. ive tried the load balancing, internet and load balancing running well but i still cant ping my router public address
i monitor the traffic using torch, and i see RX traffic but no TX, seems the traffic cant get back to the incoming ISP (traffic is receive but cant reply)
Comment by athan August 30, 2012 @ 11:55 AM
Reply
97. Salam Dear Sir ,
Sir ap kasy hai .umied hai k ap thek hai .ALLAH ap per desta shufqat rakha.Sir main UBNT wireless setup laga raha hun.Aur sir mujha ap say kuch help
ke zaroorat hai .wo ya k main us k liya mikrotik ka kon sa ver use karun uar mikrotik ruterbord kon sa purchas karun.qk es ma humara pass dedicated
links be hai .aur SIR humara owner ya chata hai k ptcl jasie wireless modem ma setting ho.
SIR Cache server be creat karna hai kindly ap us ka be bta dijya ga. Sir main umied karta hun k ap jaldi aur bhater jawab send kary gia.
Waqas sabir from Faisalabad.
E-mail = the2ndlastguy@yahoo.com
Mob= 03157215729
Comment by Muhammad Waqas Sabir
Comment by Muhammad Waqas Sabir September 2, 2012 @ 1:57 PM
Reply

Hardware requirements are based on number of clients that will be accessing the network resources.
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

28/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Hardware requirements are based on number of clients that will be accessing the network resources.
For smaller network, RB450, RB450G would be enough.
For cache Server, if you have some know-how on Linux environment, then I will recommend you to go with SQUID proxy.
Search my blog or Google, and you will find many helpful resources regarding configuring mikrotik/squid.
Comment by Syed Jahanzaib / Pinochio~:) September 3, 2012 @ 8:44 AM
Reply
a.a
brother ma nay 4 wireless spot bany hn aur mikro tik dhcp use kar raha hn but jab ma hotspot use karta hn to mary 3 spot k andar any waly user thk
say login hoty han par 1 spot asa ha jahan par user login hoty hi logout ho jata ha agur ip binding bi karon tab bi un users k pass login page ata ha
problum ya ha k serprofile kam nahi karti but isi spot par default profile ko login karon to thk kam karti ha but sab users ko defalt profile to nahi day
sakta
kindly ap is ka hal jaldi batin
phaly bi ap ko comment kya tha ap shyad hamary comments ko nahi dakhty
kindly is bar ko positiv
e feedback din
cell no 0312-5741540
Comment by basaam September 12, 2012 @ 10:25 PM
Reply
without knowing technical specs, I cant comment.
Post your config here. or email me.
You can copy default profile and rename it as per requirements then make necessary changes.
Comment by Syed Jahanzaib / Pinochio~:) September 16, 2012 @ 12:58 PM
98. how does when i used internet soucer with DCHP?how?
Comment by budi September 18, 2012 @ 8:32 AM
Reply
99. Asalam o Alikum sir
mane 5 WAN ka load balancing banna ha kya ap mujhe source bana k mail kar sakty hain mera nam Zohaib Bin Khalid ha mane ek server banwaya tha
jis na bana k diya tha os na password nai btaya or na hi mujhe back up diya mera server dead para howa ha plzzzz help kar dain
mane 10 connection liya hain ptcl sa or sub k sub 10MB hain,,,,,,,,,,
lucky_boy_zohaib@yahoo.com
Zohaib Bin Khalid
Pakistan Lahore
Comment by Zohaib Bin Khalid October 2, 2012 @ 7:37 PM
Reply
100. I have used your PCC script , all is working fine with the PPPOE but when using hotspot its only sending traffic through 1 gateway . does not balance the
traffic like in PPPOE
Comment by Ferdi de Beer October 5, 2012 @ 7:09 PM
Reply
to test i open 2x CMD in windows. then i use tracert to google and facebook . In PPPOE it shows that one user 192.168.4.1 and other 192.168.2.1 but in
Hotspot only *.*.4.1
Comment by Ferdi de Beer October 5, 2012 @ 7:12 PM
Reply
101. how to change the per connection classifier if we have a dual wan with the first port off 93Mbps and the second 11Mbps with the same gateway
whats the best solution to solve this .
Comment by Agashi October 6, 2012 @ 7:25 PM
Reply
102. Hello, I setuped my L/B as exactly the way you showed us but im having Stream Issues, If I listen to youtube it always cut(stop)
I have 10mb on wan1 and 6mb on wan2..
Do you have any clue?
Comment by dbRenaud October 7, 2012 @ 8:49 AM
Reply
Try changing the classifier to src-addres
Comment by Syed Jahanzaib / Pinochio~:) October 7, 2012 @ 2:33 PM
Reply
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

29/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Thanks bro.but in that way i am not getting the merged speeds.Load is only on WAN1
Comment by usman January 12, 2013 @ 9:56 PM
103. Hello
i have NanoStation M5 /RB SXT+ RB750 G.
i connected both NM5 & SXT to two isp (pppoe). so i run dhcp server in this device.
in 750g i used dhcp client to have internet. but when i use 2 dhcp client i cannot use both of them at the same time. and only one of them useing.
how i can have both rb+nm5 internet in same time on 750g?
i used this way:http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/
Comment by Karim October 7, 2012 @ 8:07 PM
Reply
104. Syed , could u tell me is there a way to this scenario :
WAN1 >>>>
Mikrotik > Users with subnet 10.0.1.1/24 get internet from wan1 and users from subnet 10.0.2.1/24 gets internet from wan2 on same interface
WAN2 >>>>
is this possible in anyway to do it.
Comment by agashi October 9, 2012 @ 1:40 AM
Reply
This will surely help you in getting some ideas . . .
http://aacable.wordpress.com/2011/10/27/mikrotik-policy-routing-based-on-client-ip-address/
Comment by Syed Jahanzaib / Pinochio~:) October 9, 2012 @ 4:28 PM
Reply
105. on everyway i doo , i get a issue with reaching radius vica versa .
because when i route the second trafic to another gw then i do a tracert on it i get this :
http://postimage.org/image/xyo4aitef/
ive tried on routing it , adding a vpn to the main mikrotik but always i cant reach radius
please can u help me on solving this .
Comment by agashi October 11, 2012 @ 2:18 PM
Reply
106. sir i have a mikritik load balncind pcc mathod used, but is not working . sir 1 line is working butt 2 line is not working.
i have used the mikrotik 3.30 . please solve my problem,sir i cal adeel ahmad but is not halpe me.
Comment by naveed October 31, 2012 @ 1:25 PM
Reply
107. your script works like a charm. but when use external proxy (squid) with pcc load balancing, its not working since pcc seems to maintain all connection
state between source and destination (both address & port). if i disable all pcc mangle rules, external proxy is wortking, http packets is redirected to
squid, but it use only 1 gateway. is there any way to use external squid proxy with pcc load balancing ?
Comment by lostbytes November 10, 2012 @ 9:31 AM
Reply
I havent tried this scenario. Usually I use separate RB for LB. This way things dont get complicated when it comes to troubleshoot any problem.
Comment by Syed Jahanzaib / Pinochio~:) November 12, 2012 @ 10:26 AM
Reply
ahhi see. thats an option too, use 1st RB to do LB, then 2nd RB for guest & external proxy management. thats a simple yet effective approach
(and also cheap considering RB prices today). but it will be nice on research side if we can do the one RB option. Thank you for your reply, i will
take your suggestion (apply 2 RB).
Comment by lostbytes November 12, 2012 @ 1:29 PM
108. I have two internet connection. One is PTCL (4 Mb) and other one is World Call (2mb). I want to USE RB 750GL for the load margin and Load balancing.
Can you please give complete script for that.
Comment by Waqar November 19, 2012 @ 12:37 PM
Reply
109. i am using 2 ISP for load balancing. I have facing problem when i run my FTP at that time my FTP didt connect. But when i swith off one line my ftv
works properly. How can i run the FTP on bouth lans.
Comment by Waqar November 27, 2012 @ 7:49 PM
Reply
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

30/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

You can exempt specific use or specific port from being processed by PCC.
http://aacable.wordpress.com/2012/04/14/howto-exempt-any-user-website-from-mikrotik-pcc/
Comment by Syed Jahanzaib / Pinochio~:) November 28, 2012 @ 10:15 AM
Reply
110. Dear Sir
I have 4 WAN pppoe client and one Local using RB450G, how can I marege and bond all those 4 PPPoE Clients if my ISP doesnt support MLPPP .
what should I do to merge all links ? any script ?
Please Mr. Syed I need your help.
Thanks.
Comment by esalehnet November 28, 2012 @ 8:30 PM
Reply
111. Hi Sir,
I have 4wan pppoe client and 1 local network, hot to merge all those pppoe client if my ISP doesnt support MLPPP ? any script ?
what should I do in this case ?
I need your help.
Thank you very much.
Comment by esalehnet November 28, 2012 @ 9:04 PM
Reply
try the below link.
http://mikrotikz.blogspot.com/2010/07/load-balance-mikrotik-with-pcc-using.html
Comment by Syed Jahanzaib / Pinochio~:) November 29, 2012 @ 3:15 PM
Reply
that load balancing and not merge my connection in one single link when I download one single file, didnt give me speed for all 4 WAN interfaces
at once.
I tried to put another mikrotik Routerboard by making 4 interfaces work as on single bonding using Balance rr method.
what is the best method should I use to get merge these 4 interfaces, so when I start download a file , Ill get speed the total speeds for those 4
nterfaces connection?
Comment by esalehnet December 7, 2012 @ 8:41 PM
112. i am using 2 ISP for load balancing. I have facing problem when i run my FTP at that time my FTP didt connect. But when i swith off one line my ftv
works properly. How can i run the FTP on both Lans, I try your script. But i still i have problem . can u explain it more for me
Comment by Waqar November 29, 2012 @ 7:03 PM
Reply
Wich Is the Best Methord Pcc Or Nth ?
Comment by usma December 9, 2012 @ 12:45 AM
Reply
113. i have Question about Mikrotik Loadbalancing
First if i have Two Wan 2Mb/s , with this method My Download Speed Increase to 4Mb/s ? (Download 1 file with 4 Mb/s )
Another Question : i Think if i Established PPTP Vpn Connection on my Client PC it just Use one WAN , But if i Established PPTP on my Mikrotik i think
it use 4Mb/s Tunnel and Direct Two WAN to Tunnel . is it Correct ? if yes can help me how can i Established PPTP Client on My Mikrotik and Direct 2
Wan on That tunnel ? ( i have 4Mb/s Tunnel )
Regards .
Comment by Mehran December 9, 2012 @ 2:13 PM
Reply
114. salaM mere Pas mikrotek hotspot connection hemgr porblem ye he her baar login hona parta hekia koi aisa method nai jis se auto login mumkin ho
sake.
Comment by raheel December 12, 2012 @ 1:43 PM
Reply
Yes you can resister user mac and bypass authentication for specific users.
Howto Bypass authentication for Few Clients
This bypasses the hotspot by mac address.
/ip hotspot ip-binding add mac-address=xx:xx:xx:xx:xx:xx type=bypassed
(change xx:xx:xx:xx:xx:xx with your users mac address. You can also use the ip address to bypass.
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

31/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Read more about it here.


http://aacable.wordpress.com/2011/09/12/mikrotik-hotspot-quick-setup-guide-cli-version/
Comment by Syed Jahanzaib / Pinochio~:) December 13, 2012 @ 8:50 AM
Reply
115. I Did it , and it work well . but just in Download manager it work well cause its Split connection and download with Two wan .
In Video Stream or many other things they use just One connection it use 1 Wan . there is no Way I can Split 1 Connection to 2 connection and see Video
streaming or others with two wan ?
Thanks .
Comment by Mehran December 13, 2012 @ 11:34 AM
Reply
116. Is That possible to pass Torrents from 4th Gateway only
please tell me example code for it.
Comment by shahzad December 14, 2012 @ 12:10 PM
Reply
117. I have here a situation with my dual WAN Load Balancing.
WAN2 = 384kb LS
WAN1 = 6Mb ADSL
Load Balancing on RB433
after this, WAN2 is fully used but WAN1 hardly reaches 2Mb and at the moment the LAN is reaching 1.5Mb, browsing is becoming almost impossible.
My VOIP Calls are not more clear
Using WAN1 alone, easily reaching 4Mb with no problem and can also Call.
Plz Help
Here is the configuration:
/ip address
add address=192.168.1.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
add address=192.168.2.2/24 network=192.168.1.0 broadcast=192.168.2.255 interface=WAN1
add address=192.168.11.2/24 network=192.168.11.0 broadcast=192.168.11.255 interface=WAN2
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=221.132.112.8,8.8.8.8
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting dst-address=192.168.1.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.11.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 newconnection-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 newconnection-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
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.11.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.11.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
/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 newconnection-mark=WAN2_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 newhttp://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

32/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

connection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection newconnection-mark=WAN1_conn passthrough=yes
Comment by warren December 14, 2012 @ 10:51 PM
Reply
Hi Warren,
I am using 2 ISP with PCC method. But i am facing a problem with the FTP. When i try to upload through Filezilla my connect disconnect when both
wan are working. But when i disable the one Wan i ma able to do a upload. Can you pleaes tell me how can i make my FTP working with both lan. Or
how can i exempt the IP from PCC rule.
Comment by waqar December 15, 2012 @ 8:38 PM
Reply
Define your network topology in detail.
If users are hitting directly to PCC , then you can use src-address as classifier as this way change of WAN ip wont occur for the user , for the
session he initially build with pcc. he will always be bound with the WAN that he initially connected to.
Or you can also exclude some Users ip / Traffic from being processed by pcc, means you can bypass certain traffic from being processed by the
PCC, and this tagged tarffic will go via specific WAN only,
http://aacable.wordpress.com/2012/04/14/howto-exempt-any-user-website-from-mikrotik-pcc/
Comment by Syed Jahanzaib / Pinochio~:) December 16, 2012 @ 10:24 AM
118. Here is my new config but no change
WAN1 = 384kb LS
WAN2 = 6Mb ADSL
/ip address
add address=192.168.1.1/24 network=192.168.1.0 broadcast=192.168.1.255 interface=Local
add address=192.168.11.2/24 network=192.168.11.0 broadcast=192.168.11.255 interface=WAN1
add address=192.168.2.2/24 network=192.168.2.0 broadcast=192.168.2.255 interface=WAN2
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=221.132.112.8,8.8.8.8
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting dst-address=192.168.11.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 newconnection-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 newconnection-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
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.11.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.11.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection newconnection-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 newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
Comment by Warren December 16, 2012 @ 9:06 PM
Reply
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

33/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Will this force Local to send more traffic to WAN2 ?


add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:5/0 action=mark-connection newconnection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:5/1 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:5/2 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:5/3 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:5/4 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
Comment by Warren December 17, 2012 @ 3:26 AM
Reply
Yes
Comment by Syed Jahanzaib / Pinochio~:) January 23, 2013 @ 3:41 PM
119. [...] view source [...]
Pingback by Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | @rskabc January 28, 2013 @ 7:16 AM
Reply
120. Hello Bhai..
main 2 adsl(ptcl) modem ki loadbalancing ki huwi hai. using PCC method. its fine, . lakin jab aik Line disconnect hoti hai tu browsing main GateWay
Timeout ka error aata jata hai. So how i can solve this problem.???? iam waiting for response
thank you
Hammad Hassan
Fast ISP
Comment by hammad hassan February 5, 2013 @ 5:51 PM
Reply
121. Assalamuaikum
thank you for this tutorial, but i have a question about :
/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 newconnection-mark=WAN1_conn passthrough=yes
> for that example !local [accept local]
what is the ip address for local list..? theres only ip address for client connection, or any others one..?
thank you for help me..
Wassalamualaikum
Ronny
Comment by Ronny Siswongso Nugroho February 14, 2013 @ 2:39 PM
Reply
122. Dear Sayed Jahanzaib
I have a pcc load balance where:
WAN1: 8M up / 8M down (for direct connections)
WAN2: 8M up / 8M down (for direct connections)
WAN3: 35M down from sat (for port 80 connections)
we are routing our sat subnet to use it for port 80 connections and every thing is ok
but we want to stop our sat down and upgrade our WAN2 to become 25M up / 50M down
what we need is to divide the WAN2 bandwidth between the direct connections and port 80 connections
to be like this :
WAN1: 8M up / 8M down (for direct connections)
WAN2: 8M up / 8M down (for direct connections)
WAN2: 17M up / 42M down (for port 80 connections)
ether2: my local lan
ether3: my WAN1 (25M up / 50M down)
ether4: my WAN2 (8M up / 8M down)
what I need is to separate http connection from the PCC load balance and must pass from ether3 only
so can I solve it in this way ? :
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

34/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

/ip address
add address=192.168.1.1/24 disabled=no interface=ether2 network=192.168.1.0
add address=1.1.1.2/24 disabled=no interface=ether3 network=1.1.1.0
add address=2.2.2.2/24 disabled=no interface=ether4 network=2.2.2.0
PCC load balance with marking http connection:
/ip firewall mangle
add action=mark-connection chain=forward disabled=no dst-port=80 new-connection-mark=http_conn passthrough=yes protocol=tcp srcaddress=192.168.1.0/24
add action=mark-packet chain=forward connection-mark=http_conn disabled=no dst-port=80 new-packet-mark=http passthrough=no protocol=tcp srcaddress=192.168.1.0/24
add action=accept chain=prerouting comment=ether3 disabled=no dst-address=1.1.1.0/24 in-interface=ether2
add action=accept chain=prerouting comment=ether4 disabled=no dst-address=2.2.2.0/24 in-interface=ether2
add action=mark-connection chain=prerouting comment=ether3_conn connection-mark=no-mark disabled=no in-interface=ether3 new-connectionmark=ether3_conn passthrough=yes
add action=mark-connection chain=prerouting comment=ether4_conn connection-mark=no-mark disabled=no in-interface=ether4 new-connectionmark=ether4_conn passthrough=yes
add action=mark-connection chain=prerouting comment=ether3_conn connection-mark=no-mark disabled=no dst-address-type=!local in-interface=ether2
new-connection-mark=ether3_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1
add action=mark-connection chain=prerouting comment=ether4_conn connection-mark=no-mark disabled=no dst-address-type=!local in-interface=ether2
new-connection-mark=ether4_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0
add action=mark-routing chain=prerouting comment=ether3_packet mark connection-mark=ether3_conn disabled=no in-interface=ether2 new-routingmark=to_ether3 passthrough=yes
add action=mark-routing chain=prerouting comment=ether4_packet mark connection-mark=ether4_conn disabled=no in-interface=ether2 new-routingmark=to_ether4 passthrough=yes
add action=mark-routing chain=output comment=ether3_packet mark connection-mark=ether3_conn disabled=no new-routing-mark=to_ether3
passthrough=yes
add action=mark-routing chain=output comment=ether4_packet mark connection-mark=ether4_conn disabled=no new-routing-mark=to_ether4
passthrough=yes
/ip firewall nat
add action=accept chain=srcnat disabled=no dst-port=80 out-interface=ether3 protocol=tcp
add action=masquerade chain=srcnat disabled=no out-interface=ether3
add action=masquerade chain=srcnat disabled=no out-interface=ether4
/ip route
add check-gateway=ping comment=Load balance_ether3 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=1.1.1.1 routing-mark=to_ether3
scope=30 target-scope=10
add check-gateway=ping comment=Load balance_ether4 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=2.2.2.1 routing-mark=to_ether4
scope=30 target-scope=10
add check-gateway=ping comment=Load balance_ether3 disabled=no distance=1 dst-address=0.0.0.0/0 gateway=1.1.1.1 scope=30 target-scope=10
add check-gateway=ping comment=Load balance_ether4 disabled=no distance=2 dst-address=0.0.0.0/0 gateway=2.2.2.1 scope=30 target-scope=10
/queue simple
add burst-limit=0/0 burst-threshold=0/0 burst-time=0s/0s direction=both disabled=no interface=all limit-at=0/0 max-limit=17M/42M name=HTTP Queue
packet-marks=http parent=none priority=8 queue=ethernet-default/ethernet-default target-addresses= total-queue=default-small
Comment by Fiber Net February 17, 2013 @ 3:14 PM
Reply
123. sorry edit :
ether2: my local lan
ether3: my WAN2 (25M up / 50M down)
ether4: my WAN1 (8M up / 8M down)
Comment by Fiber Net February 17, 2013 @ 3:26 PM
Reply
124. i have rb 1100
. ether 1: pppoe client ,local
ether 2: pppoe client ,local
ether 3: pppoe client ,local
ether 4: pppoe client ,local
ether 5: pppoe client ,local
ether 6: pppoe client ,local
all ether 1,2,3,4,5,6 have the same network 192.168.1.0 with DHCP 192.168.1.1/192.168.1.254
and i wont the output hotspot
Comment by absal February 18, 2013 @ 11:52 PM
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

35/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Reply
125. Asslam o Alaikum sir i am using rb 750 for loadbalcing in which 2 mb 4 mb 4mb connection used after dat os on syatem usinf pppoe net share bt ther is a
problem that i used skype dafual speed gives me error ur net speed is slow give me solution plz
Comment by waqar February 26, 2013 @ 6:47 PM
Reply
126. Can the setup work for me.
I have to ISP, one is USM(ppp-client USB dongle) and the other one is with a router to mikrotik thru ether1.
My Lan is on port 3 (hotspot-193.168.30.1/24),
ether2 (10.11.6.1/24) and wlan1(192.168.2.1/24).
I want a situation where the ppp-client USB will be my primary ISP (WAN1) and My secondary ISP will be from (ether1).
How will my settings or configuration be so that if primary isp is down, the secodnary will come up and if primary comes up, it switches over to it.
Comment by sapanda March 5, 2013 @ 4:41 PM
Reply
You can setup netwatch to monitor wan connectivity usnig your specific primary interface, so when it stops receive response from google for
example, then it should switch over to secondary ISP.
Comment by Syed Jahanzaib / Pinochio~:) March 6, 2013 @ 7:55 PM
Reply
127. hello,
i want to limit users internet bandwidth but i am having problem with internal connection. the internal bandwidth is also limited and it is affecting VOIP
on the network. how can i solve this issue.
thank you. i love your post and am a huge fan of yours
Comment by Rene March 5, 2013 @ 8:32 PM
Reply
Its depend on the scenario.
Are you running HOTSPOT ?
Comment by Syed Jahanzaib / Pinochio~:) March 6, 2013 @ 8:53 AM
Reply
Yes. am running hotspot on the network
Comment by Rene March 8, 2013 @ 4:07 PM
HOTSPOT users cant communicate with each other on LAN or PROXY-ARP issue
If you face hotspot broadcast issue / arp-poisoning , problem, Remove the address pool from the Hotspot to turn off Universal NAT,
/ip hotspot set address-pool=none
OR
/ip hotspot set numbers=hotspot1 address-pool=none
OR
/ip firewall nat add chain=pre-hotspot dst-address-type=!local hotspot=auth action=accept
Comment by Syed Jahanzaib / Pinochio~:) March 10, 2013 @ 7:14 PM
the trixbox server is in the network. i want a situation where users would not be limited to the bandwidth given to them to access anything on the
LAN. i already added the IP address of the sip server to bind and bypassed it; but its still slow and something jerky calls.
Comment by Rene March 11, 2013 @ 12:58 AM
128. Kindly describe this issue
I am using ppc load balancing
When I use torch tool I see this
Dst. Vlan Tx Rate Rx Rate Tx Packeg
0.0.0.0 143.2Kbps 3.5Mbps 219
Comment by Ehtisham March 8, 2013 @ 1:28 AM
Reply
tx means mikrotik is transmitting traffic to requesting target. Usually UPLOAD traffic
rx means mikrotik is receiving traffic from the source. Usually Internet
Comment by Syed Jahanzaib / Pinochio~:) March 10, 2013 @ 7:16 PM
Reply
Thanks Bhai
Comment by Ehtisham March 31, 2013 @ 1:56 AM
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

36/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

129. is it possible to achieve the config through winbox? i have 2 adsl connections 15/1Mbps each one and i like to get them on my mikrotik 750 to get higher
throughput and redundancy in case of one link fails. they are different ISPs and i can turn its modems in bridge mode.
i have one network 192.168.190.0/24
Comment by aris March 11, 2013 @ 7:02 PM
Reply
Yes you can configure mikrotik with PCC using WINBOX, in fact it will be musch easier if you use winbox because of GUI
Comment by Syed Jahanzaib / Pinochio~:) March 12, 2013 @ 8:59 AM
Reply
Is there any howto for the gui?
Comment by aris March 12, 2013 @ 12:39 PM
No. but search on google there are few guides in GUI too.
Comment by Syed Jahanzaib / Pinochio~:) March 13, 2013 @ 9:55 AM
130. AoA,
I need to know how to setup 2 adsl lines that traffic that coming to me(inbound) should be load balanced like web server hosted at my home does it work
with mikrotik or dns load balancing will be required?
Comment by gmsq March 24, 2013 @ 6:31 PM
Reply
131. hi
thanks for script
i use this script for 2 links 1 adsl (2m) and 1 wireless internet link (2m)
load balancing work well and combine 2 link ==>4m download but fail over not work correctly
so test this i disconnect modem telephone cable and internet disconnected because ping rule only check next hop of internet link and not understand
internet link is down
i try resolved this problem with tool/netwatch and check 8.8.8.8 but not success
can you help for improve fail over method with load balancing
tanks a lot
Comment by saeed April 6, 2013 @ 8:45 PM
Reply
132. Aslam O Alikum Syed Jahanzaib
I am Tanveer ul isalm from Saudi Arabia, I just configure PPPoe and it working fine, but i have tow WAN connection. How i cam make only fail over. i
no need loadbalance. please help me urgent or i want to monitor two wan IP ( yahoo or google), if it will not ping then it will shif to other gateway. if you
can help in gui mode. Thanks in Advance.
Regards,
Tanveer
Comment by Tanveer ul islam April 10, 2013 @ 7:50 PM
Reply
Read below . . .
http://aacable.wordpress.com/2013/04/12/mikrotik-multiple-wan-fail-over-scripts/
Comment by Syed Jahanzaib / Pinochio~:) April 12, 2013 @ 4:16 PM
Reply
133. What do I Need to Change to have 4 LAN Interfaces with different Networks in your script?
Do I Need to add These additional LAN ports simply to the following lines and thts it or do I Need to Change 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=192.168.3.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.4.0/24 action=accept in-interface=Local
Comment by Dirk May 6, 2013 @ 6:55 PM
Reply
134. i have 2 ISP primary is 192.168.10.10/24 connected to port ether 1 secondary is 10.10.10.10/24 connected on port ether 2 and LAN is 172.16.0.1/16
connected on port ether3. please kindly provide me the dual ISP fail-over scripts.
Comment by Naveed May 12, 2013 @ 3:00 PM
Reply
sorry didnt mention RB 1100AHx2
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

37/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Comment by Naveed May 12, 2013 @ 3:02 PM


Reply
Here you go . . .
http://aacable.wordpress.com/tag/mikrotik-fail-over/
Comment by Syed Jahanzaib / Pinochio~:) May 13, 2013 @ 8:38 AM
Reply
135. Hi there!
I will like to set up 2 WAN Load Balancing using PCC method. but these two line are not equal. the first one has 06mb and the second one has 1mb. all
are Optic Fiber links. can someone please advice?
Comment by Alex May 29, 2013 @ 2:54 AM
Reply
PCC is not very good with un equal links. but you can try by adding more pcc rule for high end wan. see the examples in the article.
Comment by Syed Jahanzaib / Pinochio~:) June 12, 2013 @ 2:24 PM
Reply
136. Hello Sir,
I was wondering if it is possible to load balance more than 30 PPPOE connections. What mikrotik router do you advice? What is your advice in load
balancing that many connections?
Comment by HRDHKR July 9, 2013 @ 2:52 AM
Reply
I will not recommend you to go with that much pppoe connections, as troubleshooting will become very hard.
anyhwo still you can do it, downloading larger files with idm type tools will be greatly benefited. No RB have 30 ports, however you can use VLAN
technology to do as much as ports config you like. I once saw 22 WAN LB at a friends rb suing this tech.
Comment by Syed Jahanzaib / Pinochio~:) July 9, 2013 @ 8:09 AM
Reply
137. Hi,
I am using RB 1100 of V6.0rc11
I have two internet connections.
One connection gives static Ip Address ie. on ether10 - 111.112.113.114 (ISP1)
and other is PPPOE Connection gives dynamic ip address on ether9 (ISP2)
I have LAN on ether1 192.168.0.0/24
my nat rule is
add action=masquerade chain=src-nat Src. Address=192.168.0.0/24 out-interface=ISP1 (internet for all)
i tried
add action=masquerade chain=src-nat Src. Address=192.168.0.100 out-interface=ISP2 (internet for particular computer)
And
add action=masquerade chain=src-nat Src. Address=192.168.0.101 out-interface=ISP1 (internet for particular computer)
What I want is to route all traffic from ISP2 of ip 192.168.0.100 and ip192.168.10.101
Please Help
Comment by cool nicq July 13, 2013 @ 2:42 PM
Reply
138. bhai kia hum is script k saat quality of service ko apply kar saktey hain or kese kindly guide,we are facing problem with browsing although downloading
speed is fine.
Comment by Ehtisham August 14, 2013 @ 2:57 PM
Reply
Hi Im using LB with 8 PPPoE Clients and all working fine.
I having problem with the smtp port 25 in outlook, all users can recieve emails by pop3 port 110, but they cannot do send.
When I connect all users direct to one PPPoE client without using LB like a simple router, they can sends emails smoothly.
Ive add a rule in the mangle with prerouting chain, TCP Protocol, Dst. Port 25 and action accept, and nothing.
Please what should I do to fix this problem ?
Help
Comment by esalehnet August 19, 2013 @ 3:21 PM

http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

38/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Reply
139. Hello Syed,
Below find config related to Mikrotik RB750G router, running 6.0rc9.
I am trying to configure ISP redundancy in load-balancing mode through a PCC article.
I have three connected interfaces, LAN, WAN and WAN2. The Primary and secondary WAN connections have different speed.
Issue is that after configuring the router, I get no traffic on one of the firewall>mangle prerouting chain rules (for WAN). The same applies when I disable
the secondary interface (WAN2) there is no automatic changeover to the primary interface.
Some observations Ive noted through WebFig are the following:
Interface>Interface Ok, Traffic being Transmitted and Received on all three interfaces
Interface>Ethernet Ok, Traffic being Transmitted and Received on all three interfaces
DNS Four set, two for one ISP and two for the other ISP
Firewall>NAT seems ok, traffic being transmitted and received on all interfaces
Firewall>Mangle there seems to be an issue here since there is no packets (counter still at 0), are flowing for primary ISP network addresses.
Rule is as follows:
/ip firewall mangle
Add chain=prerouting dst-address=XXXX action=accept in-interface=LAN

Note that all seems ok with the remaining prerouting (mark connection and mark routing) rules, since traffic is flowing. This includes the prerouting rule
for the other WAN link.
Routes>Primary ISP Gateway is unreachable for static routes
Routes>Nexthops
Primary and secondary gateways are reachable for both nexthops
Below I am including extracts of the config.
(Please note that IP addresses/MAC Addresses have been left out and replaced with Text).
Should you require further info please let me know
[admin@MikroTik] /interface> print
Flags: D dynamic, X disabled, R running, S slave
# NAME TYPE MTU L2MTU MAX-L2MTU MAC-ADDRESS
0 R WAN ether 1500 1520 1520
1 R LAN ether 1500 1520 1520
2 R WAN2 ether 1500 1520 1520
3 XS ether4-slave-local ether 1500 1520 1520
4 XS ether5-slave-local ether 1500 1520 1520

[admin@MikroTik] /ip address> print


Flags: X disabled, I invalid, D dynamic
# ADDRESS NETWORK INTERFACE
0 ;;; default configuration
192.168.88.1/24 192.168.88.0 LAN
1 ;;; Internet Primary
ISP1 IP Address [ISP1 Network Address] WAN
2 ;;; Internet Secondary
ISP2 IP Address [ISP2 Network Address] WAN2

[admin@MikroTik] /ip firewall mangle> print


Flags: X disabled, I invalid, D dynamic
0 chain=prerouting action=accept dst-address=[ISP1 Network Address] in-interface=LAN
1 chain=prerouting action=accept dst-address=[ISP2 Network Address] in-interface=LAN
2 chain=prerouting action=mark-connection new-connection-mark=WAN_conn passthrough=yes
in-interface=WAN connection-mark=no-mark
3 chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes in-interface=WAN2 connection-mark=no-mark
4 chain=prerouting action=mark-connection new-connection-mark=WAN_conn passthrough=yes
dst-address-type=!local in-interface=LAN connection-mark=no-mark
per-connection-classifier=both-addresses:2/0

5 chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes


http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

39/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

5 chain=prerouting action=mark-connection new-connection-mark=WAN2_conn passthrough=yes


dst-address-type=!local in-interface=LAN connection-mark=no-mark
per-connection-classifier=both-addresses:2/1
6 chain=prerouting action=mark-routing new-routing-mark=to_WAN passthrough=yes
in-interface=LAN connection-mark=WAN_conn
7 chain=prerouting action=mark-routing new-routing-mark=to_WAN2 passthrough=yes
in-interface=LAN connection-mark=WAN2_conn
8 chain=output action=mark-routing new-routing-mark=to_WAN passthrough=yes
connection-mark=WAN_conn
9 chain=output action=mark-routing new-routing-mark=to_WAN2 passthrough=yes connection-mark=WAN2_conn

[admin@MikroTik] /ip firewall nat> print


Flags: X disabled, I invalid, D dynamic
1 chain=srcnat action=masquerade out-interface=WAN
2 chain=srcnat action=masquerade out-interface=WAN2

[admin@MikroTik] /ip route> print


Flags: X disabled, A active, D dynamic, C connect, S static, r rip, b bgp, o ospf, m mme,
B blackhole, U unreachable, P prohibit
# DST-ADDRESS PREF-SRC GATEWAY DISTANCE
0 0.0.0.0/0 ISP1 Gateway 1
1 0.0.0.0/0 ISP2 Gateway 2
2 0.0.0.0/0 ISP1 Gateway 1 (routing mark to_WAN)
3 0.0.0.0/0 ISP2 Gateway 2 (routing mark to_WAN2)
4 ADC 192.168.88.0/24 192.168.88.1 LAN 0
5 ADC ISP1 Network Address ISP1 Static IP WAN 0
6 ADC ISP2 Network Address ISP2 Static IP WAN2 0
Comment by Joseph Lee Lemon August 27, 2013 @ 5:45 PM
Reply
140. rocket m2 kay ubnt sactor 120 degree ka laga hi
1 km par 72 mb par conect ho kar thori dair tak 1 mb par a jata hi
ya masla samaj nhi a raha plz help me
Comment by rashid September 3, 2013 @ 3:05 PM
Reply
sorry bro.
No idea for wireless related issues.
Comment by Syed Jahanzaib / Pinochio~:) September 4, 2013 @ 1:19 PM
Reply
141. Hello Syed,
Any Idea on 139, i.e. ISP redundancy with PCC
Much obliged,
Joe
Comment by Joseph Lee Lemon September 4, 2013 @ 6:15 PM
Reply
142. Plz help me with a scrip for RB750
Comment by tanveer September 29, 2013 @ 9:53 PM
Reply
143. does this method consume traffic from both links equally ??
Comment by Khuffash October 3, 2013 @ 5:38 PM
Reply
YES if multiple http connections generated, like IDM or multiple requests on load
Comment by Syed Jahanzaib / Pinochio~:) October 4, 2013 @ 10:34 AM
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

40/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Reply
144. we are using 3 WAN connection, i study ur documents which helps a lot, internet is working fine but the problem is that when i use web email or remote
desktop from outside network (abroad) its drops after some time, can you please guide me how to fix this issue.
Comment by Friends October 10, 2013 @ 1:06 PM
Reply
145. but what if i do this in ip routes ??
what is the diffrance between the picture and between ur route role ??
or
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
Comment by qassam mahmoud October 18, 2013 @ 10:32 PM
Reply
146. Bhai,
Assalamu Alaikum Wa Rahmatullah. I am Kawsar from Bangladesh. I just configured your given 2XWan Script on My Mikrotik 450G and put two
modem (1XWimax-2MB Line+1XADSL-512 Kbps). Every script is okey. But my system is not working. I am not clear which DNS should I use and also is
there any necessity to put up real IP which has given by two ISP (1 from Wimax and 1 from ADSL)? I didnt put that. Here I am giving the whole script
which I have given to my Mikrotik. If you see and help me. I will be grateful.
Please have a look with my used script.
/ip address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local
add address=192.168.1.2/24 network=192.168.1.0 broadcast=192.168.1.255 interface=WAN1
add address=192.168.2.2/24 network=192.168.2.0 broadcast=192.168.2.255 interface=WAN2
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=221.132.112.8,8.8.8.8
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
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 newconnection-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 newconnection-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
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.1.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
Thanks
Kawsar
+8801711865172
mdsekawsar@gmail.com
Comment by Md Sarwar E Kawsar November 4, 2013 @ 10:24 PM
Reply
147. Hi Sir

I have 2 Dynamic IP Addresses (dsl) lines. I am using Afraid.org auto dns updater the system is load balancing setup. It seems to be working fine,
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/
41/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

I have 2 Dynamic IP Addresses (dsl) lines. I am using Afraid.org auto dns updater the system is load balancing setup. It seems to be working fine,
untill both dynamic ip addresses change on the wan 1 and wan 2.. is there a script that can force my IP updater to go only through wan 1, or through
wan 2 which I can select myself?. It somehow seems to affect my voip system as well now i have to reboot my voip server everytime the IP changes
as well
Kind regards
Comment by jackalt007Nizam November 7, 2013 @ 2:46 AM
Reply
Oh yes. Using RB750
Comment by jackalt007Nizam November 7, 2013 @ 12:33 PM
Reply
148. sir ,
jab main yeh 2 wan lod balniceing karta ho to interface main rx errors ata ha plz reply
Comment by shshid November 8, 2013 @ 11:34 AM
Reply
149. [] http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-s… []
Pingback by Link to mikrotik Multiwan | Plovelogs Weblog November 12, 2013 @ 10:45 PM
Reply
150. why do u use
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
I mean 192.168.1.0/24 and 192.168.2.0/24. Because this is WAN network. This is not my property. This is service providers network.
Please explain me.
Thanks in advance.
Comment by myfahimFahim Ahmed November 19, 2013 @ 3:15 PM
Reply
Thanks Dear,
I just update my wimax modem local IP as 192.168.1.0/24 and 192.168.2.0/24. Thats why I used those twice IP as well. One thing let me describe you.
When I just start the two wimax modem at a time just WAN1 modem is using. If I make disable WAN1 then WAN2 is automatically starts its duty.
Means this time WAN2 is working. At a time both is not working. I would like to get both modems data means (WAN1-2MB and WAN2-2MB=Local4MB). Is it possible to get 4 MB download speed at a time by the said two wimax modem?
Thanks
Kawsar
mdsekawsar@gmail.com
+8801711865172
Comment by Md Sarwar E Kawsar November 20, 2013 @ 10:36 PM
Reply
I have configured my router another way. In my LAN, I have devided my network into two (e.g. 10.10.10.0/25 and 10.10.10.128/25). The first
subnet is going twards WAN1 and second subnet going twards WAN2. It is working fine. But I want something which will work dynamically. I
dont wanna define subnet. I dont wanna select user to go to some specific WAN.
Comment by Fahim November 25, 2013 @ 8:02 AM
151. Dear I have purchased a mikrotik rb750 . and I want you to configure it for me. with hotspot login page. how much will u charge for it. plz contact me @
0333-6107719 or send me email at m.arfanzahid@yahoo.com
Comment by Arfan November 23, 2013 @ 2:19 PM
Reply
152. Hello,
I have two Fiber Optic links with /29 IP subnet and gateway IP is on ISP hardware(so I can only use 5 public IPs from each link) , how can I configure
Loadbalancer to fit my scenario???.I have tried the script but it force traffic only to one link the second not working or when I disconnect the first one its
start to force to second one.
Thank you in advance
Comment by Mojitos_82 December 12, 2013 @ 4:02 AM
Reply
It depends on how your mikrotik box is configured with other services. If only one link is in used, probably something in config is configured
incorrectly.
Once PCC script cannot fit in all environment, for example, if you have PCC with PPPoE server in box, or PCC with HOTSPOT, or simple PCC as a
gateway, settings are different for each scenario.

http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

42/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Comment by Syed Jahanzaib / Pinochio~:) December 12, 2013 @ 8:24 AM


Reply
Hi,
Thanks for reply, I need simple pcc loadbalancer .But I preffer to use loadbalancing on my PPPoE concentrator directly, on RB1100AH . Is it
possible?
I have configured for now PORT 13 as WAN port and port 6 as LAN master and the rest port 7-10 as slave ports ,11-12 ports dont have idea how
to use them.I running ROS 6.6 on RB.
Please help!
Comment by Mojitos_82 December 13, 2013 @ 11:37 PM
153. hi,
please sir, i want to know if it is possible to use two 2 internet service provider, isp1 for browsing and isp2 for downloading on mikrotik, thank you
Comment by lateef December 26, 2013 @ 5:29 PM
Reply
154. hi
sir my question is the rb 740 can combine 4 network for example 10Mb+10Mb+10Mb+10Mb combine 40Mb it is possible
Comment by imran rasool January 14, 2014 @ 10:25 PM
Reply
Yes It can.
See following for a comparison
http://routerboard.com/RB750
Comment by Syed Jahanzaib / Pinochio~:) January 17, 2014 @ 7:22 PM
Reply
155. Dear sir assalamo alaikum
sir i am having a problem on my network dhcp lease busy and that time whole the network yellow sign and not accept any ip address manually kindly
tell me the solution i am very upset for this problem i am using mikrotik 5.20 hotspot
Comment by Muhammad Ali January 17, 2014 @ 2:00 AM
Reply
156. I have 2 wan with 4 and 8 mbps. Which one of the following pcc is correct.
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/0 action=mark-connection newconnection-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 newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
OR
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:3/0 action=mark-connection newconnection-mark=WAN1_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:3/1 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:3/2 action=mark-connection newconnection-mark=WAN2_conn passthrough=yes
Notice the 2 and 3 in the pcc..
Thank you for the answer.
Comment by freerhyme February 11, 2014 @ 12:03 PM
Reply
157. How to update this script if i have one WAN with PPPoE and both WANs has adresses from DHCP and may change?
I can use 192.168.1.1. and 192.168.2.1. Can it be changed to interface?
Comment by LiveBomb February 24, 2014 @ 2:48 PM
Reply
158. i have 2 Wan, of 4mb each, WAN1 has download volume of 102gb, WAN2 no volume quota: i wish to load balance my surf to WAN1 and all downloads
to WAN2: can you help me please;i have a network which clients can download more than 200gb per month and need to reduce cost
Comment by loknjinu March 3, 2014 @ 3:29 PM
Reply
159. Is it possible on MikroTik i can LoadBalancing with Single Socket Connection ? i mean For Streaming Video and etc it just use one Session , Connectify
Switchboard is a Application can do it and used Multiple Internet Connection for Streaming Videos .
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

43/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Now i want know Mikrotik is able to do that ?


-Thanks .
Comment by Mehran March 15, 2014 @ 3:33 PM
Reply
160. hello, thanks for your great works with this blog but I would like to find out;
I recently bought an RB2011 and Im expecting my ISP to install a second connection.
Can I have the load balancing as well as hotspot setup on the same router?
Thanks,
Max
Comment by maxcuban March 24, 2014 @ 1:20 PM
Reply
161. hi,
I have written on many forums without ever answer, but I need help, I have 2 WAN from a 4mb and from a 7mb, I would like to achieve load balancing
and I used this script
/ip address
add address=192.168.1.1/24 network=192.168.1.0 broadcast=192.168.1.255 interface=Local
add address=192.168.10.2/24 network=192.168.1.0 broadcast=192.168.10.255 interface=WAN1
add address=192.168.20.2/24 network=192.168.2.0 broadcast=192.168.20.255 interface=WAN2
/ip dns set allow-remote-requests=yes cache-max-ttl=1w cache-size=5000KiB max-udp-packet-size=512 servers=217.112.96.190,8.8.8.8
/ip firewall mangle
add chain=input in-interface=WAN1 action=mark-connection new-connection-mark=WAN1_conn
add chain=input in-interface=WAN2 action=mark-connection new-connection-mark=WAN2_conn
add chain=output connection-mark=WAN1_conn action=mark-routing new-routing-mark=to_WAN1
add chain=output connection-mark=WAN2_conn action=mark-routing new-routing-mark=to_WAN2
add chain=prerouting dst-address=192.168.10.0/24 action=accept in-interface=Local
add chain=prerouting dst-address=192.168.20.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 newconnection-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 newconnection-mark=WAN2_conn passthrough=yes
add chain=prerouting dst-address-type=!local in-interface=Local per-connection-classifier=both-addresses-and-ports:2/2 action=mark-connection newconnection-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
/ip route
add dst-address=0.0.0.0/0 gateway=192.168.10.1 routing-mark=to_WAN1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.20.1 routing-mark=to_WAN2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.1.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=192.168.2.1 distance=2 check-gateway=ping
/ip firewall nat
add chain=srcnat out-interface=WAN1 action=masquerade
add chain=srcnat out-interface=WAN2 action=masquerade
but I do not understand why, or where Im wrong but problems steaming, https web sites
you can help me solve the problem?
please
Comment by antosere April 2, 2014 @ 1:53 AM
Reply
162. Hey there. its sam
I was looking over one of my 2 WAN PPC on a rb450G (ports 4-5) and i noticed i am using a Bridge for ports 1-3. Should i be using a Master port vs
Bridge? Any performance issues i could incur doing this? No idea why i am using a bridge. I think it came out of the box with a bridge on the rb450G vs
master/slave. its running 4.14
Comment by Sam April 5, 2014 @ 10:45 AM
Reply

163.
how it can possible rb 750 combine two or more network
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

44/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

163. how it can possible rb 750 combine two or more network


i.e 4Mb+4Mb=8Mb.
how it is posible reply my email
imran_rasool1991@tahoo.com
Comment by imran April 7, 2014 @ 12:30 AM
Reply
164. Sir i am Babu i wants to easy solution Auto redundancy from mikrotik plz help me..
Comment by Babu April 7, 2014 @ 9:25 AM
Reply
Sir plz help me.
Comment by Babu April 7, 2014 @ 10:30 AM
Reply
165. Sir i think you have lot of experience in mikrotik so i wants to help auto redundancy script.i am wait for your mail.
Comment by Babu April 9, 2014 @ 10:15 AM
Reply
You want to load balance two wan connections? or you want primary / secondary fail over?
Comment by Syed Jahanzaib / Pinochio~:) April 10, 2014 @ 8:52 AM
Reply
166. Sorry Sir load balance i am ok but i wants to help auto redundancy script i dont know redundancy men primary / secondary fail over ? plz help me..
Comment by Babu April 11, 2014 @ 4:07 PM
Reply
http://aacable.wordpress.com/2013/04/12/mikrotik-multiple-wan-fail-over-scripts/
Comment by Syed Jahanzaib / Pinochio~:) April 11, 2014 @ 10:45 PM
Reply
167. Thank Sir i will try it .
Comment by Babu April 12, 2014 @ 4:57 PM
Reply
168. Assalamu walaikum Vaijan,
I want to know can i pass torrent bandwidth my 2nd wan link?
Can you please help me.
Comment by Salim Rahman April 15, 2014 @ 9:45 AM
Reply
169. i have 2 isps and im using Rb750 . i want certain traffics to be ruled like facebook,youtube ,DL and others browsing will go only to ISP1 and my ISP2
will be my gaming isp pls help thanks in advance
Comment by nhelly June 1, 2014 @ 9:11 AM
Reply
170. Sir Syed Jahanzaib !
salam !
i have two connection of wan one is DSL and the other one is the fiber optic connection. i want to merge both connection to get the double bandwidth and
also have to do fail-over can you do it for me via team-viewer, as i am newbie to the mikrotik i need your help please !
And this will also be a great chance for to learn something
Comment by Ismail khan June 11, 2014 @ 2:58 PM
Reply
171. Sir
Salam !
I am using RB 450 . I have install two ISP in the device and I am using
PCC method for load balancing. All the Things are running perfectly
alright. But I am facing problem with the FTP file zilla software. When
I
try to upload with the software with active two isp I got the
disconnection. After that I disable one connection and I tried the File
ziila software. Its works fine. Can you help me in this matter. How can I
exempt the IP PCC rules.plz help me .
http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

45/46

8/10/2014

Mikrotik DUAL WAN Load Balancing using PCC method. Complete Script ! by zaiB | Syed Jahanzaib Personnel Blog to Share Knowledge !

Comment by Babu July 7, 2014 @ 5:32 PM


Reply
Sir plz help me.
Comment by Babu July 7, 2014 @ 5:46 PM
Reply
have you read this ?
http://aacable.wordpress.com/2012/04/14/howto-exempt-any-user-website-from-mikrotik-pcc/
Comment by Syed Jahanzaib / Pinochio~:) July 9, 2014 @ 9:36 AM
Reply
172. hi,i have to links WAN1(10mb up 512k down) and WAN2(1mb up 5mb down),i want to use both links having WAN1 as my download and WAN2 as my
upload.how do i configure?? i hace ccr 12g
Comment by Jim July 25, 2014 @ 11:16 PM
Reply
173. correction.hi,i have to links WAN1(10mb down 512k up) and WAN2(1mb down 5mb up),i want to use both links using WAN2 as my main
upload.how do i configure?? i hace ccr 12g
Comment by Jim July 25, 2014 @ 11:18 PM
Reply
174. Dear Jahanzaib Sir,
I have two WAN Links
WAN1=203.80.130.74, 255.2555.255,252, DGW=203.80.130.73, DNS-203.80.130.1
WAN2 = DSL Model 10.92.4.2
please advise me how can configure failover router.
Regards
Abdul Wahab
Sukkur
Comment by Abdul Wahab August 17, 2014 @ 2:48 PM
Reply
RSS (Really Simple Syndication) feed for comments on this post. TrackBack URI (Uniform Resource Identifier)
The Silver is the New Black Theme. Blog at WordPress.com.
Follow

Follow Syed Jahanzaib Personnel Blog to Share Knowledge !


Powered by WordPress.com

http://aacable.wordpress.com/2011/07/27/mikrotik-dual-wan-load-balancing-using-pcc-method-complete-script-by-zaib/

46/46

Вам также может понравиться