v2fly / discussion

5 stars 0 forks source link

旁路由网关模式如何设置出口 #67

Closed ghgds closed 3 years ago

ghgds commented 3 years ago

pic2

如图所示,局域网PC1 上VMware装了openwrt路由,PC2 使用网关模式使用此路由。 外网电脑PC3 使用V2ray Vmess 连接路由的 DDNS,通过路由的端口转发到PC2。 PC2 的V2ray配置文件,outbound 直接写freedom协议,可以看到来自PC3的接收和转发,但是PC3 无法上网。 请教各位此场景下应该如何配置?感谢

kslr commented 3 years ago

PC3 可以在路由上直接转发到 core 端口

ghgds commented 3 years ago

PC3 可以在路由上直接转发到 core 端口

感谢大佬回复,但是没太明白,能再详细说一下吗

kslr commented 3 years ago

你在路由上设置将来自wan ip, port 转发到 server ip, port 然后pc3正常连接就可以了

ghgds commented 3 years ago

请问pc3 上的v2ray 如何设置? 不走vmess协议,直接转发到路由器吗?

kslr commented 3 years ago

路由转发对你的客户端是匿名的,你只需要修改远程地址为转发地址

ghgds commented 3 years ago

大佬,我感觉我现在的配置就是您说的呀,您帮我看看 PC3 的关键配置:

` {

"inbounds": [{ "port": 1086, "listen": "127.0.0.1", "protocol": "socks", "settings": { "auth": "noauth", "udp": true, "ip": "127.0.0.1" }, "tag": "dell" }],

"outbounds": [ { "protocol": "vmess", "tag": "dellout", "settings": { "vnext": [ { "address": "xxx.domain.com", "port": 7101, "users": [ { "id": "uuiduuiduuid", "alterId": 88 } ] } ]} } ],

"routing": { "domainStrategy": "IPOnDemand", "rules":[ { "type": "field", "inboundTag": "dell", "outboundTag": "dellout" } ] } } `

PC2的关键配置: `{

"inbounds": [{ "port": 7101, "tag": "socks7101", "protocol": "vmess", "settings": { "clients": [ { "id": "uuiduuiduuid", "alterId": 88 } ] } }],

"outbounds": [ { "protocol": "freedom", "settings": {}, "tag": "direct" } ],

"routing": { "domainStrategy": "IPOnDemand", "rules":[ { "type": "field", "inboundTag": "socks7101", "outboundTag": "direct" } ] } } `

路由器的端口转发设置: 端口转发

kslr commented 3 years ago

你的目标是什么,连回到家里的局域网吗?

ghgds commented 3 years ago

目标是连回家里的网络,通过旁路由openwrt科学上网

kslr commented 3 years ago

首先,在路由防火墙设置允许你的pc3连接

iptables -t nat -A PREROUTING -p tcp --dport 17474 -j DNAT --to xxxx:17474

把这个写到你的路由防火墙里,来自外网17474端口的流量就会被转发到xxx(你的服务器地址)和端口上。

ghgds commented 3 years ago

主路由是华硕,目前的端口转发状态下,我在PC3访问,在PC2的v2ray客户端可以看到来自PC3的流量,但是PC3接收不到回复。 下面是PC2的V2ray 接收到的PC3的请求 log: 2020/11/23 00:09:03 xxx.xxx.xxx.xxx:5682 accepted tcp:alive.github.com:443 [direct] 2020/11/23 00:09:08 xxx.xxx.xxx.xxx:5687 accepted tcp:alive.github.com:443 [direct] 2020/11/23 00:09:15 xxx.xxx.xxx.xxx:5689 accepted tcp:alive.github.com:443 [direct]

ghgds commented 3 years ago

下面是在PC2和PC3的Windows防火墙都关闭的情况下,PC2的V2ray 开debug模式的记录,其中xxx.xxx.xxx.xxx 是PC3的外网IP地址。

2020/11/23 16:19:00 [Debug] v2ray.com/core/app/log: Logger started 2020/11/23 16:19:00 [Debug] v2ray.com/core/app/proxyman/inbound: creating stream worker on 0.0.0.0:7101 2020/11/23 16:19:00 [Info] v2ray.com/core/transport/internet/tcp: listening TCP on 0.0.0.0:7101 2020/11/23 16:19:00 [Warning] v2ray.com/core: V2Ray 4.23.4 started 2020/11/23 16:23:38 [Info] [3042361717] v2ray.com/core/proxy/vmess/inbound: received request for tcp:cn.bing.com:443 2020/11/23 16:23:38 [Info] [3042361717] v2ray.com/core/app/dispatcher: taking detour [direct] for [tcp:cn.bing.com:443] 2020/11/23 16:23:38 [Info] [3042361717] v2ray.com/core/proxy/freedom: opening connection to tcp:cn.bing.com:443 2020/11/23 16:23:38 [Info] [3042361717] v2ray.com/core/transport/internet/tcp: dialing TCP to tcp:cn.bing.com:443 2020/11/23 16:23:38 [Info] [3042361717] v2ray.com/core/app/proxyman/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: connection ends > v2ray.com/core/proxy/vmess/inbound: failed to transfer request > read tcp 192.168.50.8:7101->xxx.xxx.xxx.xxx:2598: wsarecv: An existing connection was forcibly closed by the remote host. 2020/11/23 16:23:38 [Info] [3042361717] v2ray.com/core/app/proxyman/outbound: failed to process outbound traffic > v2ray.com/core/proxy/freedom: connection ends > v2ray.com/core/proxy/freedom: failed to process request > io: read/write on closed pipe

github-actions[bot] commented 3 years ago

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days