I want to build a Anonymizing Middlebox. I dont understand the last iptables rule:

iptables -t nat -A PREROUTING -i $_inc_if -p tcp --syn -j REDIRECT --to-ports $_trans_port

The TCP traffic is redirected to localhost to the tor proxy port. But this means the original port is lost. For example if I create a ssh connection the destination port is 22. This rule rewrites the TCP header to destination port e.g. 9040. But the proxy behind this port needs to know the original port (22), because he must write it into the SOCKET protocol. How does it work if the information is lost?



Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.