openwrt shadowsocks 配置自动翻墙获取 ip 地址段的问题?
使用的是路由器
按 openwrt + shadowsocks 这个教程配置自动翻墙,iptables用的网上脚本
脚本是这样的
#!/bin/sh
#create a new chain named SHADOWSOCKS
iptables -t nat -N SHADOWSOCKS
#Redirect what you want
#Google
iptables -t nat -A SHADOWSOCKS -p tcp -d 74.125.0.0/16 -j REDIRECT --to-ports 1080
iptables -t nat -A SHADOWSOCKS -p tcp -d 173.194.0.0/16 -j REDIRECT --to-ports 1080
#Youtube
iptables -t nat -A SHADOWSOCKS -p tcp -d 208.117.224.0/19 -j REDIRECT --to-ports 1080
iptables -t nat -A SHADOWSOCKS -p tcp -d 209.85.128.0/17 -j REDIRECT --to-ports 1080
#Twitter
#iptables -t nat -A SHADOWSOCKS -p tcp -d 199.59.148.0/22 -j REDIRECT --to-ports 1080
#iptables -t nat -A SHADOWSOCKS -p tcp -d 210.0.128.0/17 -j REDIRECT --to-ports 1080
#iptables -t nat -A SHADOWSOCKS -p tcp -d 210.0.192.0/18 -j REDIRECT --to-ports 1080
# facebook
iptables -t nat -A SHADOWSOCKS -p tcp -d 173.252.64.0/18 -j REDIRECT --to-ports 1080
#Shadowsocks.org
iptables -t nat -A SHADOWSOCKS -p tcp -d 199.27.76.133/32 -j REDIRECT --to-ports 1080
#Anything else should be ignore
iptables -t nat -A SHADOWSOCKS -p tcp -j RETURN
# Apply the rules
iptables -t nat -A PREROUTING -p tcp -j SHADOWSOCKS
这个脚本中只有google,和 Shadowsocks.org是可以的,我猜其它ip地址失效了,
按照这个帖子 https://www.v2ex.com/t/126091 中的方法,
我是从国外的vps 用nsloop查出ip,再到 http://wq.apnic.net/apnic-bin/whois.pl 查ip地址
把ip加到iptables里,也不起作用。
是我获取ip地址段的方法不对吗?有没有其它的方法?
补充
现在就是用的chinadns, https://github.com/clowwindy/ChinaDNS-C
直接
dig @192.168.1.1 www.youtube.com
是这样的
root@OpenWrt:/usr/bin# dig @192.168.1.1 www.youtube.com
; <<>> DiG 9.9.4 <<>> @192.168.1.1 www.youtube.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48082
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1280
;; QUESTION SECTION:
;www.youtube.com. IN A
;; ANSWER SECTION:
www.youtube.com. 13875 IN A 37.61.54.158
;; Query time: 9 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Tue Nov 25 01:11:21 UTC 2014
;; MSG SIZE rcvd: 60
看到了这个
https://github.com/clowwindy/ChinaDNS-C/issues/24
好像解析的还不对?
Answers
首先要确保你的路由器能正常解析 google、youtube、twitter 的域名,并且解析得到的 IP 就是你往路由表里添加的 IP
这方面建议使用
https://github.com/clowwindy/ChinaDNS
这个比较可靠、省心,不建议使用楼主第一个链接里提到的 pdnsd
域名解析问题解决后,直接在路由器上 ping youtube.com 然后把得到的第一个 IP 加到路由表里,就能访问 youtube.com 了。