if we have two server let's say server1( server2(

I'm working on redirect incoming traffic on server1 port 4444 to server2 port 12345,this is easy with iptables rule on server1 like the following:

sysctl -w net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p tcp --dport 4444 -j DNAT --to-destination
iptables -t nat -A POSTROUTING -j MASQUERADE  

this working well

request --> 4444:server1 <===> 12345:server2

what I need to do is using tor netwok between the two server:

request --> 4444:server1 <===> |tor network| <===> 12345:server2

how I can do what?

I tried to use HiddenServicePort on server2 but I can't forward traffic from HiddenServicePort to another tor hostname ( in server1)

also how i can redirect traffic from iptables to tor specific hostname (server2 hostname)


If you would like to do the following: request --> 4444:server1 <===> |tor network| <===> 12345:server2

You just require to setup tor client on server1 and use system wide proxy settings in order (e.g. https://www.experts-exchange.com/articles/16980/How-to-set-up-a-TOR-Transparent-Proxy.html)

And before applying any iptables be sure to check that there is a specific rule that will keep you connected to the server via SSH (to avoid being cut out)

In order to proxy the request from port 4444 to server2 you will need to setup a reverse proxy such as Nginx or HAproxy (using the tor client this will use the tor network connecting to server2), from a tecnical point of view doesn't make a lot of sense but i don't know the specific use case

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.