How to Map Ports in Windows

Port mapping is a great feature that allows you to make almost any remote network service to work like it is running on your computer. Most people use specialized software to make it work, however there is a built-it Windows command that allows you to do exactly the same thing. Fire up windows command shell (Start->Run->cmd) and run this command:

netsh interface portproxy add v4tov4 listenport=8888 connectport=80 connectaddress= protocol=tcp

Now start web browser and go to this URL: http://localhost:8888/. Note that the web browser is pointer to your own computer yet it displays a page from my website.

Another example where you can use this utility is to expose a server that binds to loopback to the LAN. From my recent experience Webrick when started in Rubymine and Oracle Policy Modeller do that. If you want to access services exposed by these programs you can map a port on your loopback interface ( to your LAN interface. There are ways to configure both Webrick and OPM to bind to the LAN interface, but using netsh seems to be an easier way.

If you’re running Windows XP there is one catch though. You need to install IPv6 (Run->Settings->Control Panel->Network Connections->Local Area Connection->Properties->Install->Protocol->Microsoft TCP/IP version 6), otherwise this feature won’t work. It’s a known bug in netsh and it doesn’t look like Microsoft is going to fix it.

Google for netsh and you will find more cool features this utility is packed with.

Leave a Reply