Monday, September 8, 2014

How to set up a windows proxy to redirect traffic using netsh

Suppose you want to expose a service running at a specified address/port, to another address/port, configuring a windows machine for acting as a proxy server.
For instance, computer A exposes a service available only to computer B, computer C wants to consume the same service. It doesn't reach computer C but reaches computer B. You can create a windows proxy server to redirect the traffic from C to B.


To do this, you can use the netsh windows command.

Computer A: 10.132.99.100:80
Computer B: 192.168.1.111:4422
Computer C: Any computer in the network that could reach Computer B at port 4422 (keep in mind that any service exposed out from a router needs to be mapped through Port Forwarding section in router control panel)

Open Command Prompt to use netsh command.

Set up a new connection:

netsh interface portproxy add v4tov4 listenport=4422 listenaddress=192.168.1.111 connectport=80 connectaddress=10.132.99.100

View all available connections: 

netsh interface portproxy show all


Note: The first command uses protocol conversion v4tov4 that stands for "from IPv4 to IPv4".
Have a look to other conversion options offered by netsh command.

No comments:

Post a Comment

(c) Copyright 2020 - MyTroubleshooting.com