Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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 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.


share|improve this question

migrated from Aug 28 '12 at 5:41

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

it's either that or add iptables rules. guess which is easier! :) – Michael Lowman Jul 19 '11 at 19:34
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.

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


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.