Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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 serverfault.com/questions/247623/… –  ahaw Feb 17 at 12:49

2 Answers 2

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 example.com 8888"
share|improve this answer

Your Answer

 
discard

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.