Iptables – how to run pptp over redsocks proxy

iptableslinux-networkingpptpdsockstransparent-proxy

I have one (virtual) Linux box in Ubuntu, that has redsocks set up done. Inside the machine, I could confirm that the the redsocks did work (use wget to check the external IP).

Now, I want other client machines to share the same redsocks proxy. So I have set up a PPTP server (linux-pptp) in the linux machine, and connect clients machines to the linux box using PPTP.

Though the client still got the network after the PPTP connection, it has no redsocks proxy effect. Somehow the PPTP and redsocks are not connected together.

Here are my iptables rules:

iptables -t nat -N REDSOCKS
iptables -t nat -A REDSOCKS -d 0.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 10.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 127.0.0.0/8 -j RETURN
iptables -t nat -A REDSOCKS -d 169.254.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 172.16.0.0/12 -j RETURN
iptables -t nat -A REDSOCKS -d 192.168.0.0/16 -j RETURN
iptables -t nat -A REDSOCKS -d 224.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -d 240.0.0.0/4 -j RETURN
iptables -t nat -A REDSOCKS -p tcp -o eth1 -j DNAT --to 127.0.0.1:12345

iptables -t nat -A OUTPUT -p tcp -j REDSOCKS

iptables -t nat -A POSTROUTING -s 192.168.10.0/24 -o eth1 -j MASQUERADE
iptables -A FORWARD -p tcp --syn -s 192.168.10.0/24 -j TCPMSS --set-mss 1356

Please note that there is only one lan card (eth1) in the machine, and the redsocks service is located at 127.0.0.1:12345.

I have already stuck for one full day, any help would be much appreciated. Thanks.

Best Answer

Finally got it solved.

iptables -t nat -I PREROUTING -i ppp+ -p tcp -j REDIRECT --to 12345