- 論壇徽章:
- 0
|
在學(xué)習(xí)了http://72891.cn/forum/v ... 7601&show_type=
和
http://72891.cn/forum/viewtopic.php?t=563053
感覺很有用處,決定把二貼終和一下, 因?yàn)?第一個(gè)帖子的方法是產(chǎn)生一個(gè)ip/mark的 文本文件,
而第二個(gè)帖子 是用的ip 策略, 這樣可以實(shí)現(xiàn)的就是, 修改2的腳本 讓其在A產(chǎn)生的文件中讀取對(duì)應(yīng)的ip 生成相應(yīng)的策略!
- #For ChinaUnix By Fushuyong,Wuhan
- #modify by laokanlinux@gmail.com
- #!/bin/sh
- IPLIST_FILE=/root/cn.net
- echo "1" >; /proc/sys/net/ipv4/ip_forward
- /sbin/modprobe ip_conntrack_ftp
- /sbin/modprobe ip_nat_ftp
- #NAT the two red interface
- /sbin/iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
- /sbin/iptables -t nat -A POSTROUTING -o eth2 -j MASQUERADE
- #Add a route table name 100 for CNC addresses
- ip route add 0/0 via 219.146.111.129
- ip route add 0/0 via 218.59.127.127 table 100
- #Add the route rules for the CNC addresses
- #ip rule add to 60.0.0.0/13 table 100
- #ip rule add to 222.162.0.0/16 table 100
- #ip rule add to 222.163.0.0/19 table 100
- #WE use the list file's text
- n=1 # RULE number
- for ip in $(awk -F: '{ print $1 }' < "$IPLIST_FILE" )
- # Get input from the CNC ip list file
- do
- echo "RULE #$n = IP/MARK: $ip is inited!"
- ip rule add to $ip table 100
- let "n += 1"
- done
- echo "router table is setted!enjoy it! Let's go!"
復(fù)制代碼
由帖子一得到的網(wǎng)通的ip段大概有300多行!
這樣的代碼比較簡(jiǎn)單了,只要把對(duì)贏的文本放入合適的目錄就可以了! 這樣更新策略時(shí)不用懂 代碼了, 以免出錯(cuò)啊!
不過這個(gè)腳本目前的2個(gè)瑕疵如下:
1) 這個(gè)腳步弄出來的路由器 在客戶段設(shè)置ip的時(shí)候必須 設(shè)置 電信或者網(wǎng)通的DNS 不能用路由器的內(nèi)網(wǎng)地址! 既不轉(zhuǎn)發(fā)DNS的請(qǐng)求. 其實(shí)iptalbes 高手很容易就搞定了, 可惜我不是高手
2) 路由器還有一個(gè)確點(diǎn)就是當(dāng) 網(wǎng)絡(luò)中的某一個(gè)isp 網(wǎng)絡(luò)不通的時(shí)候就 出現(xiàn)網(wǎng)站大面積不能訪問的情況了,! 例如,網(wǎng)通斷線 那么整個(gè)網(wǎng)通額ip段就全都不能訪問了,路由器不會(huì)自動(dòng)轉(zhuǎn)請(qǐng)求到電信的線路! 希望有達(dá)人能更好的解決這個(gè)問題! |
|