Giter Club home page Giter Club logo

Comments (20)

zfl9 avatar zfl9 commented on August 24, 2024
ip route flush table 100
ip route add local 0/0 dev lo table 100
ip rule add fwmark 0x01/0x01 table 100
iptables -t mangle -A PREROUTING -p tcp -j TPROXY --tproxy-mark 0x01/0x01 --on-port $TCP_PORT

from ss-tproxy.

5high avatar 5high commented on August 24, 2024

现在我是这样送流量给dokodemon-door的,UDP部分应该已经是TPROXY了,TCP部分用您 的代码无效,能否给修改一个完整的TPROXY版本
TCP:
iptables -t nat -N V2RAY
iptables -t nat -A V2RAY -d 192.168.1.0/24 -j RETURN
iptables -t nat -A V2RAY -p tcp -j REDIRECT --to-ports 12345
iptables -t nat -A PREROUTING -p tcp -j V2RAY

UDP:
ip rule add fwmark 0x01/0x01 table 100
ip route add local 0.0.0.0/0 dev lo table 100
iptables -t mangle -N V2RAY
iptables -t mangle -A V2RAY -p udp -j TPROXY --on-port 12345 --tproxy-mark 0x01/0x01
iptables -t mangle -A PREROUTING -j V2RAY
iptables -t mangle -I V2RAY -d 192.168.1.0/24 -j RETURN

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

据我所知,目前 ss-libevssr-libevv2ray 实现 TCP 透明代理均为 iptables-REDIRECT(DNAT) 方式,只有 UDP 是通过 iptables-TPROXY 方式实现的。所以目前,ss、ssr、v2ray 都只能是上面你给出的这种组合方式。

from ss-tproxy.

5high avatar 5high commented on August 24, 2024

sockopt (V2Ray 3.40+): 连接选项,可用的配置项有:
mark: 一个整数。当其值非零时,在传出连接上标记 SO_MARK。
仅适用于 Linux 系统。
需要 CAP_NET_ADMIN 权限。
tcpFastOpen: 是否启用 TCP Fast Open。当其值为true时,强制开启TFO;当其它为false时,强制关闭TFO;当此项不存在时,使用系统默认设置。
仅在以下版本(或更新版本)的操作系统中可用:
Windows 10 (1604)
Mac OS 10.11 / iOS 9
Linux 3.16: 系统已默认开启,无需要配置。
可用于传入传出连接。
tproxy (V2Ray 3.44+): 是否开启透明代理 (仅适用于 Linux)。可选的值有:
"redirect": 使用 Redirect 模式的透明代理。仅支持 TCP/IPv4 和 UDP 连接。
"tproxy": 使用 TProxy 模式的透明代理。支持 TCP 和 UDP 连接。
"off": 关闭透明代理。****

https://www.v2ray.com/chapter_02/05_transport.html

最新版本已经支持tcp也走tproxy了

from ss-tproxy.

5high avatar 5high commented on August 24, 2024

好像是V2ray会自动给数据包打标记,但是我对tproxy不熟悉,所以过来请教。

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

好吧,恕我无知。按道理来说 TCP 和 UDP 的 TPROXY 代理都是差不多的,只不过将 udp 改为 tcp 而已。如果行不通的话我也无能为力了。

from ss-tproxy.

5high avatar 5high commented on August 24, 2024

我测试成功了,完整配置如下,听说TPROXY可以隐藏中间代理服务器,但是为何我访问ip111.cn还是有显示服务器ip地址呢?

"inboundDetour": [{
"domainOverride": ["tls", "http"],
"port": 12345,
"protocol": "dokodemo-door",
"settings": {
"followRedirect": true
},
"streamSettings": {
"sockopt": {
"mark": 100,
"tproxy": "tproxy"
}
}
}],

ip rule add fwmark 0x01/0x01 table 100
ip route add local 0.0.0.0/0 dev lo table 100
iptables -t mangle -N V2RAY
iptables -t mangle -A V2RAY -p udp -j TPROXY --on-port 12345 --tproxy-mark 0x01/0x01
iptables -t mangle -A V2RAY -p tcp -j TPROXY --on-port 12345 --tproxy-mark 0x01/0x01
iptables -t mangle -A PREROUTING -j V2RAY
iptables -t mangle -I V2RAY -d 192.168.1.0/24 -j RETURN

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

所以,你给出的规则是可行还是不可行?

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

它那个 mark 100 是什么,是指 tproxy-mark 要为 100 吗?

from ss-tproxy.

5high avatar 5high commented on August 24, 2024

按照我的配置修改v2ray dokodemo-door可以成功透明代理,不过访问ip111.cn还是显示服务器地址,并未真正透明。

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

我想你是理解错了,透明代理和你显示的 IP 不是一回事。显示什么 IP 要看你使用什么分流模式,gfwlist 还是 chnroute 还是全局。

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

你现在可以代理的话,那么我上面给出的规则应该是可行的,还是那句话,只是从 -p udp 改为 -p tcp 而已。

from ss-tproxy.

5high avatar 5high commented on August 24, 2024

https://blog.csdn.net/u011431128/article/details/77481678
参考这篇文章应该能有启发,但是我不太懂tproxy

from ss-tproxy.

5high avatar 5high commented on August 24, 2024

按文章前面提到如下:
客户端向真实服务器发起连接,代理机冒充服务器与客户端建立连接,并以客户端ip与真实服务器建立连接进行代理转发。因此对于客户端与服务器来说,代理机都是透明的。

那么被访问端不应知道V2ray服务器地址,我这样理解对吗?

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

透明代理:指客户端无需任何配置即可按照预先设好的代理规则出去,客户端无法知道它现在究竟是走了代理还是没走代理。这才是 透明 的意思。总之,客户端只需要像没有代理那样使用就行。

而你之所以访问 ip111.cn 显示的 vps 的 IP,是因为你的流量是走 v2ray 代理出去的(由 vps 发送出去的),所以显示的是 vps 的 IP。不存在所谓的透明代理就不会知道你的 vps 服务器地址,事实恰恰相反,目的网站只能知道是 vps 访问的它,他不可能知道原始客户主机是哪个。

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

此处的透明只是针对客户端来说的,你搞混了。

from ss-tproxy.

voioc avatar voioc commented on August 24, 2024

@5high 可否给一个完整版的透明代理的config.json的配置文件,我的弄了好久了还是不能成功

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

@sunnysnow 请查看:readme.md,已更新相关说明。

from ss-tproxy.

caoli5288 avatar caoli5288 commented on August 24, 2024

@5high 按你的配置成功了,但是上网速度比socks模式慢好多,我怀疑dns的转发哪里有问题

from ss-tproxy.

zfl9 avatar zfl9 commented on August 24, 2024

读者注意,ss-tproxy早已支持纯tproxy代理方式,请不要被上面的讨论给误导,无论是redirect模式还是纯tproxy模式都不存在所谓性能或效率问题,规则都是经过精心设置的。

from ss-tproxy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.