9

I received a request from one of our developers that I am having trouble solving.

Here in the office they use linux desktops and I can forward the localhost:80 via a iptables nat to localhost:8080. What they want is the same thing at home in windows 7.

I got what I think are two ways of going about this. One to reconfigure the jboss webserver and all the webapps urls (messy). The other is find a way to redirect/nat the localhost port 8080 to port 80. Though in windows 7 I am unsure of how to do this.

Anyone have anyideas on how to do the second?

3 Answers 3

6

AFAIK, Win7 has no iptables equivalent. Writing a server that does what you want (listens on a port, copies everything to/from another) should be easy enough. You can find one at this URL: http://www.quantumg.net/portforward.php (untested). Using a reverse proxy (Google is yout friend) may fit the bill for http-like traffic. Also check this post: https://stackoverflow.com/questions/3721000/port-forwarding-on-windows-7

1
  • Doh, I feel like a dummy now, forgetting the term reverse proxy. As soon as I can up vote I will for you. Jan 3, 2012 at 14:53
13

Yes, windows does have a iptables equivalent, it is via the tool netsh and the portproxy interface.

The command to do what you want would be

netsh interface portproxy add v4tov4 listenaddress=YOUR_IP_HERE listenport=8080 connectaddress=YOUR_IP_HERE connectport=80 

Note, that this will only do IPv4 connections, if you also want to forward IPv6 connections you would also need to do

netsh interface portproxy add v6tov6 listenaddress=YOUR_IP_HERE listenport=8080 connectaddress=YOUR_IP_HERE connectport=80
4
  • Will this be persistent across reboots? Also the commands are invalid, as I get an error: "one or more essential parameters were not defined"
    – sorin
    Jul 21, 2015 at 20:03
  • @sorin it does persist, I use this in a system where I redirect RDP from the standard port to a nonstandard port and I only need to run this command once when I am setting up a new VM. As for the error, you are correct I forgot a parameter for the address (Which I see you fixed, thanks!) Jul 21, 2015 at 20:15
  • I instead used add v4tov4 listenport=80 connectaddress=127.0.0.1 connectport=8080 Assuming you want to listen on port 80 and redirect to a non-elevated server running on 8080, you need to switch the listen and connect ports. If you want to respond to both network IP and localhost requests, drop the listenaddress. And you can redirect to 127.0.0.1 to avoid hardcoding your IP address.
    – Carl Walsh
    Jan 17, 2019 at 5:51
  • Other useful commands are described in the Microsoft docs: docs.microsoft.com/en-us/windows-server/networking/technologies/… e.g., to list current portproxies (netsh interface portproxy show v4tov4) or to delete a postproxy (netsh interface portproxy delete v4tov4 listenaddress=localhost listenport=80)
    – neXus
    Jan 6, 2020 at 10:53
0

I think Windows has no iptables equivalent. Command

netsh interface portproxy ...

do port proxying but not packet forwarding. The main difference is

We had been using this technique to port forwarding but after those findings we had to use extra rules on network firewall to avoid usage of netsh.

You must log in to answer this question.

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