wangyu- / udp2raw

A Tunnel which Turns UDP Traffic into Encrypted UDP/FakeTCP/ICMP Traffic by using Raw Socket,helps you Bypass UDP FireWalls(or Unstable UDP Environment)
MIT License
6.96k stars 1.15k forks source link

FakeTCP 能否支持 iptables 操作呢? #136

Open qiang-yu opened 6 years ago

qiang-yu commented 6 years ago

毕竟是 fake 的 tcp,能否支持 iptables 对 tcp 的规则呢?

我现在 client 会用 iptables 把流量随机分散到 5000 个端口 (防止单个端口流量过大被QoS或者检测)

iptables -t nat -A OUTPUT -d 145.95.122.56 -p tcp --dport 443 -j DNAT --to-destination 145.95.122.56:5000-10000 --random

在 server 端把端口 5000--10000 的流量定向到真实的监听端口

-A PREROUTING -p tcp -m multiport --dport 5000:10000 -j REDIRECT --to-ports 1080

现在这个 udp2raw-tunnel 的 fake tcp 能支持 iptables 的这个规则吗?

wangyu- commented 6 years ago

不行,raw socket会绕过本机的iptables。

你可以考虑开多对udp2raw client/server ,用类似的方法把流量随机分散到多个udp2raw隧道上。

qiang-yu commented 6 years ago

如果 raw socket 不能应用 iptables ,那也就是说无法做 中继 了吧,就是一台国内跳板机器用 iptables 转发到国外的vps上,这种无法实现吧,只能直连国外那个 vps 了

wangyu- commented 6 years ago

如果 raw socket 不能应用 iptables ,那也就是说无法做 中继 了吧,就是一台国内跳板机器用 iptables 转发到国外的vps上,这种无法实现吧,只能直连国外那个 vps 了

完全没问题,解决方法很多。

  1. 直接在跳板机上用iptables转发。 raw socket只会绕过本机的iptables,对跳板机来说看到的只是普通的tcp包。

  2. 在udp层面转发。根据哪一环节有QOS,可以有不同的连法: A client------直连------->跳板机-------->udp2raw隧道---------->vps B client------udp2raw隧道------->跳板机-------->直连---------->vps C client------udp2raw隧道------->跳板机-------->udp2raw隧道2-------->vps

flipphos commented 6 years ago

可以考虑加一层ss,转发ss即可。

在 2018年1月30日,11:08,QiangYu notifications@github.com 写道:

如果 raw socket 不能应用 iptables ,那也就是说无法做 中继 了吧,就是一台国内跳板机器用 iptables 转发到国外的vps上,这种无法实现吧,只能直连国外那个 vps 了

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/wangyu-/udp2raw-tunnel/issues/136#issuecomment-361462747, or mute the thread https://github.com/notifications/unsubscribe-auth/AK1u0n3jtR_vAy1MdEHwwE2LibIVLo15ks5tPoehgaJpZM4Rwjpf.

ghost commented 5 years ago

如果 raw socket 不能应用 iptables ,那也就是说无法做 中继 了吧,就是一台国内跳板机器用 iptables 转发到国外的vps上,这种无法实现吧,只能直连国外那个 vps 了

完全没问题,解决方法很多。

  1. 直接在跳板机上用iptables转发。 raw socket只会绕过本机的iptables,对跳板机来说看到的只是普通的tcp包。 ...

尝试了一下,传统iptables在nat链内做tcp转发无法连接udp隧道,但是在prerouting表里能看见尝试连接的微小的流量,postrouting里看不到。如果是udp,则两者都没有流量出现。