Welcome to Sysnet Board คู่มือ การใช้งานอุปกรณ์ Network. Please log in or sign up.
สมาชิกทั้งหมด
17,595
กระทู้ทั้งหมด
10,026
หัวข้อทั้งหมด
4,711

  • การทำ Loadbalance Internet Static IP 2 เส้น แบบ PCC
    เริ่มโดย yod
    Read 43,119 times
0 สมาชิก และ 1 ผู้มาเยือน กำลังดูหัวข้อนี้
yod

 

 

การทำ Loadbalance Internet Static IP 2 เส้น แบบ PCC



การทำ loadbalance แบบนี้ ข้อดีคือจะจัดการตาม session เลยครับ เพราะฉะนั้นจะไม่มีปัญหาเรื่องการเข้า web พวก ssl แต่ค่อนข้างจะกิน cpu นะครับ ไม่แนะนำให้ใช้กับรุ่น Mikrotik RB-750 แต่ถ้าใช้ร่วมกับระบบ Hotspot Server ควรเป็นรุ่น RB-450G ขึ้นไปครับ

ตัวอย่างจะเป็นการต่อ Internet 2 คู่สาย โดยอาจจะใช้ร่วมกับ Cable Modem, Fiberoptic หรือ Interent ที่รับมาจาก Wireless เช่น TOT Winet




Port Ether1 ของ Mikrotik เข้ากับ Router#1 เป็น IP 192.168.2.1 และ Port Ether2 เข้ากับ Router#2 เป็น IP 192.168.3.1 กำหนด IP ที่ตัว Mikrotik ที่ Port Ether1=192.168.2.2 และ Port Ether2=192.168.3.2 ให้ Port Ether3-5 เป็น Bridge (สะพาน) เชื่อมถึงกัน IP เป็น 192.168.1.1

IP Address ของฝั่ง Internet กับฝั่ง Lan ของ Mikrotik ห้ามอยูในวง Network เดียวกันนะครับ


เนื่องจากการ Config อุปกรณ์ Mikrotik จะสามารถทำได้หลายรูปแบบแต่ให้ผลลัพท์ที่เหมือนกัน จะขออ้างอิงการ Config ต่อเนื่องจากหัวข้อ

การ Config อุปกรณ์ Mikrotik RouterBoard เบื้องต้น #1
การ Config อุปกรณ์ Mikrotik RouterBoard เบื้องต้น #2


หรือจากที่ผม Config ส่งไปให้ครับ ในกรณีที่ Config อะไรไปเยอะแล้ว แนะนำให้ Backup ไว้ และRestore ค่าที่ผม Backup ไว้ก่อนครับ  :D


1. Login เข้า Winbox เข้า Menu PPP ให้ Disable pppoe-out1




2.  เข้า Menu Bridge --> Ports ให้ลบ ether2 ออกจากสมาชิกใน Bridge1 จะเหลือเพียง ether3,4,5 ในกรณีใช้ 3Wan ก็ลบ ether3 ออกด้วยครับ




3. เข้า Menu IP --> Address สร้าง Network ขึ้นมาสำหรับ Port ether2
Address: 192.168.2.2/24
Network: 192.168.2.0
Interface: ether1



Click [OK]

เสร็จแล้วสร้าง Address สำหรับ Port ether3
Address: 192.168.3.2/24
Network: 192.168.3.0
Interface: ether2



Click [OK]


4. Copy script ด้านล่าง เลือกเอาอย่างใดอย่างนึงนะครับ

#ไม่ได้ทำ Hotspot Server


/ip firewall mangle
add action=accept chain=prerouting disabled=no in-interface=eth1
add action=accept chain=prerouting disabled=no in-interface=eth2

add action=mark-connection chain=prerouting disabled=no dst-address-type=!local \
new-connection-mark=wan1_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0 src-address=192.168.1.0/24

add action=mark-connection chain=prerouting disabled=no dst-address-type=!local \
new-connection-mark=wan2_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1 src-address=192.168.1.0/24


add action=mark-routing chain=prerouting connection-mark=wan1_conn disabled=no new-routing-mark=to_wan1 passthrough=yes src-address=192.168.1.0/24
add action=mark-routing chain=prerouting connection-mark=wan2_conn disabled=no new-routing-mark=to_wan2 passthrough=yes src-address=192.168.1.0/24

/ip firewall nat
add action=masquerade chain=srcnat disabled=no out-interface=eth1 src-address=192.168.1.0/24
add action=masquerade chain=srcnat disabled=no out-interface=eth2 src-address=192.168.1.0/24

/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_wan1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.3.1 routing-mark=to_wan2 scope=30 target-scope=10

add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.2.1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.3.1 scope=30 target-scope=10



#ใช้ร่วมกับ Hotspot Server


/ip firewall mangle
add action=accept chain=prerouting disabled=no in-interface=eth1
add action=accept chain=prerouting disabled=no in-interface=eth2

add action=mark-connection chain=prerouting disabled=no dst-address-type=!local hotspot=auth \
new-connection-mark=wan1_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:2/0 src-address=192.168.1.0/24

add action=mark-connection chain=prerouting disabled=no dst-address-type=!local hotspot=auth \
new-connection-mark=wan2_conn passthrough=yes per-connection-classifier=both-addresses-and-ports:2/1 src-address=192.168.1.0/24


add action=mark-routing chain=prerouting connection-mark=wan1_conn disabled=no new-routing-mark=to_wan1 passthrough=yes src-address=192.168.1.0/24
add action=mark-routing chain=prerouting connection-mark=wan2_conn disabled=no new-routing-mark=to_wan2 passthrough=yes src-address=192.168.1.0/24

/ip firewall nat
add action=masquerade chain=srcnat disabled=no out-interface=eth1 src-address=192.168.1.0/24
add action=masquerade chain=srcnat disabled=no out-interface=eth2 src-address=192.168.1.0/24

/ip route
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.2.1 routing-mark=to_wan1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.3.1 routing-mark=to_wan2 scope=30 target-scope=10

add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.2.1 scope=30 target-scope=10
add check-gateway=ping disabled=no distance=1 dst-address=0.0.0.0/0 gateway=192.168.3.1 scope=30 target-scope=10



Copy แล้ว Click ขวาเลือก Paste ที่ New Terminal



เคาะ Enter 1 ครั้ง


5. เข้า Menu IP --> Firewall --> NAT
Disable รายการตามรูป จะเหลือแค่ 2 รายการครับ รายการที่ Disable จะเป็น NAT mทาง Hotspot Server สร้างเอาไว้อัตโนมัติ




6. ตรวจสอบรายการที่ Menu IP --> Firewall --> Mangle





ทดสอบ

ปล่อย Internet เส้นละ 3Mbps เมื่อ Download Bittorrent จะได้ 6Mbps เต็มๆครับ




ดึงสาย Internet ออกทีละเส้น ในกรณีที่ Internet เส้นใดเส้นนึงมีปัญหา จะต้อง Download ได้ปกติ






เรียบร้อยครับ

รบกวนถามหน่อยครับว่า
ถ้าไม่ต้องการทำ Loadbalance Internet Static IP 2 เส้น
แต่ต้องการทำแค่ static wan ip 1 เส้นจะต้องทำยังไงครับ
ขอบคุณครับ

เวลาเล่นเกม online จะมีปัญหาไหมครับ เรื่องการสลับ wan

yod


ยังไม่เคยลองเลยครับ ถ้ามีปัญหากับพวกเกมส์ Online หรือพวก Internet Banking ให้ใช้เป็นแบบ NTH จะดีกว่าครับ



ยังไม่เคยลองเลยครับ ถ้ามีปัญหากับพวกเกมส์ Online หรือพวก Internet Banking ให้ใช้เป็นแบบ NTH จะดีกว่าครับ
[/quote]แล้วแบบ NTH มีที่ไม่ต้องทำ modem เป็น bridge ไหมครับ พอดีใช้ร่วมกับ TOT Winet ด้วย มันไม่สามารถทำให้เป็น bridge ได้
ขอบคุณครับ


yod
ลองดูนะครับ ขา 1 PPPoE Client ส่วนขา 2 เป็น Static ครับ

/ ip firewall mangle
add chain=input in-interface=pppoe-out1 action=mark-connection new-connection-mark=wan1_conn
add chain=input in-interface=ether2 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-type=!local hotspot=auth in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:2/0 \
action=mark-connection new-connection-mark=wan1_conn passthrough=yes
add chain=prerouting dst-address-type=!local hotspot=auth in-interface=bridge1 per-connection-classifier=both-addresses-and-ports:2/1 \
action=mark-connection new-connection-mark=wan2_conn passthrough=yes

add chain=prerouting connection-mark=wan1_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_wan1
add chain=prerouting connection-mark=wan2_conn in-interface=bridge1 action=mark-routing new-routing-mark=to_wan2

/ ip route
add dst-address=0.0.0.0/0 gateway=pppoe-out1 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

/ ip firewall nat
add chain=srcnat out-interface=pppoe-out1 action=masquerade
add chain=srcnat src-address=192.168.2.0/24 action=masquerade

ต้องการทำ Load balance Internet Static IP 3 เส้น รุ่น RB-450G ใช้ร่วมกับ Hotspot

- 3 WAN => Eth1,Eth2,Eth3
- 2 LAN => Eth4,Eth5

จะทำได้หรือเปล่า ถ้าทำได้ขอขั้นตอนการทำด้วยครับ

ทำไม Loadbalance ผมใช้สองเส้นแต่เข้าไปดูมันใช้เส้นเดียวตลอด ไม่เห็นมันโหลดพร้อมกัน แต่ถ้าดึงสายหนึ่งออกมันถึงจะใช้อีกสายหนึ่ง

yod


ลองโหลดบิตที่มีคนปล่อยเยอะๆครับ