Closed cufirod closed 6 years ago
try my fork of redsocks, it works.
I can confirm that your fork can handle UDP traffic without errors. And the support of shadowsocks is even more awesome.
However, I am still not able to configure TPROXY on my machine. If I run these commands
ip rule add fwmark 0x01/0x01 table 100
ip route add local 0.0.0.0/0 dev lo table 100
iptables -t mangle -N REDSOCKS2
iptables -t mangle -A REDSOCKS2 -p udp -j TPROXY --on-port 10053 --tproxy-mark 0x01/0x01
iptables -t mangle -A PREROUTING -j REDSOCKS2
and I setup redudp to work in the TPROXY mode (I omit dest_ip and dest_port)
redudp {
local_ip = 127.0.0.1;
local_port = 10053;
ip = 127.0.0.1;
port = 8888;
udp_timeout = 10;
//udp_timeout_stream = 180;
}
then I do not see any debug output from redudp. On the other hand, when I use redudp without TPROXY support, then I can clearly see in the debug output that redudp is making connections.
If somebody was able to successfully configure TPROXY for redsocks/redsocks2, could you please share the iptables rules you created? I guess that the commands ip rule
and ip route
are allways the same, however iptables entries can vary among configurations.
There is one more thing that concerns me. Is it not a problem, that I run redsocks and iptables on the same machine that I use for testing the connection? Somewhere I have read that TPROXY works only on routers because the PREROUTING
chain does not apply to localhost traffic.
I think that it would be beneficial both for the users of redsocks as well as for the users of redsocks2 to have an example of working configuration.
I think your ip configs are correct. For redsocks2, the redudp config section requires one more parameter: type. It's value can be 'socks5' or 'shadowsocks'. You are right, TPROXY only works for incoming packets. 2016年3月22日 下午10:39,"cufirod" notifications@github.com写道:
I can confirm that your fork can handle UDP traffic without errors. And the support of shadowsocks is even more awesome.
However, I am still not able to configure TPROXY on my machine. If I run these commands
ip rule add fwmark 0x01/0x01 table 100 ip route add local 0.0.0.0/0 dev lo table 100 iptables -t mangle -N REDSOCKS2 iptables -t mangle -A REDSOCKS2 -p udp -j TPROXY --on-port 10053 --tproxy-mark 0x01/0x01 iptables -t mangle -A PREROUTING -j REDSOCKS2
and I setup redudp to work in the TPROXY mode (I omit dest_ip and dest_port)
redudp { local_ip = 127.0.0.1; local_port = 10053; ip = 127.0.0.1; port = 8888; udp_timeout = 10; //udp_timeout_stream = 180; }
then I do not see any debug output from redudp. On the other hand, when I use redudp without TPROXY support, then I can clearly see in the debug output that redudp is making connections.
If somebody was able to successfully configure TPROXY for redsocks/ redsocks2, could you please share the iptables rules you created? I guess that the commands ip rule and ip route are allways the same, however iptables entries can vary among configurations.
There is one more thing that concerns me. Is it not a problem, that I run redsocks and iptables on the same machine that I use for testing the connection? Somewhere I have read that TPROXY works only on routers because the PREROUTING chain does not apply to localhost traffic.
I think that it would be beneficial both for the users of redsocks as well as for the users of redsocks2 to have an example of working configuration.
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/darkk/redsocks/issues/79#issuecomment-199843353
I apologize for improperly copying my redudp config section. I was deleting the comments and I accidently deleted an important line.
TPROXY can be used only on the PREROUTING chain. However if I am correct, then the command ip route add local 0.0.0.0/0 dev lo table 100
, redirects each outgoing packet to the lo
interface. Thus this packet is an incoming packet to the lo
interface and it can be redirected to TPROXY.
Please correct me if I am wrong. This should mean that the TPROXY method can be used to send outgoing UDP traffic from a device to a proxy server via redsocks running on the same device. Is it correct?
Or am I wrong and there is some reason that TPROXY must be configured on a router?
iproute2 is for routing manipulation. TPROXY is used for PRE routing. Think about what is a mess if locally generated packets become incoming packets. 2016年3月22日 下午11:55,"cufirod" notifications@github.com写道:
I apologize for improperly copying my redudp config section. I was deleting the comments and I accidently deleted an important line.
TPROXY can be used only on the PREROUTING chain. However if I am correct, then the command ip route add local 0.0.0.0/0 dev lo table 100, redirects each outgoing packet to the lo interface. Thus this packet is an incoming packet to the lo interface and it can be redirected to TPROXY.
Please correct me if I am wrong. This should mean that the TPROXY method can be used to send outgoing UDP traffic from a device to a proxy server via redsocks running on the same device. Is it correct?
Or am I wrong and there is some reason that TPROXY must be configured on a router?
— You are receiving this because you commented. Reply to this email directly or view it on GitHub https://github.com/darkk/redsocks/issues/79#issuecomment-199878507
Seems, that's more or less resolved.
@semigodking thanks for maintaining the fork focused on circumvention :)
Redsocks cannot forward the device's own UDP data, because forwarding UDP requires the use of TPROXY. But TPROXY works in the PREROUTING chain. The UDP data of this machine does not go through the PREROUTING chain. redsocks can work on the router and forward the UDP data of the lan port device, because these UDP data are connected through PREROUTING
Many questions regarding UDP and DNS support by redsocks appeared recently. I think that I speak for many people if I say that it is not clear how to properly configure redudp.
First of all, a list of iptables rules for the tproxy solution is crucial and unavailable at he same time. The tutorial from balabit is nice, however it might be too difficult to apply it to a situation with redsocks.
For example I have the simples possible configuration. My UDP compatible SOCKS5 server listens on localhost port 8888 and my redudp section is:
My iptables entries are:
And I still receive these errors whenever my browser performs a DNS lookup:
Where
x.x.x.x
is my public IP address andy
is a random port selected by the browser.