B
B
Bega2022-01-11 09:15:59
linux
Bega, 2022-01-11 09:15:59

Redirecting host traffic to a local machine with a proxy, how?

Help to help configure the passage of host traffic through the gateway (linux) that is connected to the proxy server.
host > gateway > proxy
The task is very strange, but there is no other way out.
Tried to do it through iptables

iptables -t nat -A PREROUTING -s 192.168.0.0/24 -p tcp -m multiport --dports 80,8080,443 -j REDIRECT  --to-ports 10808
iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE

but an error comes out
2022/01/11 06:12:37 tcp:192.168.0.5:62481 rejected  v2ray.com/core/proxy/socks: unknown Socks version: 22

v2ray listens on two socks5 ports 10808 http 10809
Tried to configure proxy globally for linux via /etc/environment. Linux itself goes through a proxy, hosts directly. I broke my head how you can turn this feint with your ears

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vladimir Dubrovin, 2022-01-11
@Bega

You have redirected HTTP/HTTPS traffic to the SOCKS proxy port, which the SOCKS proxy does not expect (it expects a SOCKS client to come).
There are three possible solutions:
1. Make a redirect at the HTTP level, for this HTTPS will require a certificate substitution, traffic must be redirected to an http / https proxy, and then redirected from it further
2. For HTTP, do it at the HTTP level, for HTTPS take the destination name from SNI, redirect http to http proxy, redirect https to a separate port that SNI will do.
3. Use a proxy that supports transparent redirects
I don't know which of these supports v2ray, 3proxy supports options 1 and 3, squid supports option 2, I would recommend the third one. Further, from 3proxy, traffic can be redirected to the parent proxy, for example, to SOCKSv5 from v2ray. Discussed for example here:
https://3proxy.ru/plugins/TransparentPlugin/
https://github.com/3proxy/3proxy/issues/724

R
Rsa97, 2022-01-11
@Rsa97

For redirection, you need not socks-, but http-proxy, and in transparent mode.
For example, you can use Squid with transparent proxy configured.
For https traffic, you also need to configure SSL-bumping with installing your root certificate on all computers.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question