บทความอัพเดทในเว็บ ขออนุญาตอัพเดทช่องทาง https://fb.com/siamcafefan

ผู้เขียน หัวข้อ: รบกวนถามเรื่อง script 3wan ตอน "เมื่อเน็ตเน่าไป1สาย"  (อ่าน 3059 ครั้ง)

0 สมาชิก และ 1 บุคคลทั่วไป กำลังดูหัวข้อนี้

jededjed

  • บุคคลทั่วไป
ตอนนี้ที่ร้านผมใช้เน็ต 3 สายครับ ppp0= game, ppp1=net, ppp2=net load ตามกฏดังต่อไปนี้นะครับ

1 line
# ----------------------------------------------------------------------
if [ $_PPPCONNECTSTATUS -eq 001 ]; then
   iptables -t mangle -I LINE_GAME -j MULTIWAN_ppp2
   iptables -t mangle -I LINE_NET -j MULTIWAN_ppp2
   iptables -t mangle -I LINE_NET_LOAD -j MULTIWAN_ppp2
elif [ $_PPPCONNECTSTATUS -eq 010 ]; then
   iptables -t mangle -I LINE_GAME -j MULTIWAN_ppp1
   iptables -t mangle -I LINE_NET -j MULTIWAN_ppp1
   iptables -t mangle -I LINE_NET_LOAD -j MULTIWAN_ppp1
elif [ $_PPPCONNECTSTATUS -eq 100 ]; then
   iptables -t mangle -I LINE_GAME -j MULTIWAN_ppp0
   iptables -t mangle -I LINE_NET -j MULTIWAN_ppp0
   iptables -t mangle -I LINE_NET_LOAD -j MULTIWAN_ppp0
#
# 2 line
# ----------------------------------------------------------------------
elif [ $_PPPCONNECTSTATUS -eq 011 ]; then
   iptables -t mangle -I LINE_GAME -j MULTIWAN_ppp1
   iptables -t mangle -I LINE_NET -j MULTIWAN_ppp2
   iptables -t mangle -I LINE_NET_LOAD -j MULTIWAN_ppp2
elif [ $_PPPCONNECTSTATUS -eq 110 ]; then
   iptables -t mangle -I LINE_GAME -j MULTIWAN_ppp0
   iptables -t mangle -I LINE_NET -j MULTIWAN_ppp1
   iptables -t mangle -I LINE_NET_LOAD -j MULTIWAN_ppp1
elif [ $_PPPCONNECTSTATUS -eq 101 ]; then
   iptables -t mangle -I LINE_GAME -j MULTIWAN_ppp0
   iptables -t mangle -I LINE_NET -j MULTIWAN_ppp2
   iptables -t mangle -I LINE_NET_LOAD -j MULTIWAN_ppp2
#
# 3 line
# ----------------------------------------------------------------------
elif [ $_PPPCONNECTSTATUS -eq 111 ]; then
   iptables -t mangle -I LINE_GAME -j MULTIWAN_ppp0
   iptables -t mangle -I LINE_NET -j MULTIWAN_ppp1
   iptables -t mangle -I LINE_NET_LOAD -j MULTIWAN_ppp2
   ip route change default table 250 proto static nexthop via $_PPP1_ADDR dev ppp1 weight 10 nexthop via $_PPP2_ADDR dev ppp2 weight 30

แต่ตอนนี้ ppp0 ของผมมันเสีย(catมีปัญหา) ตามกฏคือ มันจะให้ เกมมาวิ่งที่ ppp1 ส่วนnet กับ net load จะวิ่งรวมกันที่ ppp2
แต่มันดันมีการโหลดการเปิดหน้าเว็บ การเปิด hi5 เข้ามาวิ่ง ที่ ppp1 ด้วยครับ

ขอคำแนะนำจากผู้รู้ด้วยครับ

ออฟไลน์ Admin!

  • อยู่ใต้ฟ้าอย่าท้าฝน เกิดเป็นคนอย่าท้ากรรม !
  • admin
  • ********
  • กระทู้: 4182
  • Reputation: 101
  • เพศ: ชาย
  • สัจจะคือคำขาด
    • http://www.siamcafe.net
Re: รบกวนถามเรื่อง script 3wan ตอน "เมื่อเน็ตเน่าไป1สาย"
« ตอบกลับ #1 เมื่อ: พฤษภาคม 05, 2009, 01:13:31 pm »
ให้ใช้ script ที่ MR.X เคยแจกๆไปใน board ๆนี้หละครับ ..ลองดู เพราะจริงๆ กฎเดิมๆของ Clark นั้นทำระบบ Fail over เอาไว้ให้ดีแล้วไม่ต้องไปแก้ไขอะไรมันก็ทำงานเองนะครับ :001:

ออฟไลน์ Admin!

  • อยู่ใต้ฟ้าอย่าท้าฝน เกิดเป็นคนอย่าท้ากรรม !
  • admin
  • ********
  • กระทู้: 4182
  • Reputation: 101
  • เพศ: ชาย
  • สัจจะคือคำขาด
    • http://www.siamcafe.net
Re: รบกวนถามเรื่อง script 3wan ตอน "เมื่อเน็ตเน่าไป1สาย"
« ตอบกลับ #2 เมื่อ: พฤษภาคม 05, 2009, 01:25:08 pm »
โค๊ด: [Select]
# ----- 2 WANs By Mr.X
# ----- change to you local IP

Lan="192.168.0.0/16"
Games="MARK --set-mark 0x8000"
Net="MARK --set-mark 0x8001"
Any="0.0.0.0/0"
E="eth1"

# iptables -t mangle -F PREROUTING > /dev/null

# ----- start fwmark
# ----- finding pppX address & gateway
eth1_addr=`ifconfig | grep -A1 eth1 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "`
ppp0_addr=`ifconfig | grep -A1 ppp0 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "`
ppp1_addr=`ifconfig | grep -A1 ppp1 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "`
ppp2_addr=`ifconfig | grep -A1 ppp2 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "`
ppp3_addr=`ifconfig | grep -A1 ppp3 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "`
ppp4_addr=`ifconfig | grep -A1 ppp4 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "`

ppp0_gw=`ip route | grep ppp0 | head -1 | cut -f 1 -d " "`
ppp1_gw=`ip route | grep ppp1 | head -1 | cut -f 1 -d " "`
ppp2_gw=`ip route | grep ppp2 | head -1 | cut -f 1 -d " "`
ppp3_gw=`ip route | grep ppp3 | head -1 | cut -f 1 -d " "`
ppp4_gw=`ip route | grep ppp4 | head -1 | cut -f 1 -d " "`

# Flush and rebuild rule for table 250 ( load balance )
ip route flush cache
ip route flush table 250 all > /dev/null
ip route replace table 250 default scope global equalize nexthop via $ppp1_gw dev ppp1 weight 1

# ----- Squid
if [ -f /var/run/squid.pid ]; then
iptables -t nat -D PREROUTING -i $E -p tcp -s $Lan -d $Any -m multiport --destination-port 80,5977 -j REDIRECT --to-port 3128 > /dev/null
iptables -t nat -A PREROUTING -i $E -p tcp -s $Lan -d $Any -m multiport --destination-port 80,5977 -j REDIRECT --to-port 3128
# CSO
iptables -t nat -D PREROUTING -i $E -p tcp -d 202.43.33.122 --dport 9898 -j REDIRECT --to-port 3128 > /dev/null
iptables -t nat -A PREROUTING -i $E -p tcp -d 202.43.33.122 --dport 9898 -j REDIRECT --to-port 3128
iptables -t nat -D OUTPUT -o $E -p tcp -d 202.43.33.122 --dport 80 -j DNAT --to 202.43.33.122:9898 > /dev/null
iptables -t nat -A OUTPUT -o $E -p tcp -d 202.43.33.122 --dport 80 -j DNAT --to 202.43.33.122:9898
fi

# ----- Frox
if [ -f /var/run/frox.pid ]; then
iptables -t nat -D PREROUTING -i $E -p tcp -s $Lan -d $Any -m multiport --destination-port 21,8021 -j REDIRECT --to-port 2121 > /dev/null
iptables -t nat -A PREROUTING -i $E -p tcp -s $Lan -d $Any -m multiport --destination-port 21,8021 -j REDIRECT --to-port 2121
fi

# ----- Msn Yahoo Icq Irc
# if [ -f /var/run/imspector.pid ]; then
# iptables -t nat -D PREROUTING -i $E -p tcp -m multiport --destination-port 1863,6667,5050,5190 -j REDIRECT --to-port 16667 > /dev/null
# iptables -t nat -A PREROUTING -i $E -p tcp -m multiport --destination-port 1863,6667,5050,5190 -j REDIRECT --to-port 16667
# fi

# P2P Block
# iptables -t filter -D FORWARD -i $E -s $Lan -d $Any -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP > /dev/null
# iptables -t filter -D INPUT -i $E -s $Lan -d $Any -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP > /dev/null
# iptables -t filter -D OUTPUT -o $E -s $Lan -d $Any -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP > /dev/null
# iptables -t filter -A FORWARD -i $E -s $Lan -d $Any -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP
# iptables -t filter -A INPUT -i $E -s $Lan -d $Any -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP
# iptables -t filter -A OUTPUT -o $E -s $Lan -d $Any -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP

# Fifa 2
iptables -t filter -D FORWARD -i $E -p all -s 61.91.68.0/24 -j ACCEPT > /dev/null
iptables -t filter -A FORWARD -i $E -p all -s 61.91.68.0/24 -j ACCEPT
iptables -t filter -D FORWARD -i $E -p all -d 61.91.68.0/24 -j ACCEPT > /dev/null
iptables -t filter -A FORWARD -i $E -p all -d 61.91.68.0/24 -j ACCEPT

#### Mark Games To Gameline ####
ipls=(

61.19.241.0/24
61.90.227.0/24
203.144.130.0/24
203.144.132.0/24
203.144.137.0/24
203.144.166.0/24
203.144.179.0/24
203.144.244.0/24
58.97.46.0/24
58.147.89.0/24
61.47.6.0/24
61.47.57.0/24
61.90.199.0/24
61.90.252.0/24
61.90.203.0/24
61.91.72.0/24
61.91.68.0/24
61.91.69.0/24
195.222.17.0/24
202.43.34.0/24
158.39.49.0/24
159.153.186.0/24
202.43.33.0/24
202.43.35.0/24
203.121.165.0/24
61.91.123.0/24
58.64.24.0/24
61.47.6.0/24
61.47.39.0/24
61.90.198.0/24
61.91.127.0/24
202.43.35.0/24
203.113.10.0/24
210.1.60.67
210.86.180.0/24

)
for ipl in ${ipls[@]}
do
iptables -t mangle -A PREROUTING -i $E -s $Lan -p all -d $ipl -j $Games
done

# Tread some port To Net Line
portnetls=(
20:25
80
110
443
554
1863
1935
2009
3389
5050
5190
5977
6667
8021
8080
9099
9770
9898
)
for portnet in ${portnetls[@]}
do
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d $Any --destination-port $portnet -j $Net
done

# P2P
iptables -t mangle -A PREROUTING -i $E -s $Lan -p all -d $Any -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j $Net

# Dns ( Mark Domain name server to Net Line )
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d $Any --destination-port 53 -j $Net
iptables -t mangle -A PREROUTING -i $E -s $Lan -p udp -d $Any --destination-port 53 -j $Net

# Cre Dot-I ( All With GG )
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d $Any -m multiport --source-port 1513:1514,7001:7255,8687:8688 -j $Games

# Join Dot-I ( All With GG )
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d $Any -m multiport --destination-port 1513:1514,6001:6255,7000:7255,8687:8688 -j $Games

# Battle Filed 2 ( All Server )
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d $Any -m multiport --destination-port 299,4711,27901,28910,29900 -j $Games
iptables -t mangle -A PREROUTING -i $E -s $Lan -p udp -d $Any -m multiport --destination-port 1500:4999,16567,27900,29900 -j $Games

# IPBONUS ( Mark IPBONUS to Games Line )
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d secure1.asiasoft.co.th --destination-port 443 -j $Games
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d secure2.asiasoft.co.th --destination-port 443 -j $Games

# Fifa 2
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d 61.91.68.0/24 -m multiport --destination-port 443,1863,6215,6216,6316 -j $Games
iptables -t mangle -A PREROUTING -i $E -s $Lan -p udp -d 61.91.68.0/24 -m multiport --destination-port 32768:65535 -j $Games

# Ini3 IPBonus
iptables -t mangle -A PREROUTING -i $E -s $Lan -p tcp -d netcafe.ini3.co.th --destination-port 80 -j $Games

ก่อนอื่นต้อขอกล่าว สวัสดีครับ พ่อ แม่ พี่ น้อง ทุกๆคน

V นี้เป็น basic แต่ไม่ basic เอ๊ะ ยังไง

ก่อนอื่น ต้องเปลี่ยน ค่า eth ของ lan card ของท่านก่อน โดยปกติแล้วจะอยู่ที่ eth1

ขอเชิญท่านที่สนใจ นำไปทดลอง ทดสอบใช้งาน ติดปัญหาอะไร สอบถามได้ที่นี่เลยครับผม

ปล. ร่วมกัน ต่อยอดนะคร้าบ

ปล. ขอขอบคุณ คุณ skung22 สำหรับสคริป หดให้สั้นลง เร้าใจมากขึ้น

ใคร copy ไปกรุณาให้เครดิตด้วยนะจ๊ะ

 ๛scCredits : MR.X

jededjed

  • บุคคลทั่วไป
Re: รบกวนถามเรื่อง script 3wan ตอน "เมื่อเน็ตเน่าไป1สาย"
« ตอบกลับ #3 เมื่อ: พฤษภาคม 05, 2009, 04:38:42 pm »
ขอบคุณนะคร้าบบบบบบบ