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

This is my situation:

Two computer under the same router, and

This is what I like to do: On, while accessing port 22 with localhost, it directs the traffic to port 22.

In another word, I would like to forward whatever traffic from localhost to another local IP.

Is there any solution for what I need?

share|improve this question
It might help to know what you are trying to achieve, knowing your OS would help, too. – Baarn Jul 1 '12 at 19:15
netcat ... but you'd have to disable ssh on 1.101. What ARE you trying to do? – lornix Jul 2 '12 at 12:07
You're misusing the term localhost. Sounds like you think it's the locally assigned internet accessible IP address. It isn't. The loopback network ( which will contain your localhost ( is used for all IP communications that are supposed to happen within that box you call a computer. This is one of those questions, which if you have to ask it, you don't understand enough to be messing around with it. – Fiasco Labs Jan 13 '13 at 5:26

Don't redefine the meaning of localhost. You'll break things in surprising ways.

Instead, look at the -L and -R options in ssh(1). They make it easy to redirect a port on the local machine to the IP address and port of a remote machine. Plus the tunnel is secured by SSH.

Note that these tunnels are not necessarily specific to ssh/shell traffic. It can be for arbitrary traffic.

share|improve this answer

Not sure if that is a smart thing to do. A lot of services intended to run on the local machine use either (which would be no problem with your change) or localhost (in which case your change would mess things up) to connect to other services on the same machine. And a lot of other packages comes configured this way.

If the purpose is to have the same name to connect crosswise, regardless on which machine you are, I'd rather recommend to use a different name for this. Instead of "localhost" you could e.g. use "crosshost" - and with that follow the hints given by Indrek: Check for your hosts file (on Linux/Unix and probably also Mac it is /etc/hosts, on Windows it is C:\Windows\System32\drivers\etc\hosts (without extension -- so take care here, Windows usually already has some other hosts.* file in that directory). Do NOT comment out the localhost line, nor modify it -- leave it as is. Just add a line crosshost

on the machine, and similarly with the other address on the other machine. Now you can e.g. ssh crosshost to connect to one machine from the other, or copy files over with scp filename.ext crosshost:/path/to/put, or whatever you intended.

share|improve this answer

Execute the command:

netsh interface portproxy add v4tov4 listenaddress= listenport=21 connectaddress= connectport=21


  • 21 with the port you want to forward,
  • with your ip,
  • with the destination ip.
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.