SagerNet / sing-box

The universal proxy platform
https://sing-box.sagernet.org/
Other
19.34k stars 2.3k forks source link

use sing-box tunneling on a domestic ubuntu server #606

Closed vahobrsti closed 1 year ago

vahobrsti commented 1 year ago

hi team,

thanks for the repository and your awesome work. I don't have actually an issue but needs a bit of help. I have

1- ServerIran: Domestic VPS with outgoing udp blocked. So no udp will be allowed to go outside of Iran (uot needed). 2- ServerPoland: Foreign VPS which has V2ray (vless - could be any other protocol- running on 9000 port) installed

What I'm trying to achieve is

[xray client] -----tcp--->  IranServer[sing-box (trojan):1234 ----- tun0 Iranserver (vless:9000) ----> [PolandServerserver:9000] tcp[xray server:9000]

[xray client initiates a request] -----tcp---> IranServer[sing-box (trojan):1234 listens and offloads the request, then tunnel it]----- tun0 of sing-box initiates vless to PolandServer:9000 and tunnel the request through tun0 of Iranserver(noth eth0) ----> [PolandServerserver:9000] receives it on tcp[xray server:9000]

Is this possible to be done in sing-box? I can do it via Nekoray Gui with a DOH (dns over https) server. Basically, Iranserver acts as a trojan server and vless client at the same time. Receives the traffic, offload it and relay it to Poland.

Thanks for your help.

nekohasekai commented 1 year ago

Basically, you should not use tun on the server. For use with other proxy programs, use socks5 for bridging.

vahobrsti commented 1 year ago

Hi @nekohasekai Thanks

Right now, I'm offloading the traffic in Iran and re-encrypt, tunnel through tun0. are you suggesting that instead of tun0, I can have a socks5 proxy in place to tunnel the requests from Iranserver to Polandserver?

[xray client] -----tcp---> IranServer[sing-box (trojan):1234 ----- socks5 Iranserver ---> (vless:9000) ----> [PolandServerserver:9000] tcp[xray server:9000]

I think this is related to what you said:

Why I can't use it with other local proxies (e.g. via socks)? Tun will hijack all traffic, including other proxy applications. In order to make tun work with other applications, you need to create an inbound to proxy traffic from other applications or make them bypass the route.

github-actions[bot] commented 1 year ago

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