Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

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'd like to make all incoming connections to port 1000 of my host (IP: 200.234.XXX.XXX) to be forward to the port 80 on host

How can I do it on my host? It is running Mac OS X 10.5.8

share|improve this question
ah, you're also running parallels, having the same problem as I? :) – LearnCocos2D Feb 21 '13 at 10:36
up vote 22 down vote accepted

Quite simple to do, Firstly you will need to enable the remote login service on your mac. This starts your ssh server.

Then run the following command in your OS X Terminal:

ssh -L 200.234.XXX.XXX:10000: -N

You may need to accept the server fingerprint initially as well as type in your local password for ssh login. (You can also set up a local to local ssh public / private key to make it not prompt for a password, but that it a different exercise.)

The format is thus basically:

ssh -L [<local addr>:]<local port>:<remote addr>:<remote port> -N

share|improve this answer
Can we do it if port 22 is not open? – Afshin Moazami Oct 14 '15 at 16:14
You need to connect somehow. But you can always run ssh on another port... perhaps http port? or the BIND (DNS) port? Those are mostly open on firewalls. – Marius Nov 11 '15 at 22:53
amazing! thanks so much it worked! – kernix Jun 22 at 12:15

Assuming you have a UPnP router, its easy to configure ports by using PortMap

It has a very simple UI.

alt text

share|improve this answer

Well, I can tell you how I do that sort of thing on my Mac OS X 10.5.8 system.

I started on an answer about NAT, but I think you actually want a TCP forwarder program instead (you mention 'proxy' and port forwarding.)

There's a few ways of doing this, depending upon your needs even 'SSH' can be pressed into action, though my favourite short and sweet way is a Perl script tcpforward.

If you need some HTTP manipulation (you might need to tweak HTTP redirects, so that when a request comes for a URL without a trailing '/' you don't get redirected to the real, inaccessible, server), then Apache can do the job of a reverse proxy. You'll want to look at mod_proxy and specifically ProxyPass and ProxyPassReverse. Do not enable ProxyRequests, that's for forward proxying. It should be possible to use Mac OS's own Apache to do this, if you've got it running. It does come with mod_proxy and /etc/httpd/httpd.conf is the config file to update.

Even with Apache, you need to make sure that all the links in the real server's content are relative, if they reference the real server then you could try the mod_proxy_html module (I have no experience of how well that works.)

share|improve this answer

Here is a good article:

But since you are forwarding to 80 I'm assuming you want it to go to a web server so I would just change the web server config to set up a reverse proxy or something like that.

share|improve this answer
Looks like the link is broken – Jochen Bedersdorfer Aug 14 '15 at 15:17

Very simple using the versatile tool ncat:

sudo ncat --sh-exec "ncat 80" -l 1000 --keep-open

Get the binaries of ncat/nmap for Mac OS X from the official website:

EDIT: added sudo to listen on a restricted port <1024

share|improve this answer

Is your machine connected directly to the internet (IE - without a router)? Normally you do the port forwarding on the router, but if you do use a modem to connect directly, iptables is probably the best way.

share|improve this answer
I have no idea why this was voted down because it's the truth. – Hasaan Chop Nov 21 '09 at 0:27
@HasaanChop This is downvoted because it isn't helpful. If it detailed exactly how to use iptables to accomplish what the question asked, that could be useful. – Jon-Eric Jan 22 '13 at 21:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .