Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to make a port on a local Linux machine redirect to another ip address:port. I can currently achieve this with a ssh tunnel and sshing into myself, however I am sure there is more elegant way of doing this.

I am looking for something temporary and non-permanent. AKA easy to undo/remove.

Thanks!

share|improve this question

migrated from serverfault.com Aug 28 '12 at 5:41

This question came from our site for professional system and network administrators.

1  
it's either that or add iptables rules. guess which is easier! :) –  Michael Lowman Jul 19 '11 at 19:34

3 Answers 3

up vote 3 down vote accepted

SSH is a good choice, but netcat may also give you what you want.

See the generic tcp proxy section of this page. http://www.stearns.org/doc/nc-intro.v0.9.html

Basically the suggestion is to use a command like this.

mknod backpipe p
nc -l -p 80 0<backpipe | tee -a inflow | nc localhost 81 | tee -a outflow 1>backpipe

If this is something you do regularly, it should be really easy to put it all into a script which accepts arguments.

share|improve this answer

No, actually, SSH tunneling is probably your best option in general, especially given your "temporary and non-permanent" criteria.

share|improve this answer

If redirection need once (or some times ocassionally) - ssh best

"There is nothing more permanent than temporary." - proverb

But if temporary must live over many reboots - iptables look better.

But if some manipulations with data (logging for example) required - Netcat can be useful

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.