FlowerWrong / tun2socks

Redirect tun flow to socks 5 in golang, support tcp and udp.
425 stars 107 forks source link

Little question about configuring #38

Closed Yolkis closed 6 years ago

Yolkis commented 6 years ago

How to make move all traffic through tun2socks without internal-ip?

[route]
v = 8.8.8.8
v = 4.4.4.4
v = 1.1.1.1
v = 1.0.0.1
v = 192.168.0.0/16

[tcp]

[udp]
proxy = B

[proxy "B"]
url = socks5://127.0.0.1:1080
default = yes

[pattern "proxy-website"]
proxy = B
scheme = IP-CIDR
v = 0.0.0.0/0

[pattern "internal-ip"]
scheme = IP-CIDR
v = 10.0.0.0/24
v = 172.16.0.0/20
v = 192.168.0.0/16

[rule]
pattern = proxy-website
pattern = internal-ip
final = B
FlowerWrong commented 6 years ago

Do you mean this?

# define a proxy named "B"
[proxy "B"]
url = socks5://127.0.0.1:1080
# use this proxy as default
default = yes

# set to a proxy for domaines that don't match any pattern
# DEFAULT VALUE: ""
final = B
mittwillson commented 6 years ago

@FlowerWrong 他的意思是除了 internal-ip 规则的IP全部都走代理,按之前issues查的貌似只能依赖dns-mode进行转发流量,对于直连非dns的方式就只能用route来针对性添加?

FlowerWrong commented 6 years ago

是的,也没有其他方式。因为流量到不了tun设备。可以看下udp_relay_via_socks5 mode,就是需要依靠route table工作。scheme = IP-CIDR 是dns解析过后拿结果才去匹配,其他schema也是,我预留了route配置项,这里可以配置少量路由表。

可能是这个没有说明文档,所以配置不那么容易理解,配置我是直接拿kone作者的。其实和surge应该差不多。

mittwillson commented 6 years ago

@FlowerWrong 是否可以参考一下badvpn,通过默认路由并将全部流量导入到虚拟网卡的做法来实现(仅测试过windows)

FlowerWrong commented 6 years ago

@MittWillson 现在支持的。udp_relay_via_socks5 mode,具体脚本可以参考ip2socks darwin_setup_utun.sh

mittwillson commented 6 years ago

@FlowerWrong windows 应该怎么做 我按badvpn的做法导过去以后没有正常将流量代理出去

FlowerWrong commented 6 years ago

😭 这个我没试过,目前没windows电脑。