Giter VIP home page Giter VIP logo

Comments (6)

RPRX avatar RPRX commented on May 17, 2024

没有特意去掉此功能,如果确实无效,将会修复

from xray-core.

nJhEqnvK avatar nJhEqnvK commented on May 17, 2024

根据 v2ray 官方文档设置透明代理,给每个 Outbound 打标记

"streamSettings": {
"network": "tcp",
"sockopt": {
"mark": 255
},

iptables -t nat -A OUTPUT -p tcp -m mark --mark 0xff -j RETURN

同样的配置,在 v2ray v4.33 版本下正常,通过 iptables 能看到捕获的数据包数量
而在 xray 下看不到捕获的数据数量

v2ray这个给outbound打mark意思是这个包是由V2ray发出,不应该再有iptables重定向至dokodemo door,否则就容易产生回环,所以之前看到了是属于形成了回环?

另外之前官方教程的透明代理好像有问题,你试试用mangle表呢,以下是我自测没问题的:

# 设置策略路由
ip route add local default dev lo table 100
ip rule add fwmark 1 lookup 100

# 代理局域网设备
iptables -t mangle -N V2RAY

iptables -t mangle -A V2RAY -d ${VPS的IP}/32 -j RETURN # 配合V2ray中把outbound的address直接设为IP,防止DNS解析失败出幺蛾子

iptables -t mangle -A V2RAY -d 0.0.0.0/8 -j RETURN
iptables -t mangle -A V2RAY -d 10.0.0.0/8 -j RETURN
iptables -t mangle -A V2RAY -d 127.0.0.0/8 -j RETURN
iptables -t mangle -A V2RAY -d 169.254.0.0/16 -j RETURN
iptables -t mangle -A V2RAY -d 172.16.0.0/12 -j RETURN
iptables -t mangle -A V2RAY -d 224.0.0.0/4 -j RETURN
iptables -t mangle -A V2RAY -d 240.0.0.0/4 -j RETURN
iptables -t mangle -A V2RAY -d 192.168.0.0/16 -p tcp -j RETURN # 直连局域网,避免 V2Ray 无法启动时无法连网关的 SSH,如果你配置的是其他网段(如 10.x.x.x 等),则修改成自己的
iptables -t mangle -A V2RAY -d 192.168.0.0/16 -p udp ! --dport 53 -j RETURN # 直连局域网,53 端口除外(因为要使用 V2Ray 的 

iptables -t mangle -A V2RAY -m mark --mark 0xff -j RETURN 
iptables -t mangle -A V2RAY -p udp -j TPROXY --on-port 12345 --tproxy-mark 1 # 给 UDP 打标记 1,转发至 12345 端口
iptables -t mangle -A V2RAY -p tcp -j TPROXY --on-port 12345 --tproxy-mark 1 # 给 TCP 打标记 1,转发至 12345 端口
iptables -t mangle -A PREROUTING -j V2RAY # 应用规则

from xray-core.

Ciacconas avatar Ciacconas commented on May 17, 2024

我试了mangle表,也没问题

from xray-core.

swordsmile avatar swordsmile commented on May 17, 2024

没有特意去掉此功能,如果确实无效,将会修复

谢谢大神解答,我已经知道是什么原因了。

我是在 openwrt x64 下,使用 nobody 用户运行,会出现权限问题,使用 root 用户运行就可以了。

以下是使用 nobody 用户的提示:
github.com/xtls/xray-core/v1/transport/internet: failed to apply socket options > github.com/xtls/xray-core/v1/transport/i
nternet: failed to set SO_MARK > operation not permitted

from xray-core.

badO1a5A90 avatar badO1a5A90 commented on May 17, 2024

可以在xray.service文件里加上AmbientCapabilities=CAP_NET_ADMIN
解决

from xray-core.

neweva avatar neweva commented on May 17, 2024

没有特意去掉此功能,如果确实无效,将会修复

谢谢大神解答,我已经知道是什么原因了。

我是在 openwrt x64 下,使用 nobody 用户运行,会出现权限问题,使用 root 用户运行就可以了。

以下是使用 nobody 用户的提示:
github.com/xtls/xray-core/v1/transport/internet: failed to apply socket options > github.com/xtls/xray-core/v1/transport/i
nternet: failed to set SO_MARK > operation not permitted

nobody 啓動xray 帶iptables 還需要 PermissionsStartOnly=true

from xray-core.

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.