1

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.

gparent
  • 3,601
  • 2
  • 24
  • 28
Sławosz
  • 121
  • 5
  • Here is answer http://serverfault.com/questions/247623/iptables-redirect-local-connections-to-remote-system-port – ahaw Feb 17 '14 at 12:49

2 Answers2

4

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
ahaw
  • 206
  • 1
  • 3
1

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"
neutrinus
  • 1,125
  • 7
  • 18