CiscoTik

Networking Administration

CiscoTik

Networking Administration

CiscoTik

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

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

سلام به همه
در میکروتیک چند روش برای load-balancing مطرح شده.انواع و ویژگی های هرکدام را در شکل زیر مشاهده می شود.


یکی از روشها PCC مبیاشد که قرار است در این قسمت توضیح کاملی را بدهم...

مقدمه:
PCC روشی است که در آن ترافیک بطور مساوی داخل stream های برابر ، تقسیم میشود.

PCC matcher will allow you to divide traffic into equal streams with ability to keep packets with specific set of options in one particular stream (you can specify this set of options from src-address, src-port, dst-address, dst-port)

Theory

PCC takes selected fields from IP header, and with the help of a hashing algorithm converts selected fields into 32-bit value. This value then is divided by a specified Denominator and the remainder then is compared to a specified Remainder, if equal then packet will be captured. You can choose from src-address, dst-address, src-port, dst-port from the header to use in this operation.

per-connection-classifier=
PerConnectionClassifier ::= [!]ValuesToHash:Denominator/Remainder
  Remainder ::= 0..4294967295    (integer number)
  Denominator ::= 1..4294967295    (integer number)
  ValuesToHash ::= both-addresses|both-ports|dst-address-and-port|
  src-address|src-port|both-addresses-and-ports|dst-address|dst-port|src-address-and-port 

برای درک بهتر توضیح فوق لینک http://wiki.mikrotik.com/wiki/How_PCC_works_(beginner) را مشاهده کنید، اگر متوجه نشدید بگویید تا من توضیح بدهم.


کل دستورات زیر بیانگر روش PCC میباشد:

/ ip address
add address=192.168.0.1/24 network=192.168.0.0 broadcast=192.168.0.255 interface=LAN
add address=10.111.0.2/24 network=10.111.0.0 broadcast=10.111.0.255 interface=ISP1
add address=10.112.0.2/24 network=10.112.0.0 broadcast=10.112.0.255 interface=ISP2

/ ip firewall mangle
add chain=prerouting dst-address=10.111.0.0/24  action=accept in-interface=LAN
add chain=prerouting dst-address=10.112.0.0/24  action=accept in-interface=LAN
add chain=prerouting in-interface=ISP1 connection-mark=no-mark action=mark-connection \
    new-connection-mark=ISP1_conn
add chain=prerouting in-interface=ISP2 connection-mark=no-mark action=mark-connection \ 
    new-connection-mark=ISP2_conn
add chain=prerouting  in-interface=LAN connection-mark=no-mark dst-address-type=!local \
    per-connection-classifier=both-addresses:2/0 action=mark-connection new-connection-mark=ISP1_conn 
add chain=prerouting  in-interface=LAN connection-mark=no-mark dst-address-type=!local \ 
    per-connection-classifier=both-addresses:2/1 action=mark-connection new-connection-mark=ISP2_conn
add chain=prerouting connection-mark=ISP1_conn in-interface=LAN action=mark-routing \ 
    new-routing-mark=to_ISP1
add chain=prerouting connection-mark=ISP2_conn in-interface=LAN action=mark-routing \
    new-routing-mark=to_ISP2
add chain=output connection-mark=ISP1_conn action=mark-routing new-routing-mark=to_ISP1     
add chain=output connection-mark=ISP2_conn action=mark-routing new-routing-mark=to_ISP2

/ ip route
add dst-address=0.0.0.0/0 gateway=10.111.0.1 routing-mark=to_ISP1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.112.0.1 routing-mark=to_ISP2 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.111.0.1 distance=1 check-gateway=ping
add dst-address=0.0.0.0/0 gateway=10.112.0.1 distance=2 check-gateway=ping

/ ip firewall nat 
add chain=srcnat out-interface=ISP1 action=masquerade
add chain=srcnat out-interface=ISP2 action=masquerade


فرض بر اینست که آدرس ها وکلا شکل همان شکل پست ECMP (که خود یک روش دیگر load-balancing میباشد) است.


با فرض فوق تمام بخش ها را در زیر توضیح میدهم...


Policy routing

/ ip firewall mangle
add chain=prerouting dst-address=10.111.0.0/24  action=accept in-interface=LAN
add chain=prerouting dst-address=10.112.0.0/24  action=accept in-interface=LAN

با Policy routing ، تمام ترافیک ها یی که از شبکه connected می آیند به سمت گیت وی انتقال داده میشوند (حتی ترافیک هایی که مقصدشان گیت وی نباشد).در نتیجه یک loop ایجاد شده و مانع از ارتباط هاست ها بایکدیگر میشود.

برای جلوگیری از آن باید از یک default routing table برای ترافیک های connected باید استفاده کرد.

add chain=prerouting in-interface=ISP1 connection-mark=no-mark action=mark-connection \
    new-connection-mark=ISP1_conn
add chain=prerouting in-interface=ISP2 connection-mark=no-mark action=mark-connection \ 
    new-connection-mark=ISP2_conn

در مرحله اول باید ارتباطات آغاز شده از خارج به روتر رامدیریت کنیم.یعنی به در خواستهایی که از بیرون شبکه می آیند ، پاسخشان را از همان اینترفیس روتر (آدرس های public )بگیرند.
ساده تر بگویم:یک در خواستی از اینترنت به اینرفیس روتر ما که دارای IP public است آمده ، حال Reply تولید شده از این اینتر فیس باید خارج شود. :دی

2 خط بالاییی و 2 خط پایینی مربوط به ارتباط رفت و برگشت از کلاینت به اینترنت و بلعکس است...

add chain=prerouting  in-interface=LAN connection-mark=no-mark dst-address-type=!local \
    per-connection-classifier=both-addresses:2/0 action=mark-connection new-connection-mark=ISP1_conn 
add chain=prerouting  in-interface=LAN connection-mark=no-mark dst-address-type=!local \ 
    per-connection-classifier=both-addresses:2/1 action=mark-connection new-connection-mark=ISP2_conn

دستورات فوق یعنی اگر LAN وروردی باشد، ولی مقصد local نباشد و باقیمانده مقدار  hash شده که شامل مبدا و مقصد یک درخواست است بر2 ، مقادیر 0 و یا 1 شد ، این ارتباط را با نام ISP1_conn و ISP2_conn مارک میکند.

عدد 2 همان تعداد ISP ها یا اینترفیس های با IP Valid هستند.

برای درک بهتر توضیح فوق لینک http://wiki.mikrotik.com/wiki/How_PCC_works_(beginner) را مشاهده کنید، اگر متوجه نشدید بگویید تا من توضیح بدهم.


Action mark-routing can be used only in mangle chain output and prerouting, but mangle chain prerouting is capturing all traffic that is going to the router itself. To avoid this we will use dst-address-type=!local. And with the help of the new PCC we will divide traffic into two groups based on source and destination addressees



add chain=prerouting connection-mark=ISP1_conn in-interface=LAN action=mark-routing \ 
    new-routing-mark=to_ISP1
add chain=prerouting connection-mark=ISP2_conn in-interface=LAN action=mark-routing \
    new-routing-mark=to_ISP2
add chain=output connection-mark=ISP1_conn action=mark-routing new-routing-mark=to_ISP1     
add chain=output connection-mark=ISP2_conn action=mark-routing new-routing-mark=to_ISP2

در اینجا ما تمام ارتباطات (از کلاینت ها به گیت وی را) مارک می کنیم.polidy routing فقط برای ترافیک هایی هستند که به سمت اینترنت میروند.

do not forget to specify in-interface option

..............................................

با تشکر از شما:mohammad ba


نظرات (۱)

با تشکر از پست مفیدتون
پاسخ:
سلام .ممنون از لطف شما

ارسال نظر

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