Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a script that tries to connect to rabbitmq using default url and port (localhost:5672).

Is it possible to make linux redirect all connections to this url and port to different server?

I am creating some proof of concept and such thing would be useful for me.

share|improve this question
Here is answer… – ahaw Feb 17 '14 at 12:49
up vote 4 down vote accepted

I found a better solution for you:

sysctl net.ipv4.ip_forward=1
iptables -t nat -A PREROUTING -p tcp --dport port -j DNAT --to-destination ip:port
share|improve this answer

As you are asking for a script, so I think you are asking for a userspace tool.

nc -l -p 8888 -c "nc 8888"
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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