Thursday, July 28, 2016

4 Wan Equal Load Balancing PPPoE Clients (PCC)


Ether 1 = DSL 1 = 192.168.1.1
Ether 2 = DSL 2 = 192.168.2.1
Ether 3 = DSL 3 = 192.168.3.1
Ether 4 = DSL 4 = 192.168.4.1
Ether 5 is your Local  192.168.5.1

/interface ethernet
set [ find default-name=ether1 ] name=ether1
set [ find default-name=ether2 ] name=ether2
set [ find default-name=ether3 ] name=ether3
set [ find default-name=ether4 ] name=ether4
set [ find default-name=ether5 ] name=ether5
/ip address
add address=192.168.1.2/24 interface=ether1 network=192.168.1.0
add address=192.168.2.2/24 interface=ether2 network=192.168.2.0
add address=192.168.3.2/24 interface=ether3 network=192.168.3.0
add address=192.168.4.2/24 interface=ether4 network=192.168.4.0
add address=192.168.5.1/24 interface=ether5 network=192.168.5.0
/interface pppoe-client
add add-default-route=yes disabled=no interface=ether1 max-mru=1480 max-mtu=\
    1480 name=pppoe-out1 password=#PWD use-peer-dns=no user=#USER1
add add-default-route=yes disabled=no interface=ether2 max-mru=1480 max-mtu=\
    1480 name=pppoe-out2 password=#PWD use-peer-dns=no user=#USER2
add add-default-route=yes disabled=no interface=ether3 max-mru=1480 max-mtu=\
    1480 name=pppoe-out3 password=#PWD use-peer-dns=no user=#USER3
add add-default-route=yes disabled=no interface=ether4 max-mru=1480 max-mtu=\
    1480 name=pppoe-out4 password=#PWD use-peer-dns=no user=#USER4
/ip pool
add name=dhcp_pool1 ranges=192.168.5.2-192.168.5.254
/ip dhcp-server
add address-pool=dhcp_pool1 disabled=no interface=ether1 name=dhcp1
/ip dhcp-server network
add address=192.168.5.0/24 gateway=192.168.5.1
/ip dns
set allow-remote-requests=yes cache-size=15000KiB servers=\
    208.67.222.222,208.67.220.220
/system note set note="Server Configuration By <HAMZA KHALIL> (www.itlearnweb.com)" show-at-login=yes
/ip firewall mangle
add chain=prerouting in-interface=pppoe-out1
add chain=prerouting in-interface=pppoe-out2
add chain=prerouting in-interface=pppoe-out3
add chain=prerouting in-interface=pppoe-out4
add action=mark-connection chain=prerouting dst-address-type=!local \
    new-connection-mark=wan1_conn per-connection-classifier=\
    both-addresses-and-ports:4/0
add action=mark-connection chain=prerouting dst-address-type=!local \
    new-connection-mark=wan2_conn per-connection-classifier=\
    both-addresses-and-ports:4/1
add action=mark-connection chain=prerouting dst-address-type=!local \
    new-connection-mark=wan3_conn per-connection-classifier=\
    both-addresses-and-ports:4/2
add action=mark-connection chain=prerouting dst-address-type=!local \
    new-connection-mark=wan4_conn per-connection-classifier=\
    both-addresses-and-ports:4/3
add action=mark-routing chain=prerouting connection-mark=wan1_conn \
    new-routing-mark=to_wan1
add action=mark-routing chain=prerouting connection-mark=wan2_conn \
    new-routing-mark=to_wan2
add action=mark-routing chain=prerouting connection-mark=wan3_conn \
    new-routing-mark=to_wan3
add action=mark-routing chain=prerouting connection-mark=wan4_conn \
    new-routing-mark=to_wan4
/ip firewall nat
add action=masquerade chain=srcnat out-interface=pppoe-out1
add action=masquerade chain=srcnat out-interface=pppoe-out2
add action=masquerade chain=srcnat out-interface=pppoe-out3
add action=masquerade chain=srcnat out-interface=pppoe-out4
add action=masquerade chain=srcnat comment="Masquerade Dhcp Network" src-address=192.168.5.0/24
/ip route
add check-gateway=ping distance=1 gateway=pppoe-out1 routing-mark=to_wan1
add check-gateway=ping distance=1 gateway=pppoe-out2 routing-mark=to_wan2
add check-gateway=ping distance=1 gateway=pppoe-out3 routing-mark=to_wan3
add check-gateway=ping distance=1 gateway=pppoe-out4 routing-mark=to_wan4
add check-gateway=ping distance=1 gateway=pppoe-out1
add distance=2 gateway=pppoe-out2
add distance=3 gateway=pppoe-out3
add distance=4 gateway=pppoe-out4

5 comments:

  1. Hamza bro, ye LB wali script failover ka kaam b krti hay kia ?

    ReplyDelete
  2. Hello... how we can forward a udp port from a internal IP (voip-server) to the wan's?

    ReplyDelete
  3. bhai maine ap se 1 sawaal pouchna hai k yr maine dream intenet se fiber pr link liya howa hai or meray pass 24mbps speed hai or mikrotik routerboard pr mera server bana howa hai pppoe or bhai masla yeh arha hai k download jab mai local server dream net jo hai emasti.pk mikrotik se jab mai connect hokr yeh server se downloading kr rha hu tou kbps mai downloading arhe hai jab k yeh tou 1 local sharing server hai nah dream network ka is tou mbps mai downloading ani chaahiye or bhai maine direct tplink pr downloading emasti.pk se checck ki hai tou 1mbps se ly kr 10mbps tak downloading arhe hai so please help me brother...

    ReplyDelete
  4. Sir Unequal with failover chaiye mujhe plz sent kar sakhty ho?

    ReplyDelete