Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 #55

Closed
EkkoG opened this issue Jul 28, 2015 · 40 comments

Comments

@EkkoG
Copy link

EkkoG commented Jul 28, 2015

代理所有非中国IP的模式下,有些IP想排除,但是似乎是没有选项的。。希望可以考虑下我的建议,感谢作者的付出:)

@EkkoG EkkoG changed the title 建议shadowsocks增加使用配置文件选项,以及非中国IP的代理模式中增加哪些IP不通过代理选项。 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 Aug 25, 2015
@yasteora
Copy link

有个gfwlist 里面 可以自己 配置。不过我没用通过dnsmaqs 的ipset功能分组 ip 后通过ip 规则打标记 到table 在通过防火墙规则 来透明代理的方式,我直接全局代理。
ipset list 那里 似乎就是gfwlist之类的,我已经把那些个插件卸载了 帮不了你了,你自己看看 github有一本 叫做freerouter 的PDF 你可以看看

@EkkoG
Copy link
Author

EkkoG commented Aug 26, 2015

@yasteora 找到方法了,我用的是分国内外IP的模式,不是GFWList模式,只有几个IP不想走代理,所以把那几个IP加到ipset的国内列表里就行了。就是Luci界面没有相关设置,自己手动添加了ipset的标记,不过也不麻烦。已经解决了,谢谢。

@rssnsj rssnsj closed this as completed Sep 14, 2015
@Leeiio
Copy link

Leeiio commented Dec 7, 2015

@cielpy 请问怎么修改?应该改哪个文件

@EkkoG
Copy link
Author

EkkoG commented Dec 7, 2015

/etc/ipset/local 里加上你不想走代理的ip就行了。

@Leeiio
Copy link

Leeiio commented Dec 7, 2015

@cielpy 看到了,多谢,不过我选国内外ip模式twitter、facebook这些还是会打不开..你有遇到这个问题么

@EkkoG
Copy link
Author

EkkoG commented Dec 7, 2015

如果你没改什么的话,设置好ss账号后就应该没问题了。DNS问题也是newwork-feed里解决了,看下你账号有没有填错。

@Leeiio
Copy link

Leeiio commented Dec 7, 2015

@cielpy 使用shadowsocks的简单模式设置ss是可以上网的,但是使用「面向高级用户」里的「所有非中国的IP」就会有这样的问题,可能是我杭州这的DNS污染太严重了...

@EkkoG
Copy link
Author

EkkoG commented Dec 7, 2015

Twitter等网站的DNS是不走本地的DNS解析的,用的是pdnsd转发到8.8.8.8,你可以ssh登录路由器,然后去年dig @127.0.0.1 -p 7453 twitter.com看返回什么结果

@Leeiio
Copy link

Leeiio commented Dec 7, 2015

刚才切回gfwlist模式可以返回结果,然后切回国内ip模式,就变成
root@OpenWrt:~# dig @127.0.0.1 -p 7453 twitter.com

; <<>> DiG 9.9.4 <<>> @127.0.0.1 -p 7453 twitter.com
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached

@Leeiio
Copy link

Leeiio commented Dec 7, 2015

以下是gfwlist模式的返回结果

dig @127.0.0.1 -p 7453 twitter.com

; <<>> DiG 9.9.4 <<>> @127.0.0.1 -p 7453 twitter.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 28053
;; flags: qr rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1024
;; QUESTION SECTION:
;twitter.com. IN A

;; ANSWER SECTION:
twitter.com. 900 IN A 104.244.42.193
twitter.com. 900 IN A 104.244.42.1

;; Query time: 164 msec
;; SERVER: 127.0.0.1#7453(127.0.0.1)
;; WHEN: Mon Dec 07 15:43:29 GMT 2015
;; MSG SIZE rcvd: 72

@EkkoG
Copy link
Author

EkkoG commented Dec 7, 2015

国内外模式域名不能解析,先用gfw模式吧,明天我看看国内外分流模式的dns怎么搞的。你可以先看看国内外ip分流模式下pdnsd有没有运行,试着把8.8.8.8加到ipset的过滤列表,看看会不会能解析。

Sent using CloudMagic [https://cloudmagic.com/k/d/mailapp?ct=pi&cv=7.1.27&pv=8.4]
On 周一, 12月 7, 2015 at 23:42, 瓜牛 notifications@github.com wrote:
刚才切回gfwlist模式可以返回结果,然后切回国内ip模式,就变成
root@OpenWrt:~# dig @127.0.0.1 -p 7453 twitter.com

; <<>> DiG 9.9.4 <<>> @127.0.0.1 -p 7453 twitter.com
; (1 server found)
;; global options: +cmd
;; connection timed out; no servers could be reached


Reply to this email directly or view it on GitHub
[https://github.com//issues/55#issuecomment-162561958] .[https://github.com/notifications/beacon/AC_jvRdMFnOpMJHJ9UXCnThIdlnvDv-qks5pNaBngaJpZM4Fg55Y.gif]

@Leeiio
Copy link

Leeiio commented Dec 7, 2015

pdnsd还真没接触过,以前用的是openwrt官网下的版本,然后自己装的shadowsocks和chinadns来翻墙的,但是最近十分不稳定,经常无法正常翻墙才换了这个固件...

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

ps看一下有没有pdnsd进城就行了

Sent using CloudMagic [https://cloudmagic.com/k/d/mailapp?ct=pi&cv=7.1.27&pv=8.4]
On 周二, 12月 8, 2015 at 00:37, 瓜牛 notifications@github.com wrote:

pdnsd还真没接触过,以前用的是openwrt官网下的版本,然后自己装的shadowsocks和chinadns来翻墙的,但是最近十分不稳定,经常无法正常翻墙才换了这个固件...


Reply to this email directly or view it on GitHub
[https://github.com//issues/55#issuecomment-162583205] .[https://github.com/notifications/beacon/AC_jvTvawgk00uMH9hjPufBjDjg6mXiIks5pNa05gaJpZM4Fg55Y.gif]

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

果然,切到国内ip模式,pdnsd进城就没有了...

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

安全DNS打开了吗?

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 上午9:51
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

果然,切到国内ip模式,pdnsd进城就没有了...


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

@cielpy 安全DNS填写的是8.8.8.8,打开了没怎么看?

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

看代码是如果开了安全DNS并且DNS uses TCP勾上就会启动pdnsd的,并生成一个dnsmasq的域名解析列表,你看下有一个tcp dns之类的有没有勾上。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 上午10:29
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

@cielpy 安全DNS填写的是8.8.8.8,打开了没怎么看?


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

@cielpy 好吧,原来必须要勾选「DNS使用TCP」才可以正常启动pdnsd的...这下似乎好了

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

嗯,代码逻辑是这样的,那个选项不是默认勾上的吗?

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 上午11:13
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

@cielpy 好吧,原来必须要勾选「DNS使用TCP」才可以正常启动pdnsd的...这下似乎好了


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

@cielpy 并没有默认勾上,我刷的是最新的release固件,不是自己打补丁的
多谢了,最后问一下,这个固件里的ipset china文件里的ip不会自动更新的是吧?

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

不会。用这个命令更新吧。
wget -O- 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | awk -F| '/CN|ipv4/ { printf("%s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/chinadns_chnroute.txt

最后那里是这路径,你改成你要写入的文件的路径就好,或者下载完了cp过去。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 上午11:33
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

@cielpy 并没有默认勾上,我刷的是最新的release固件,不是自己打补丁的
多谢了,最后问一下,这个固件里的ipset china文件里的ip不会自动更新的是吧?


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

不是应该是

curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F\| '{ printf("add china %s/%d\n", $4, 32-log($5)/log(2)) }' > ~/Desktop/chinadns_chnroute.txt

这样么,我看china文件里的每行ip前缀是add china,add china 1.0.1.0/24,而且第一行是写着create china hash:net family inet hashsize 1024 maxelem 65536,没有#注释,不知道是不是也需要的

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

0.0,是,用你那个命令就行了。不用每天 更新,这个列表很少变化,隔段时间更新一下就行了。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 上午11:40
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

不是应该是
curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F| '{ printf("add china %s/%d\n", $4, 32-log($5)/log(2)) }' > ~/Desktop/chinadns_chnroute.txt
这样么,我看china文件里的每行ip前缀是add china,add china 1.0.1.0/24,而且第一行是写着create china hash:net family inet hashsize 1024 maxelem 65536,没有#注释,不知道是不是也需要的


Reply to this email directly or view it on GitHub.

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

第一行那个也是需要的,更新过IP列表后要加上。创建的ipset标记。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 上午11:40
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

不是应该是
curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F| '{ printf("add china %s/%d\n", $4, 32-log($5)/log(2)) }' > ~/Desktop/chinadns_chnroute.txt
这样么,我看china文件里的每行ip前缀是add china,add china 1.0.1.0/24,而且第一行是写着create china hash:net family inet hashsize 1024 maxelem 65536,没有#注释,不知道是不是也需要的


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

第一行内容不知道要怎么自动添加到文件第一行...

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

手动吧。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 下午2:07
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

第一行内容不知道要怎么自动添加到文件第一行...


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

研究了下awk命令发现这样写就可以了

curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F\| 'BEGIN{printf "create china hash:net family inet hashsize 1024 maxelem 65536\n"}{printf("add china %s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/ipset/china

写入计划任务

# 自动更新
# 每天凌晨4点更新文件,注意文件路径
* 4 * * * curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F\| 'BEGIN{printf "create china hash:net family inet hashsize 1024 maxelem 65536\n"}{printf("add china %s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/ipset/china

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

BEGIN是执行一次吗。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 下午2:53
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

研究了下awk命令发现这样写就可以了
curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F| 'BEGIN{printf "create china hash:net family inet hashsize 1024 maxelem 65536\n"}{printf("add china %s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/ipset/china
写入计划任务

自动更新

每天凌晨4点更新文件,注意文件路径

  • 4 * * * curl 'http://ftp.apnic.net/apnic/stats/apnic/delegated-apnic-latest' | grep ipv4 | grep CN | awk -F| 'BEGIN{printf "create china hash:net family inet hashsize 1024 maxelem 65536\n"}{printf("add china %s/%d\n", $4, 32-log($5)/log(2)) }' > /etc/ipset/china

    Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

是的,亲测可用

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

嗯,我现在不用这个了,我把这些卸载掉了,直接装了官方的shadowsocks,官方的包会处理这些ipset,只需要指定一个IP列表就行了。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 下午2:57
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

是的,亲测可用


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 8, 2015

shadowsocks-libev-spec 还是shadowsocks-libev?
但是还是要额外处理DNS污染问题吧 我之前也是用官方的shadowsocks配合的chinadns

@EkkoG
Copy link
Author

EkkoG commented Dec 8, 2015

shadowsocks-libev-spec只用ss-redir提供透明代理,DNS污染问题参考了这个项目。
这个项目的DNS是用pdnsd通过tcponly的方案请求8.8.8.8,前两天我这用这个方案得不到解析结果,我所以我换成了shadowsocks-libev+dns2socks+pdnsd的方式
跑一个ss-local,提供给dns2socks一个socks5代理,然后把pdnsd的上游设置成了dns2socks提供缓存。用越来还行。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月8日 星期二 下午3:04
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

shadowsocks-libev-spec 还是shadowsocks-libev?
但是还是要额外处理DNS污染问题吧 我之前也是用官方的shadowsocks配合的chinadns


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 9, 2015

你有用15.05么?我发现里面自带去掉了pdnsd,也不知道15.05是否更稳定

@EkkoG
Copy link
Author

EkkoG commented Dec 9, 2015

是的,用的15.05,装的14.07里的那个pdnsd,没发现什么问题。

On Wednesday, December 9, 2015, 瓜牛 notifications@github.com wrote:

你有用15.05么?我发现里面自带去掉了pdnsd,也不知道15.05是否更稳定


Reply to this email directly or view it on GitHub
#55 (comment)
.

@Leeiio
Copy link

Leeiio commented Dec 10, 2015

可否分享下你的pdnsd配置?

@EkkoG
Copy link
Author

EkkoG commented Dec 10, 2015

global {
perm_cache=2048;
cache_dir="/var/pdnsd";
pid_file = /var/run/pdnsd.pid;
run_as="nobody";
server_ip = 127.0.0.1;
server_port = 7453;
status_ctl = on;
query_method = tcp_only;
min_ttl=15m;
max_ttl=1w;
timeout=10;
neg_domain_pol=on;
proc_limit=2;
procq_limit=8;
}
server {
label= "dns";
ip = 8.8.8.8;
timeout=6;
uptest=none;
interval=10m;
purge_cache=off;
}

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月10日 星期四 上午11:18
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

可否分享下你的pdnsd配置?


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 10, 2015

这样配置似乎没法指定国内的ip走国内的dns了是不?
为了防止国内的isp劫持需要用223.5.5.5这样的dns...

@EkkoG
Copy link
Author

EkkoG commented Dec 10, 2015

这个只是提供一个国外的纯净DNS,可以另外配合了dnsmasq让国内常用域名走国内DNS
用这个项目https://github.com/felixonmars/dnsmasq-china-list
把国内的常用域名走自定义的国内DNS,其他的全部走了pdnsd。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月10日 星期四 上午11:58
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

这样配置似乎没法指定国内的ip走国内的dns了是不?
为了防止国内的isp劫持需要用223.5.5.5这样的dns...


Reply to this email directly or view it on GitHub.

@Leeiio
Copy link

Leeiio commented Dec 10, 2015

不喜欢基于域名的方案,维护的列表太多了而且是一个不可控的不断增加
global {
perm_cache=2048;
cache_dir="/var/pdnsd";
pid_file = /var/run/pdnsd.pid;
run_as="nobody";
server_ip = 127.0.0.1;
server_port = 7453;
status_ctl = on;
query_method = tcp_only;
min_ttl=15m;
max_ttl=1w;
timeout=10;
neg_domain_pol=on;
proc_limit=2;
procq_limit=8;
}
server {
label = "china DNS";
ip = 223.5.5.5,
119.29.29.29;
timeout = 3;
}
server {
label= "dns";
ip = 8.8.8.8;
timeout=6;
uptest=none;
interval=10m;
purge_cache=off;
}
不知道是否可以这样

@EkkoG
Copy link
Author

EkkoG commented Dec 10, 2015

没办法,但是现在没有自动化方案,ChinaDNS算比较自动,但是自动化往往更不可控,CDN什么的,自动处理并不简单。

发件人: 瓜牛 notifications@github.com
答复: rssnsj/openwrt-hc5x61 reply@reply.github.com
日期: 2015年12月10日 星期四 下午12:04
至: rssnsj/openwrt-hc5x61 openwrt-hc5x61@noreply.github.com
抄送: ciel beijiu572@gmail.com
主题: Re: [openwrt-hc5x61] 建议在代理所有非中国IP的模式中增加可以忽略哪些ip的设置。 (#55)

不喜欢基于域名的方案,维护的列表太多了而且是一个不可控的不断增加
global {
perm_cache=2048;
cache_dir="/var/pdnsd";
pid_file = /var/run/pdnsd.pid;
run_as="nobody";
server_ip = 127.0.0.1;
server_port = 7453;
status_ctl = on;
query_method = tcp_only;
min_ttl=15m;
max_ttl=1w;
timeout=10;
neg_domain_pol=on;
proc_limit=2;
procq_limit=8;
}
server {
label = "china DNS";
ip = 223.5.5.5,
119.29.29.29;
timeout = 3;
}
server {
label= "dns";
ip = 8.8.8.8;
timeout=6;
uptest=none;
interval=10m;
purge_cache=off;
}
不知道是否可以这样


Reply to this email directly or view it on GitHub.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants