# ----- 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