ที่มา :
http://www.truefaster.com/bbs/index.php/topic,4001.0.html======================================================
วันนี้ขออนุญาต มาใช้บอร์ดที่เว็บไซต์ http://siamcafe.net
จุดประสงค์ :
- เพื่อแบ่งปันโค๊ดดีๆ สร้างเสริมนิสัยการ Open Source ให้กับประชาชนคนไทย มิใช่หวังเอาแต่ได้ เอาผลกำไรอย่างเดียว
- เพื่อให้ร้านเน็ตที่มีทุนน้อย สามารถทำระบบเน็ตสองสายแบบประหยัดได้ด้วยตัวเอง (เบื้องต้น)
หมายเหตุ :
ขออภัยที่ผมไม่ได้ป้อนทุกอย่างให้ท่าน เพราะหัวข้อของผม "กระตุกต่อมคิด" ครับ
ความตั้งใจผมสอนให้ท่านคิดเป็นทำเป็น ไม่ใช่อ้าปากรอรับอย่างเดียว เด๋วเป็นโปลิโอ นะจ๊ะ :c_laugh: (มุขนะครับ)
เพิ่มเติม
====== ภาพตัวอย่างการโหลด Bittorrent ด้วยความเร็ว Unlimited V.D.O.สาธิตประสิทธิภาพการแยกเน็ต+เกม+แยกBit แบบ 3 เส้น ________________________________________________________
2+1 WANs
========= [ Net ]-----------------
|-------------[linux Server]---------. . .
[Games]----------------
- แบบนี้แยกเน็ต แยกเกมส์ อยู่คนละเส้น
อยากดูโค๊ดใหม่เค้า โพสท์ตอบก่อนน้า ตะเอง [hide]
ขั้นตอนการทำแบบละเอียด
====================
0. ดาวน์โหลดไฟล์ rc.firewall.local ที่นี่ : rc.firewall.rar
1. อ่านคู่มือของคุณ xxxkung ที่นี่ : http://www.truefaster.com/bbs/index.php/topic,4027.0.html
2. อ่านและทำตามในหัวข้อต่อไปนี้
ตอนที่ 2 การติดตั้งโปรแกรม ClarkConnect 4.2 Enterprise (Installation)
ตอนที่ 4 การเชื่อมต่ออินเตอร์เน็ต (Network Configuration)
ตอนที่ 5 การลงทะเบียน ClarkConnect (Register)
ตอนที่ 7 การเชื่อมต่ออินเตอร์เน็ตแบบหลายเส้น ( Multi-WAN 1 )
- อ่านจนถึง Enable Multiwan
ตอนที่ 8 การเชื่อมต่ออินเตอร์เน็ตแบบหลายเส้น ( Multi-WAN 2 iptables )
ตอนที่ 9 ปรับแต่ง Firewall ให้ Create Dot A ( Port forwarding )
- เฉพาะหน้า 54-55
3. โหลด tool ที่จำเป็นในการเซ็ตค่าต่าง ๆ บนเซิร์ฟเวอร์ผ่านเครื่องลูกที่นี่
- winscp : http://www.winscp.net
- putty : http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe
4. ทำการลง Frox สามารถโหลดได้จากที่นี่ :
- TruefasterFroxV1 (default):
http://download2.truefaster.com/program/TF-Frox/TruefasterFroxV0.1.tar.gz
- TruefasterFroxV2 (HipStreet support):
http://download2.truefaster.com/program/TF-Frox/TruefasterFroxV0.2.tar.gz
5. ใช้ winscp เชื่อมต่อไปยังเซิร์ฟเวอร์ CC ของท่าน
- ไปที่ /etc/rc.d ใน path นี้ ท่านจะเห็น rc.firewall.local
- ให้โอนไฟล์ rc.firewall.local ของเราเข้าไปทับแทนที่
6. ใช้ putty เชื่อมต่อเข้าไปที่เซิร์ฟเวอร์ CC ของท่าน
- รันคำสั่ง service firewall restart
- และ . /etc/rc.d/rc.firewall.local
เพียงเท่านี้ ท่านก็จะสามารถทำ MULTIWAN แยกเน็ต+เกม 2 สาย ได้ด้วยตนเองแล้วครับ
# ----- 2 WANs
# ----- change to you local IP
My_Local_Net=192.168.0.0/16
Game_Mark=0x8000
Net_Mark=0x8001
# ----- Controls settings
echo "1" > /proc/sys/net/ipv4/ip_forward
echo "1" > /proc/sys/net/ipv4/conf/default/rp_filter
echo "1" > /proc/sys/kernel/core_uses_pid
# ----- Flush
iptables -t mangle -F
modprobe ip_nat_ftp
modprobe ip_tables
modprobe iptable_nat
modprobe ipt_conntrack
modprobe ip_conntrack
modprobe ip_conntrack_ftp
modprobe ip_conntrack_irc
modprobe ip_nat_irc
modprobe ip_nat_snmp_basic
# ----- set default policies
iptables -P INPUT ACCEPT
iptables -P FORWARD ACCEPT
iptables -P OUTPUT ACCEPT
# ----- set default policies
iptables -t nat -P PREROUTING ACCEPT
iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P OUTPUT ACCEPT
# ----- set default policies
iptables -t mangle -P PREROUTING ACCEPT
iptables -t mangle -P POSTROUTING ACCEPT
iptables -t mangle -P INPUT ACCEPT
iptables -t mangle -P OUTPUT ACCEPT
iptables -t mangle -P FORWARD ACCEPT
# ----- IP sharing
# iptables -t nat -D POSTROUTING -o eth+ -j MASQUERADE > /dev/null
iptables -t nat -D POSTROUTING -s $My_Local_Net -o ppp+ -j MASQUERADE > /dev/null
# iptables -t nat -A POSTROUTING -o eth+ -j MASQUERADE
iptables -t nat -A POSTROUTING -s $My_Local_Net -o ppp+ -j MASQUERADE
# ----- Squid
if [ -f /var/run/squid.pid ]; then
iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128 > /dev/null
iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 3128
fi
# ----- Frox
if [ -f /var/run/frox.pid ]; then
iptables -t nat -D PREROUTING -i eth+ -p tcp --dport 21 -j REDIRECT --to-port 2121 > /dev/null
iptables -t nat -D PREROUTING -i eth+ -p tcp -m multiport --dports 21,5977 -j REDIRECT --to-port 2121 > /dev/null
iptables -t nat -I PREROUTING -i eth+ -p tcp -m multiport --dports 21,5977 -j REDIRECT --to-port 2121
# Luna (ทาง Luna Server ทำการแก้ไขแล้ว วิ่งออก Frox ได้ตามปกติ)
# Darkstory (ไปโหลดไฟล์ AutoPatch ตัวใหม่มาลงทับ ก็เล่นได้ครับ หรือจะเปิด comment ออกเพื่อให้วิ่งตรง ๆ ไม่ผ่าน Frox)
# TS
iptables -t nat -D PREROUTING -p tcp -d 203.144.137.5 --dport 21 -j ACCEPT
iptables -t nat -I PREROUTING -p tcp -d 203.144.137.5 --dport 21 -j ACCEPT
fi
# ----- Msn Yahoo Icq Irc
if [ -f /var/run/imspector.pid ]; then
iptables -t nat -D PREROUTING -p tcp -m multiport --dports 1863,6667,5050,5190 -j REDIRECT --to-port 16667 > /dev/null
iptables -t nat -A PREROUTING -p tcp -m multiport --dports 1863,6667,5050,5190 -j REDIRECT --to-port 16667
fi
# ----- ----- ----- ----- ----- ----- ----- ----- #
# - START - multi wan 2 Line
# ----- ----- ----- ----- ----- ----- ----- ----- #
# ----- Note
# ppp0 = 0x8000 / ppp1 = 0x8001
# ----- Create our own CHAINS
# ----- Creat GOTO_GAME
iptables -t mangle -N GOTO_GAME
iptables -t mangle -F GOTO_GAME
iptables -t mangle -A GOTO_GAME -j MARK --set-mark $Game_Mark
# ----- Creat GOTO_NET
iptables -t mangle -N GOTO_NET
iptables -t mangle -F GOTO_NET
iptables -t mangle -A GOTO_NET -j MARK --set-mark $Net_Mark
# ----- Create CHECK_SERVICE_PORTS
iptables -t mangle -N CHECK_SERVICE_PORTS
iptables -t mangle -F CHECK_SERVICE_PORTS
iptables -t mangle -A CHECK_SERVICE_PORTS -p tcp -m multiport --dports 20:25,80,443,554,1863,2121,5050,5190,3128,3130,8080,16667 -j ACCEPT
# ----- Create CHECK_GAMES
iptables -t mangle -N CHECK_GAMES
iptables -t mangle -F CHECK_GAMES
# CSO, check port of game patching. If so, using LoadBalance.
iptables -t mangle -A CHECK_GAMES -d 202.43.33.0/24 -p tcp --dport 9898 -j ACCEPT
# Asiasoft
iptables -t mangle -A CHECK_GAMES -d 203.144.0.0/16 -j GOTO_GAME
# <unknown>
iptables -t mangle -A CHECK_GAMES -d 203.146.0.0/16 -j GOTO_GAME
# SF,LN2, Asiasoft International
iptables -t mangle -A CHECK_GAMES -d 61.90.0.0/16 -j GOTO_GAME
# ProjectOne, DOMO
iptables -t mangle -A CHECK_GAMES -d 61.19.0.0/16 -j GOTO_GAME
# Seal, HY, 3Kingdoms, 16
iptables -t mangle -A CHECK_GAMES -d 61.47.0.0/16 -j GOTO_GAME
# PFW, Eco
iptables -t mangle -A CHECK_GAMES -d 61.91.0.0/16 -j GOTO_GAME
# HipStreet
iptables -t mangle -A CHECK_GAMES -d 58.97.46.10/32 -j GOTO_GAME
iptables -t mangle -A CHECK_GAMES -d 58.97.46.16/32 -j GOTO_GAME
# Pangya, Rebirth, Pucca, Flyff
iptables -t mangle -A CHECK_GAMES -d 58.64.0.0/16 -j GOTO_GAME
# DotA, Getamped
iptables -t mangle -A CHECK_GAMES -d 210.86.0.0/16 -j GOTO_GAME
# LunaOnline, pko, water, SDO, Secret, RYL
iptables -t mangle -A CHECK_GAMES -d 202.43.0.0/16 -j GOTO_GAME
# RAN
iptables -t mangle -A CHECK_GAMES -d 203.142.0.0/16 -j GOTO_GAME
# TalesRunner
iptables -t mangle -A CHECK_GAMES -d 203.113.0.0/16 -j GOTO_GAME
# ----- Create CHECK_BONUS
iptables -t mangle -N CHECK_BONUS
iptables -t mangle -F CHECK_BONUS
iptables -t mangle -A CHECK_BONUS -d secure1.asiasoft.co.th -p tcp --dport 443 -j GOTO_GAME
iptables -t mangle -A CHECK_BONUS -d secure1.asiasoft.co.th -p tcp --dport 443 -j ACCEPT
iptables -t mangle -A CHECK_BONUS -d secure2.asiasoft.co.th -p tcp --dport 443 -j GOTO_GAME
iptables -t mangle -A CHECK_BONUS -d secure2.asiasoft.co.th -p tcp --dport 443 -j ACCEPT
# ----- START rule adding
# Firstly, Allow to add IP-Bonus via ppp0
iptables -t mangle -A PREROUTING -p tcp -s $My_Local_Net -j CHECK_BONUS
# set mark for packet to go to NET
iptables -t mangle -A PREROUTING -d ! $My_Local_Net -j GOTO_NET
# Service Ports
iptables -t mangle -A PREROUTING -s $My_Local_Net -d ! $My_Local_Net -j CHECK_SERVICE_PORTS
iptables -t mangle -A OUTPUT -s $My_Local_Net -d ! $My_Local_Net -j CHECK_SERVICE_PORTS
iptables -t mangle -A FORWARD -s $My_Local_Net -d ! $My_Local_Net -j CHECK_SERVICE_PORTS
# Games
# PREROUTING
iptables -t mangle -A PREROUTING -s $My_Local_Net -j CHECK_GAMES
# FORWARD
iptables -t mangle -A FORWARD -s $My_Local_Net -j CHECK_GAMES
# DotA (no need cache)
# Create DotA
iptables -t mangle -A PREROUTING -s $My_Local_Net -d ! $My_Local_Net -p tcp -m multiport --sports 6001:6100,7001:7200 -j GOTO_GAME
iptables -t mangle -A OUTPUT -s $My_Local_Net -d ! $My_Local_Net -p tcp -m multiport --sports 6001:6100,7001:7200 -j GOTO_GAME
iptables -t mangle -A FORWARD -s $My_Local_Net -d ! $My_Local_Net -p tcp -m multiport --sports 6001:6100,7001:7200 -j GOTO_GAME
# Join DotA
iptables -t mangle -A PREROUTING -s $My_Local_Net -d ! $My_Local_Net -p tcp -m multiport --dports 6001:7500 -j GOTO_GAME
iptables -t mangle -A OUTPUT -s $My_Local_Net -d ! $My_Local_Net -p tcp -m multiport --dports 6001:7500 -j GOTO_GAME
iptables -t mangle -A FORWARD -s $My_Local_Net -d ! $My_Local_Net -p tcp -m multiport --dports 6001:7500 -j GOTO_GAME
# No match, use Load Balance
iptables -t mangle -A PREROUTING -d ! $My_Local_Net -j ACCEPT
# ----- END rule adding
# ----- ----- ----- ----- ----- ----- ----- ----- #
# - END - multi wan 2 Line
# ----- ----- ----- ----- ----- ----- ----- ----- #
# ----- Load Balance
ppp1_gw=`ip route | grep ppp1 | head -1 | cut -f 1 -d " "`
ip route add default table 250 proto static nexthop via $ppp1_gw dev ppp1 weight 200
ip route change default table 250 proto static nexthop via $ppp1_gw dev ppp1 weight 200
# ----- ----- ----- ----- ----- ----- ----- ----- #
[/hide]
3+1 WANs
========= [Games]---------------
|
[ Net ]------------------------------[linux Server]---------. . .
|
[ Net ]-----------------
- แบบนี้ แยกเกมส์ทั้งหมดไปอยู่เส้นนึง อีกสองเส้นทำ load balance สำหรับเน็ต
[Games AiaSoft]------
|
[Games Others]------------------[linux Server]---------. . .
|
[ Net ]-----------------
- แบบนี้ให้เกมส์ Asiasoft เส้นนึง, เกมส์ค่ายอื่นๆ เส้นนึง, แล้วก็เน็ตเส้นนึง
5+1 WANs
========= [Games AiaSoft]------
|
[Games Others]-------
|
[Bit Torrent]----------------------------[linux Server]---------. . .
|
[ Net ]-----------------
|
[ Net ]-----------------
- แบบนี้ให้เกมส์ Asiasoft เส้นนึง, เกมส์ค่ายอื่นๆ เส้นนึง, ให้โหลดบิทเส้นนึง, แล้วก็เน็ต 2 เส้นทำ load balance
ท่านใด มีไอเดียเจ๋งๆ ก็เรียนเชิญมาร่วมจินตนาการ แบบ ขำ ๆ ด้วยกันนะครับ
หากมีผลบุญกุศลใดๆ อันเกิดจากการแบ่งปันโค๊ดและให้ความรู้ของข้าพเจ้าตั้งแต่ในอดีตจนถึงปัจจุบัน ขอให้ผลบุญนั้นจงตกอยู่แก่ตัวข้าพเจ้าทั้งหมด เพื่อความสุข ความเจริญ ไร้โรคาพยาธิ
หมดทุกข์ หมดโศก หมดโรค หมดภัย ของตัวข้าพเจ้า, ของบิดามารดาของข้าพเจ้า, ของคนรักของข้าพเจ้า, ของครอบครัวของข้าพเจ้า, ของญาติสนิทมิตรสหายของข้าพเจ้า
ตลอดจนเจ้ากรรมนายเวรทั้งหลายของข้าพเจ้าด้วย ขอให้ท่านทั้งหลายที่ข้าพเจ้าได้เอ่ยถึงมาทั้งหมดนี้ จงได้รับส่วนบุญส่วนกุศลที่ข้าพเจ้าได้อุทิศให้นี้ด้วยเทอญ สาธุ