Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is redsocks able to redirect udp traffic by tproxy (not only for dns )? #173

Open
pizeroTT opened this issue Jun 6, 2022 · 4 comments
Open

Comments

@pizeroTT
Copy link

pizeroTT commented Jun 6, 2022

I have seen 7783402
for redirecting udp traffic, but that not work for me?

my iptables rules:

ip route add local 0.0.0.0/0 dev lo table 100
ip rule add fwmark 1 table 100
iptables -t mangle -N REDUDP
iptables -t mangle -A REDUDP -d 0.0.0.0/8 -j RETURN
iptables -t mangle -A REDUDP -d 10.0.0.0/8 -j RETURN
iptables -t mangle -A REDUDP -d 100.64.0.0/10 -j RETURN
iptables -t mangle -A REDUDP -d 127.0.0.0/8 -j RETURN
iptables -t mangle -A REDUDP -d 169.254.0.0/16 -j RETURN
iptables -t mangle -A REDUDP -d 172.16.0.0/12 -j RETURN
iptables -t mangle -A REDUDP -d 198.18.0.0/15 -j RETURN
iptables -t mangle -A REDUDP -d 224.0.0.0/4 -j RETURN
iptables -t mangle -A REDUDP -d 240.0.0.0/4 -j RETURN
iptables -t mangle -A REDUDP -p udp -j TPROXY --on-port 10053 --tproxy-mark 0x1/0x1
iptables -t mangle -A REDUDP -p tcp -j TPROXY --on-port 12345 --tproxy-mark 0x1/0x1
iptables -t mangle -A PREROUTING -p udp -j REDUDP
@ge9
Copy link

ge9 commented Mar 17, 2024

Yes, it worked for me.
Unless more tricky iptables settings are applied, PREROUTING is not applied to packets generated in the machine where tproxy is running.

@sunShuShu
Copy link

It works for me too, but I added "iptables -t mangle -A REDUDP -d 192.168.0.0/16 -j RETURN" before TPROXY rules and added the "--on-ip 127.0.0.1" to TRPOXY rules ( my local_ip of redudp in config file is also 127.0.0.1 ).

@iopq
Copy link

iopq commented Sep 26, 2024

Yes, it worked for me. Unless more tricky iptables settings are applied, PREROUTING is not applied to packets generated in the machine where tproxy is running.

how would you do it then if tproxy is running locally

@ge9
Copy link

ge9 commented Sep 27, 2024

There is a good document in the Hysteria project.
https://v2.hysteria.network/docs/advanced/TPROXY/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants