Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to forward one local port to another?

I have a HTTP proxy server running on port 127.0.0.1:8888. I need to redirect a HTTP client binding to 127.0.0.1:8080 to be forwarded to 127.0.0.1:8888.

I tried using netsh.exe utility in Windows. I have DHCP client service running in my windows 7.

netsh interface portproxy add v4tov4 listenport=8080 listenaddress=127.0.0.1 connectport=8888 connectaddress=127.0.0.1

The command was successfully executed. However the proxy server never receives any request. Is it not possible to forward local ports? Or my understanding is wrong.

like image 325
justanaccount121 Avatar asked Oct 10 '13 17:10

justanaccount121


People also ask

Can I port forward with CMD?

If your business doesn't have a port forwarding utility, you can use the Command Prompt to manually set up port forwarding. CMD uses the Netsh command to initiate the port forwarding process. To make this work, you need to know the port number and IP address for both the source and destination hosts.

How does local port forwarding work?

Essentially, port forwarding maps an external “port” on your internet-facing IP address to a particular computer on your local private network. This allows you (or someone else) to access something on your computer from the internet. Port forwarding solves all kinds of problems, but it can also be dangerous.

How do I port forward 80 to another port?

Under Hostname Type, select Port 80 Redirect. Enter your current Public IP Address in the IP Address field. Enter the Port number you would like the HTTP requests sent to. Scroll down and click the Add Hostname button when finished to save your configuration.


2 Answers

So when you define the sourceAddress using the actual IP address then it only works for remote systems. If you only want to forward local connections try 127.0.0.1 but if you want to forward both use 0.0.0.0.

like image 131
Mark Avatar answered Oct 21 '22 13:10

Mark


Set listenaddress and connectaddress to actual address in LAN (e.g. 192.168.1.15, depending on your router and dhcp). Not localhost

like image 41
Saint Avatar answered Oct 21 '22 14:10

Saint