zw963 / asuswrt-merlin-transparent-proxy

transparent proxy base on ss, v2ray, xray, ipset, iptables, chinadns on asuswrt merlin or side router.
MIT License
380 stars 80 forks source link

ss+udprelay使用后无效 #63

Closed semisleep closed 5 years ago

semisleep commented 5 years ago

设备是:RT-AC68U Merlin:384.7

按照教程使用ss+udprelay,脚本执行完成功,但始终没法访问google。检查过/opt/etc/shadowsocks.json,更换过几个ss的服务器(这几个mac下面使用ShadowsocksX-NG都能够成功连接),重启服务,也不行。重启路由,也不行。最后试了用deploy_ss_to_vps脚本重新在linode上部署新的ss服务器,ShadowsocksX-NG可以用,但是同个配置,再次部署ss+udprelay还是不行。

请问有没有哪些地方是有可能有问题的? 谢谢!

semisleep commented 5 years ago

附上nslookup的结果

admin@RT-AC68U-5BC8:/tmp/home/root# nslookup google.com
Server:    127.0.0.1
Address 1: 127.0.0.1 localhost.localdomain

Name:      google.com
Address 1: 2404:6800:4005:80f::200e hkg07s29-in-x0e.1e100.net
Address 2: 216.58.221.238 hkg07s21-in-f14.1e100.net
admin@RT-AC68U-5BC8:/tmp/home/root# nslookup google.com 114.114.114.114
Server:    114.114.114.114
Address 1: 114.114.114.114 public1.114dns.com

Name:      google.com
Address 1: 2404:6800:4005:807::200e hkg07s23-in-x0e.1e100.net
Address 2: 172.217.24.206 hkg12s13-in-f14.1e100.net
admin@RT-AC68U-5BC8:/tmp/home/root# nslookup google.com 8.8.8.8
Server:    8.8.8.8
Address 1: 8.8.8.8 google-public-dns-a.google.com

Name:      google.com
Address 1: 2404:6800:4005:80e::200e hkg12s17-in-x0e.1e100.net
Address 2: 172.217.161.142 hkg12s17-in-f14.1e100.net
zw963 commented 5 years ago

贴下面两个命令的结果出来:

admin@RT-AC66U-F2F0:/tmp/home/root# iptables -t nat -nL
admin@RT-AC66U-F2F0:/tmp/home/root# iptables -t mangle -nL
semisleep commented 5 years ago

谢谢!

admin@RT-AC68U-5BC8:/tmp/home/root# iptables -t nat -nL
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
VSERVER    all  --  0.0.0.0/0            192.168.1.2         
SHADOWSOCKS_TCP  tcp  --  0.0.0.0/0            0.0.0.0/0           

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
PUPNP      all  --  0.0.0.0/0            0.0.0.0/0           
MASQUERADE  all  -- !192.168.1.2          0.0.0.0/0           
MASQUERADE  all  --  192.168.0.0/24       192.168.0.0/24      

Chain DNSFILTER (0 references)
target     prot opt source               destination         

Chain LOCALSRV (0 references)
target     prot opt source               destination         

Chain PCREDIRECT (0 references)
target     prot opt source               destination         

Chain PUPNP (1 references)
target     prot opt source               destination         

Chain SHADOWSOCKS_TCP (1 references)
target     prot opt source               destination         
RETURN     tcp  --  0.0.0.0/0            0.0.0.0/0            match-set CHINAIPS dst
RETURN     tcp  --  0.0.0.0/0            0.0.0.0/0            match-set CHINAIP dst
REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            redir ports 1080

Chain VSERVER (1 references)
target     prot opt source               destination         
VUPNP      all  --  0.0.0.0/0            0.0.0.0/0           

Chain VUPNP (1 references)
target     prot opt source               destination       
admin@RT-AC68U-5BC8:/tmp/home/root# iptables -t mangle -nL
Chain PREROUTING (policy ACCEPT)
target     prot opt source               destination         
SHADOWSOCKS_UDP  udp  --  0.0.0.0/0            0.0.0.0/0           

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
MARK       all  --  192.168.0.0/24       192.168.0.0/24       MARK xset 0x1/0x7

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         

Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         

Chain SHADOWSOCKS_MARK (0 references)
target     prot opt source               destination         
MARK       udp  --  0.0.0.0/0            8.8.8.8              udp dpt:53 MARK set 0x1

Chain SHADOWSOCKS_UDP (1 references)
target     prot opt source               destination         
RETURN     udp  --  0.0.0.0/0            0.0.0.0/0            match-set CHINAIPS dst
RETURN     udp  --  0.0.0.0/0            0.0.0.0/0            match-set CHINAIP dst
TPROXY     udp  --  0.0.0.0/0            0.0.0.0/0            udp dpt:53 TPROXY redirect 192.168.0.1:1080 mark 0x1/0x1
zw963 commented 5 years ago

看起来是好的, 不过, 我好久不用这个模式了, 目前, 我也没有支持 udp relay 的路由器去测试. 也许你可以问问 @wangxin6 , 他现在是不是用的这个模式.

zw963 commented 5 years ago

我很奇怪, 为啥你们的 router 的 ip 都是 192.168.0.1, 而不是 192.168.50.1 ?

semisleep commented 5 years ago

我很奇怪, 为啥你们的 router 的 ip 都是 192.168.0.1, 而不是 192.168.50.1 ?

192.168.0.1这个是路由器内网lan的ip没错吧?我这个我自己设置了一下用192.168.0.1,为了和旧的路由保持一致。

gitx6 commented 5 years ago

哈哈。电信猫的缺省地址就是192.168.0.1

udp relay 要成功翻出去的几个要点:

  1. 客户端的版本要和服务器端的版本匹配。曾经发生过客户端重新部署后,因为客户端版本升级,导致翻墙失败
  2. 服务器端要支持UDP relay。自己的VPS可以登上去检查或者安装,买的账号可以问管理员。
  3. 即便如此,仍然有大概率事件无法使用这种方式:因为宽带接入方不提供UDP relay服务。

以上三点造成的结果,有一个现象:部分可以翻出去。比如:gmail可行,Google photo可行;Youtube不行,Google driver不行,Google search不行等。这是由于没有UDP relay做DNS解析,被投毒造成的。

解决方案有三种:

  1. ss+chinadns+ 额外的软件包DNS Forward (hev-dns-forwarder)
  2. ss+chinadns+dnscrypt
  3. ss+dnsmasq+dnscrypt

方案2和方案3 需要额外的dnscrypt服务。自己的VPS可以搭建一个;买的账号可以问管理员;网上也有免费的dnscrypt服务可以用。

回答完毕。

semisleep commented 5 years ago

好的,再次感谢提供这么详尽的解决方案! 我再折腾下,看看是哪里的问题。