darkk/redsocks

Not fully working as a socksifying router

developer-ken opened this issue · 1 comments

I have a Debian installed in vm. It has two network devices, one is ens3(wired) and another one is wlxd0c0bf8d9e5b(wireless).
Basically, I connect my wireless to the internet, setup a socks5 proxy with danted and turn it into a transparent proxy on ens3.

I then will connect my other device to ens3, and I expect every connection the device connected to ens3 made should go through socks5, then my wireless connection. (This is because my wireless network provider restrict me from connecting multiple devices, and NAT will be detected and banned. Proxy will be a workaround.)

I set following rules:

iptables -t nat -N SOCKS
iptables -t nat -A SOCKS-p tcp -j REDIRECT --to-port 12345
iptables -t nat -I PREROUTING -p tcp -j SOCKS
iptables -t nat -A PREROUTING --in-interface ens3 -p tcp -j SOCKS

iptables -t nat -A SOCKS-p udp -j REDIRECT --to-port 12345
iptables -t nat -I PREROUTING -p udp -j SOCKS
iptables -t nat -A PREROUTING --in-interface ens3 -p udp -j SOCKS

I changed my local_ip in redsocks.conf to the address on ens3. When I try to access the internet from my other device, I see some logs about connections accepted, data relaying started and then connection closed. But internet won't work.

Set socks5 proxy on my other device will work, and I will have internet access, so I guess the socks5 server is fine. Also, it seems to be ok when redsocks is enabled and I am just connecting the host(running redsocks). Those connection will work (like ssh).

iptables -t nat -N SOCKS
iptables -t nat -A SOCKS -p tcp -j REDIRECT --to-port 12345
iptables -t nat -A PREROUTING --in-interface ens3 -p tcp -j SOCKS

iptables -t nat -A SOCKS -p udp -j REDIRECT --to-port 12345
iptables -t nat -A PREROUTING --in-interface ens3 -p udp -j SOCKS

This works.