CiscoTik

Networking Administration

CiscoTik

Networking Administration

CiscoTik

آموزش شبکه های مبتنی بر سیسکو و میکروتیک و ...

طبقه بندی موضوعی
محبوب ترین مطالب
نویسندگان
  • ۱
  • ۰

load balancing in MikroTik

سلام 

بر طبق شکل ، 2 عدد اینترنت (مثلا ADSL) وجود دارد که ما قرار است برای کاربران داخلی اینترنت را LOADBALANCE کنیم.دو رنج آدرس اینترنتی ما در شکل مشخص هستند.
یکی از روش های موجود در میکروتیک ECMP میباشد که از نوع Round Robin میباشد.
ECMP


دستورات را در 4 بخش باید انجام دهیم یعنی در بخش های NAT و Route و Mangle و آدرس.

IP Addresses

/ip firewall address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=Local add address=10.111.0.2/24 network=10.111.0.0 broadcast=10.111.0.255 interface=wlan2 add address=10.112.0.2/24 network=10.112.0.0 broadcast=10.112.0.255 interface=wlan1

The router has two upstream (WAN) interfaces with the addresses of 10.111.0.2/24 and 10.112.0.2/24. The LAN interface has the name "Local" and IP address of 192.168.0.1/24.


NAT

/ ip firewall nat 
add chain=srcnat out-interface=wlan1 action=masquerade
add chain=srcnat out-interface=wlan2 action=masquerade

As routing decision is already made we just need rules that will fix src-addresses for all outgoing packets. if this packet will leave via wlan1 it will be NATed to 10.112.0.2/24, if via wlan2 then NATed to 10.111.0.2/24


Routing

/ ip route
add dst-address=0.0.0.0/0 gateway=10.111.0.1,10.112.0.1,10.112.0.1,10.112.0.1,10.112.0.1,10.112.0.1 check-gateway=ping

This is typical ECMP (Equal Cost Multi-Path) gateway with check-gateway. ECMP is "persistent per-connection load balancing" or "per-src-dst-address combination load balancing". As soon as one of the gateway will not be reachable, check-gateway will remove it from gateway list. And you will have a "failover" effect.

You can use asymmetric bandwidth links also - for example one link is 2Mbps other 10Mbps. Just use this command to make load balancing 1:5



Mangle

/ ip firewall mangle
add chain=input in-interface=wlan1 action=mark-connection new-connection-mark=wlan1_conn add chain=input in-interface=wlan2 action=mark-connection new-connection-mark=wlan2_conn add chain=output connection-mark=wlan1_conn action=mark-routing new-routing-mark=to_wlan1 add chain=output connection-mark=wlan1_conn action=mark-routing new-routing-mark=to_wlan2
/ ip route
add dst-address=0.0.0.0/0 gateway=10.111.0.1 routing-mark=to_wlan1 
add dst-address=0.0.0.0/0 gateway=10.112.0.1 routing-mark=to_wlan2

یک توضیح برای قسمت mangle:
ابتدا در دو خط اول mangle و در chain که برابر input  است ، ابتدا ارتباط (  کلاینت ها ) ورودی به میکروتیک با اکشن marrk-connection ، با نام wlanx_conn  ، مارک میشود (علامتگذاری میشود) ، ( و در 2 خط بعدی ) و در هنگام خروج این کانکشنی که مارک شده بود (Wlanx_conn) ، با اکشن mark-routing و با نام to_wlanx علامتگذاری میشود ، تا با استفاده از 2 خط route و routing-mark ای که آنجا به نام to-wlanx تعریف شده ، مسیریابی درست روی ارتباط مورد نظر انجام میشود.

نظرات (۰)

هیچ نظری هنوز ثبت نشده است

ارسال نظر

ارسال نظر آزاد است، اما اگر قبلا در بیان ثبت نام کرده اید می توانید ابتدا وارد شوید.
شما میتوانید از این تگهای html استفاده کنید:
<b> یا <strong>، <em> یا <i>، <u>، <strike> یا <s>، <sup>، <sub>، <blockquote>، <code>، <pre>، <hr>، <br>، <p>، <a href="" title="">، <span style="">، <div align="">
تجدید کد امنیتی