NETSH port forwarding from local port to local port not working - portforwarding

I'm trying to use NETSH PORTPROXY command to forward packets sent to my XP PC (IP 192.168.0.10) on port 8001 to port 80 (I've a XAMPP Apache server listening to port 80).
I issued the following:
netsh interface portproxy add v4tov4 listenport=8001 listenaddress=192.168.0.10 connectport=80 connectaddress=192.168.0.10
Show all confirms that everything is configured correctly:
netsh interface portproxy show all
Listen on IPv4: Connect to IPv4:
Address Port Address Port
--------------- ---------- --------------- ----------
192.168.0.10 8001 192.168.0.10 80
However, I'm not able to access apache website from http://localhost:8001. I'm able to access through the direct port at http://localhost as shown below.
Additionally, I've also tried the following:
1. Access the Apache website from a remote PC using the link: http://192.168.0.10:8001. Firewall turned off.
2. Changing listenaddress and connectaddress to 127.0.0.1.
Without further information, I can't find a way to resolve the problem. Is there a way to debug NETSH PORTPROXY?
Note: By the way, if you're wondering why I am doing this, I actually want to map remote MySQL client connections from a custom port to the default MySQL Server port 3306.

I managed to get it to work by issuing:
netsh interface ipv6 install
Also, for my purpose, it is not required to set listenaddress and better to set connectaddress=127.0.0.1, e.g.
netsh interface portproxy add v4tov4 listenport=8001 connectport=80 connectaddress=127.0.0.1

If netsh's port proxying is not working as expected, then you should verify the followings, preferably in that order:
Make sure the port proxy is properly configured
Start or restart the related Windows service
Ensure support for IPv6 is installed
Make sure the port is not blocked by a firewall
Make sure the port proxy is properly configured
This might seems to be trivial, but just in case, take the time to review your configuration before you go any further.
From either a command prompt or PowerShell prompt, run the following command:
netsh interface portproxy show all
The result should look something like this:
Listen on ipv4: Connect to ipv4:
Address Port Address Port
--------------- ---------- --------------- ----------
24.12.12.24 3306 192.168.0.100 3306
24.12.12.24 8080 192.168.0.100 80
Carefully review those settings. Make sure that you can indeed connect to the addresses on the right side of that list, from the local computer. For example, can you locally open a web browser and reach 192.168.0.100:80? If the protocol is not HTTP, then use telnet: telnet 192.168.0.100 3306 (see here for how to install the Telnet client on Windows).
Then, are the values on the left side correct? Is the IP address valid for your machine? Is that the port number you are trying to connect to, from the external machine?
Start or restart the related Windows service
On latest versions of Windows, netsh's port proxying is handled by a Windows service named "IP Helper" or "iphlpsvc". Proxying will obviously not work if that service is stopped. I have also faced situations that turned out to be resolved by restarting that service.
To do that in latest versions of Windows:
Open the Task manager, then go to the Services tab.
In the "Name" column, find the service named either "iphlpsvc" or "IP Helper".
Right click on that service, then select Restart. If restart is not available, then the service is probably stopped, and actually has to be started, so select Start.
On previous versions of Windows, look for Services in Administrative Tools, inside the Control Panel.
Ensure support for IPv6 is installed (older releases of Windows only)
On earlier versions of Windows (that is Windows XP, for sure, upto some early releases of Windows 10, apparently, though this is not clear), netsh's port proxying feature (including for IPv4-to-IPv4 proxys) was actually handled by a DLL (IPV6MON.DLL) that was only loaded if IPV6 protocol support was enabled. Therefore, on these versions, support for the IPv6 protocol is required in order to enable netsh's port proxying (see Microsoft's support article here).
From either a command prompt or PowerShell prompt, run the following command:
netsh interface ipv6 install
If you get an error indicating that command interface ipv6 install was not found, then it means that you are using a recent release of Windows, in which netsh's IPv6 support is implicit and cannot be disabled.
Make sure the port is not blocked by a firewall
A local firewall may potentially block the port even before they reach the IP Helper service. To make validate this hypothesis, temporarily disable any local firewall (including Windows' native firewall), then retest. If that works, then simply add a port exclusion to your firewall configuration.

I have the problem with you. I have solve it just now. There is a Windows Service named "IP Helper" that supplies the funcions tunnel connections. You should ensure it has been started.

You must Run Command.exe as Administrator first, by right-clicking the Command Prompt icon and choosing Run as Administrator. You will asked to confirm.
Paste your netsh Command in the command.exe window and press Enter.
If no error message is shown, the command worked.
In your web browser go to http://your-up:8001 to see it works.
The Windows Event Log might have information to help find the cause of a failure.

Related

How to connect a Server in linux (host) with a client running in QEmu's guest linux (guest)

I want to connect via TCP socket a server app running in the host with a client running in the QEmu guest.
I use port 5104 for the socket in the server.
I start the server.
Then I found that I can not launch the QEmu giving that port as the input point for the client in the guest, like this:
qemu-system-arm ... -net user,hostfwd=tcp:127.0.0.1:5104-:5104
Gives the error "Could not setup host forwarding rule ..."
I guess that qemu acts like a server also and then the port is already taken by the server previously launched and then is not possible to do it.
Which is the correct syntax? The documentation talks about the option guestfwd but I tried all the possibilities and I couldn't found the solution. It should be way to do it.
Any suggestion?

WebSocket-Sharp doesn't respond to public IP address

I have a problem hosting WebSocket-Sharp on a public internet IP. Locally it works fine.
This problem occurs on Windows and Linux.
I do no receive a timeout or an HTTP status code, the page blocks immediately.
I'm 99% sure I have port forwarding set up correctly; I've tried with an Android modem, VPN and regular NAT router setup.
I've tried the following combinations:
192.168.1.2:80 8080 5000 39393
0.0.0.0: ....
public IP: ....
The problem resides in the HttpServer provided with WebsScketSharp. The pure websocket variant (WebSocketServer.cs), instead of the HttpServer option with Get functionality, has an option to set AllowForwardedRequest to true so will be reachable from non localhost addresses. The HttpServer class doesn't support this.
It is partially a solution as I gave up regular GET functionality, but thats fine by me.
Ok, assuming your server with the public Ip addres is Linux:
Check what ports are listening and what program are listening in those
netstat -tulpn
Check your Firewall rules both in the provider and in the Server
sudo ufw status
See if connections are getting to your Server
sudo tcpdump
You can filter for the port of for origin Ip (if you use a proxy that will be different Ip).
sudo tcpdump | grep "80\|123.45.67.89"
That's the only way to see if the packets are getting into the server.
Let me know if you use Docker as thinks work a bit different.
You can create a tunnel and try like if it was local
ssh -L 80:123.45.67.89:80 ubuntu#yourserver.com
Cheers

Meteor - accessing the app using public ip

I can access the app using localhost:3000 but I am trying to test from mobile devices locally, without having to deploy it. But I couldn't access the site.
I am allowing incoming request:
sudo ufw status verbose
Status: active
Logging: on (low)
Default: allow (incoming), allow (outgoing)
New profiles: skip
To Action From
-- ------ ----
3000/tcp ALLOW IN Anywhere
3000/tcp ALLOW IN Anywhere (v6)
I found that my ip address is 128.84.125.239 and so I visit 128.84.125.239:3000 and nothing happens.
This turned out to be an issue of using the right IP, or configuring the NAT of the router appropriately. Using a service such as cmyip.com will only provide you with your external IP address. This address can only reach your meteor app if your router is configured accordingly, i.e., the router will forward requests on port 3000 (or whichever port you are running your app on) to your server.
For testing on a mobile device during development you are most likely best off using your internal IP address, assuming your mobile device is on the same network as your app-serving machine.
On Linux you can use ifconfig to get your internal IPs. If you are connected via ethernet then you'll be looking for the device eth0 (in most cases). If you are connected over wifi, then the device you are looking for is typically called wlan0.
On Mac OSX you can use ifconfig as well, and look for devices called enX, where X is a number (often 0, or 2).
Your service is probably only running locally (on local ports, 127.0.0.0/8), To confirm this, run netstat -tulpn to see what services are running and on what ports/interfaces. If you don't see 0.0.0.0:3000 or 128.84.125.239:3000 then you won't be able to get ti it from the IP you are trying and you need to change the bind address of your app to be that IP (or all interaces).

Connecting to Windows localhost (IIS) from another computer

I have a Windows Vista laptop running IIS7 for its localhost. On this machine, I can successfully navigate to:
"http://localhost"
"http://127.0.0.1"
"http://mycpuname"
However, I cannot access this localhost website from another computer on the same network. Ideally I would be able to visit "http://mycpuname" (so that I can hard-code a connection), but at this point I might settle for the IP address of the machine (http://192.000.000.xyz)
I've seen similar questions asked here and elsewhere on the internet... but none of the posts seems to fix the issue for me.
Things I've tried:
- adding exceptions to Windows Firewall to allow TCP ports 80 and 8080
- disabling Windows Firewall entirely
- running the "netsh" commands in this post
Additionally, I am looking at the IP address on the Windows laptop by running "ipconfig" from the command prompt. Oddly enough, trying to access "http://192.000.000.xyz" from the Windows laptop doesn't seem to work...
I have also tried restarting IIS and restarting my machine.
Help?
Go to windows firewall with advanced security, inbound rules and check and see if world wide web services is enabled. I had this same issue, and this fixed it for me.
are you binding to 127.0.0.1? run below command
netstat -an |findstr :80 |findstr LISTEN
if it shows 127.0.0.1, you need change IIS listen to 0.0.0.0
Try netstat -na - it will show you what IP addresses your web server is listening on.
If it's only listening on 127.0.0.1, the loopback, you will have to re-configure the web server to listen on all addresses/interfaces (usually either *.*.*.*, or 0.0.0.0 in some config file, or just some drop-down in some windows dialog somewhere).
If, on the other hand, netstat tells you the web server is listening on *.*.*.* or 0.0.0.0, i.e. all interfaces, then you have to figure out what's blocking the traffic - it's either the local firewall, or something on the path between the two computers.
If you want to access your website from any other computer on your local network then you need to simply type your network IP and port. If you want to access it from internet then you need to configure your IP.

Accessing ASP.NET Development Server from another pc on the network

I would like to test my web app in other browsers. I have installed Virtual PC to do just that. the ASP.NET development server does not allow remote connections so the virtual pc (another computer on the network) cannot access the website.
I found this post that was started but there was no solution.
I understand that using localhost will not work. I heard about using the machines ip, but how do I get that correct ip? Look at my lynksys router admin?
If I were to get as far as getting my IP, im sure that the asp.net dev server does not allow remote connections. How do I enable it to do so?
The answer is: no(*). You cannot access the ASP.NET Development Server on one machine from another, even if you open the Windows firewall TCP port.
From the MSDN article "Web Servers in Visual Web Developer":
It is specifically built to serve, or run, ASP.NET Web pages under the local host scenario (browsing from the same computer as the Web server).
In other words, the ASP.NET Development Server will serve pages to browser requests on the local computer. It will not serve pages to another computer. Additionally, it will not serve files that are outside of the application scope.
(*) You'll have to run your site from your locally installed IIS... or do the nice hack using some freeware described in this blog post:
iPhone Accessing the Visual Studio ASP.NET Development Server
Use SPI Port Forward to accept the device connections do the following:
Set "Local port" to the port number the device will connect on, I usually use 8080 out of habit
Set "Remote host" to localhost
Set "Remote port" to the ASP.NET Dev Server Port
Click the "Activate" button to start accepting connections
(note: make sure you've started the program with admin rights)
I'm making some guesses about your setup here so bear with:
If your virtual machine is XP Professional, Vista Business, Windows 7 Professional or better, then you should be able to run IIS locally on the development machine and access that webserver from another machine which is on the same network via the virtual machine's name.
Likewise, if you're doing development on a real machine and would like to use different virtual machines to access the web application, you should make sure that you have IIS installed, create a new website in IIS and you should be to browse to the web application via machine name from your virtual machines.
Either way, don't try to use the builtin web server from Visual Studio, just publish your site to IIS and work with it that way.
Good luck and hope this helps some.
Setup a portforwarding using RINETD
Deatils here: http://blog.waynehartman.com/articles/218.aspx
Another answer if you don't want to use IIS (or tunnels): https://stackoverflow.com/a/12008223/1552178
Use fiddler or similar on your host - set your browser on the client
VM to use the proxy then just use localhost:dev_port as usual on the
client.
All requests from the client goto the proxy on your dev machine which
routes to localhost on the dev machine and the ASP.net dev server
thinks the request is from your dev machine!
I am answering this old question to help people to make it work without IIS.
1. First Step
You have to download Fiddler.
Once Fiddler is downloaded and installed, open it.
Go in Tools-> Fiddler Option-> Connection tab-> And check "Allow remote computers to connect" :
Restart Fiddler.
2. Second Step
After this, in the other PC on the network OR the VM, open internet explorer-> Internet Options-> Connection Tab-> Lan Settings-> Check "Use a proxy server for your LAN" :
The adress is the IP adress of your DEV machine.
And put the port 8888
Now, you can access the ASP.NET Web Server from another PC on the network (maybe you have, more config to do, like firewall, unrestricted port, etc, but this is a good start) !
To access it -> http://localhost.:54814
Don't forget the additional point after "localhost" ! (Overwrite the local localhost)
The port, "54814" in my case, is the ASP.NET Web Server port.
NOTE :
To test if the proxy work, you can try this : http://localhost.:8888
Maybe I forgot to point out some configurations, but it always depend of the network infrastructure.
Working solution for Linux
This should work if you're running an ASP.NET Dev Server on Windows in a VM or on another host and you want to access it from Linux
On Windows machine
For some reason you cannot connect directly to the ASP.NET dev server port, you need to proxy it locally first:
Use SPI Port Forward to accept the device connections do the following:
Set "Local port" to the port number the device will connect on, such as 8089
Set "Remote host" to localhost
Set "Remote port" to the ASP.NET Dev Server Port
Click the "Activate" button to start accepting connections
(note: make sure you've started the program with admin rights)
On Linux machine
Locally forward localhost port 8089 to the windows IP (replace GUEST_IP_HERE with the correct ip):
iptables -t nat -A OUTPUT -m addrtype --src-type LOCAL --dst-type LOCAL -p tcp --dport 8089 -j DNAT --to-destination GUEST_IP_HERE:8089
iptables -t nat -A POSTROUTING -m addrtype --src-type LOCAL --dst-type UNICAST -j MASQUERADE
This is needed because the dev server specifically looks for localhost in the request and will not respond to http://GUEST_IP_HERE:8089 from the host
I tried the following that i expected to enable current .net framework [ core / x-platform ] 6.0 release provided asp.net development web server access at least from other machines on local subnet w/o needing to use any 3rd party software enable the port forwarding/proxy to localhost only exposed web server.
I was able to launch the asp.net development web server from windows wsl [ windows subsystem for linux ] distro session and access it using the windows host wi-fi adapter ip address but not from another machine on my subnet, e.g. a vmware linux install operating in bridge mode. It did work if i switched vmware linux install to nat mode.
Any thoughts on why this doesn't allow other hosts access as i expected it would?
netsh interface portproxy add v4tov4 listenport=<tcp port for non-localhost access allowed/enabled in windows firewall> listenaddress=0.0.0.0 < or windows wired/wifi ipaddress > connectport=<tcp port for localhost access to asp.net development web server> connectaddress=localhost
e.g. netsh interface portproxy add v4tov4 listenport=4430 listenaddress=0.0.0.0 connectport=7146 connectaddress=localhost & netsh interface portproxy add v4tov4 listenport=8080 listenaddress=0.0.0.0 connectport=5038 connectaddress=localhost
netsh interface portproxy show all
// for %i in ( 4430, 8080 ) do ( netsh interface portproxy delete v4tov4 listenport=%i listenaddress=0.0.0.0 )
netsh advfirewall firewall add rule name="Asp.Net Development Web Server Listeners to Expose" dir=in protocol=tcp localport=<csv list of tcp ports allowed/enabled in windows firewall> profile=private|any remoteip=localsubnet|any action=allow [ enable=yes ]
e.g. netsh advfirewall firewall add rule name="Asp.Net Development Web Server Listeners to Expose" dir=in protocol=tcp localport=4430,8080 profile=private remoteip=localsubnet action=allow
netsh advfirewall firewall show rule name="Asp.Net Development Web Server Listeners to Expose" [ or wf.msc | inbound rules ]
// netsh advfirewall firewall delete rule name="Asp.Net Development Web Server Listeners to Expose"
year 2022:
After trying everything on asp.net core .NET 6 side and failed I have found
https://mitmproxy.org/
mitmproxy --mode reverse:https://localhost:7053 --ssl-insecure
covers my use case.
on phone and other devices access with http://{your-pc-ip}:8080
Open a command prompt and type; "ipconfig" this will give you your machines IP address.
If you disable your firewall (for the asp.net dev port at least) you should be able to type into the virtual PC's browser http://192.168.1.3:3243/default.aspx

Resources