To route all traffic from one IP address to a new one on Windows using netsh interface portproxy
, you’ll need to configure the portproxy
to listen on the old IP and port, and connect to the new IP and port. This involves using the netsh interface portproxy add v4tov4
command with the appropriate addresses and ports.
Steps:
- Open an elevated command prompt: You need administrator privileges to use
netsh
. - Determine the old and new IP addresses and ports: Identify the IP address and port you want to forward from and the IP address and port you want to forward to.
- Add the port proxy rule: Use the following command, replacing the placeholders with your actual values:
netsh interface portproxy add v4tov4 listenport=<old_port> listenaddress=<old_ip> connectport=<new_port> connectaddress=<new_ip>
For example, if you want to forward all traffic from 192.168.1.100 om port 443 to 192.168.1.200, the command would be:
netsh interface portproxy add v4tov4 listenport=443 listenaddress=192.168.1.100 connectport=443 connectaddress=192.168.1.200
You can change source to destination port in this example port 8080 to 80:
netsh interface portproxy add v4tov4 listenport=8080 listenaddress=192.168.1.100 connectport=80 connectaddress=192.168.1.200
You can verify the rule creation :
netsh interface portproxy show all
To get all the option and syntax including deletion :
netsh interface portproxy /?
Make sure you firewall is open for incoming traffic, in this example , we need to allow port 8080:
netsh advfirewall firewall add rule name="8080 port in" protocol=TCP dir=in localport=8080 action=allow
Make sure it is listening on that port now
netstat -noa|find "8080"
This way you can re-route all traffic from one IP to new one. I find it very particle when moving or changeing IIS server location or IP .
Remember to add rule for each port you want to re-route.
Good Luck