Windows OS Hub
  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux
  • Home
  • About

Windows OS Hub

  • Windows
    • Windows 11
    • Windows 10
    • Windows Server 2025
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
  • Microsoft
    • Active Directory (AD DS)
    • Group Policies (GPOs)
    • Exchange Server
    • Azure and Microsoft 365
    • Microsoft Office
  • Virtualization
    • VMware
    • Hyper-V
    • Proxmox
  • PowerShell
  • Linux

 Windows OS Hub / Windows 11 / Configure Port Forwarding in Windows Using Netsh

November 17, 2026

Configure Port Forwarding in Windows Using Netsh

All versions of Windows include a built-in feature that can be used to redirect incoming traffic from one TCP port to another port on the same computer or to an IP address of another (remote) host. This feature is known as port forwarding or port redirection.

It is commonly used to bypass firewalls or to create NAT/PAT (Network/Port Address Translation) rules which redirect traffic from an external IP address to other machines on the LAN. In this article, we’ll look at how to configure port forwarding in Windows using the built-in netsh interface portproxy command.

Contents:
  • How to Enable Port Forwarding on Windows with Netsh Portproxy
  • Managing Netsh Port Forwarding Rules in Windows
  • Port Forwarding with NAT Rules on Hyper-V
  • UDP Port Forwarding in Windows

In the Linux world, port forwarding is relatively easy to configure using iptables or firewalld rules. In Windows Server environments, port forwarding is typically configured using the Routing and Remote Access Service (RRAS) feature. Here, we’ll look at a simple, universal netsh portproxy mode that works on both Windows Server and Windows 10/11.

How to Enable Port Forwarding on Windows with Netsh Portproxy

You can configure port forwarding in Windows using the Portproxy mode of the Netsh command.

The command syntax is:

netsh interface portproxy add v4tov4 listenaddress=localaddress listenport=localport connectaddress=destaddress connectport=destport
where

  • listenaddress and listenport – the local IP address and TCP port number that will listen for incoming connections. To listen on all interfaces of the computer, specify 0.0.0 as the listen address. If the computer has multiple network adapters in different subnets/VLANs or multiple IP addresses assigned to the same interface, you can specify the IP address of a specific adapter.
  • connectaddress and connectport – the local or remote IP address and TCP port to which traffic received on listenport should be forwarded. If you specify a DNS name in the connectaddress, it will be resolved into an IP address when the rule is initialized.
Important. This port forwarding only works for TCP ports. You won’t be able to forward UDP ports this way. The localhost address (127.0.0.1) cannot be used as the connection address.

Let’s suppose you want the RDP service to listen on a non-standard port, for example, 3340. To do this, you will need to create a port forwarding rule that redirects incoming traffic on TCP port 3340 to the default RDP port number (3389).

First, make sure that the port number you plan to specify as listenport is not already in use by another service or process:

netstat -na|find "3340"

check local listening state on windows 10

Then open a command prompt as an administrator and run the following command:

netsh interface portproxy add v4tov4 listenport=3340 listenaddress=0.0.0.0 connectport=3389 connectaddress=10.1.1.110

The 0.0.0.0 address indicates that the computer is accepting connections on all its network interfaces and forwarding them to the specified IP address and port. Or you can specify the IP address of the listening interface.

windows port forwarding rule using netsh interface portproxy add

Make sure that the IP Helper service (iphlpsvc) is enabled on Windows. This Windows service must be running for port forwarding to work.

Check the status of the service in the services.msc console or using the PowerShell command:

Get-Service iphlpsvc

 iphlpsvc (IP Helper) service

Additionally, the IPv6 protocol support must be enabled on the network interface on which the port forwarding rule is being created

ipv6 protocol enabled

Using the netsh interface portproxy add v4tov6/v6tov4/v6tov6 options, you can create port forwarding rules between IPv4 and IPv6 addresses.
To make port forwarding work on Windows Server 2003/XP, you must additionally set the IPEnableRouter parameter to 1 under the registry key HKEY_LOCAL_MACHINE\ System\CurrentControlSet\services\Tcpip\Parameter. You can set this registry item using PowerShell:

Set-ItemProperty -Path HKLM:\system\CurrentControlSet\services\Tcpip\Parameters -Name IpEnableRouter -Value 1

This option also enables routing between different subnets in Hyper-V.

Now, use the netstat command to check that Windows is now listening on local port 3340:

netstat -ano | findstr :3340

netstat -ano - Get process PID

Now, let’s use PowerShell to find out which process is listening on the new port:

Get-Process -Id (Get-NetTCPConnection -LocalPort 3340).OwningProcess

get process listening port

This is the svchost process.

Next, create a rule in the Windows Firewall (or another firewall installed on your system) to accept connections to the new port. You can add a new inbound allow rule to Windows Defender Firewall with the command:

netsh advfirewall firewall add rule name="forwarded_RDPport_3340" protocol=TCP dir=in localip=10.1.1.110  localport=3340 action=allow

Or using the New-NetFirewallRule PowerShell cmdlet:
New-NetFirewallRule -DisplayName "forwarder_RDP_3340" -Direction Inbound -Protocol TCP –LocalPort 3340 -Action Allow

Check whether this port can now be accessed remotely by using the Test-NetConnection PowerShell cmdlet:

Test-NetConnection -ComputerName mywin11pc -Port 3340

Now try to connect to the new port from a remote computer using any RDP client. You need to specify 3340 as the RDP port number. port number is specified after a colon following the RDP server address. For example, 10.10.1.110:3340

RDP client connect to different port

The RDP connection should be established successfully.
If you want to forward an incoming TCP connection to another (remote) computer, use the following command:

netsh interface portproxy add v4tov4 listenport=3389 listenaddress=0.0.0.0 connectport=3389 connectaddress=192.168.100.101

This rule will redirect all incoming RDP traffic (from local TCP port 3389) on this computer to a remote host with the IP address 192.168.1.100.

Note that the portproxy mode in Windows doesn’t support saving the source IP in a forwarded network packet. Those, if you forward port 443 from a Windows device to an internal web server, then all incoming connections will appear on the destination web server as coming from the same IP address (the Windows computer with netsh portproxy enabled). If you need to preserve the source IP address when forwarding traffic, you should use NAT on an external firewall or on Hyper-V (described below).

Also, you can use SSH tunnels to forward a local port to a remote server in Windows.

Managing Netsh Port Forwarding Rules in Windows

You can create any number of port forwarding rules in Windows. All netsh interface portproxy rules are persistent and remain in the system after a computer reboot

These rules are stored in the registry. You can retrieve a list of port forwarding rules from the registry using PowerShell:

Get-ItemProperty -Path HKLM:\SYSTEM\CurrentControlSet\Services\PortProxy\v4tov4\tcp

get portproxy rules list from windows registry

To list all enabled TCP port forwarding rules in Windows, run the command:

netsh interface portproxy show all

Display all port forward rules

Tip. You can also list all configured port forwarding rules in portproxy as follows:

netsh interface portproxy dump

#========================
# Port Proxy configuration
#========================
pushd interface portproxy
reset
add v4tov4 listenport=3340 connectaddress=10.1.1.110 connectport=3389
popd
# End of Port Proxy configuration

netsh interface portproxy dump

If you need to change the settings of an existing portproxy rule, use the following command:

netsh interface portproxy set v4tov4 listenport=3340 listenaddress=10.10.1.110 connectport=3300 connectaddress=10.10.1.110

In this example, we have changed the portproxy target port number to 3300.

change port forwarding rule netsh portproxy

To remove a specific port forwarding rule:

netsh interface portproxy delete v4tov4 listenport=3340 listenaddress=10.1.1.110

To remove all existing port mapping rules and completely clear the port forwarding rules table:

netsh interface portproxy reset

If you disable the portproxy rule, be sure to remove the remaining firewall rule as follows:

netsh advfirewall firewall del rule name="RDP_3340"

or remove the firewall rule using PowerShell:

Remove-NetFirewallRule -Name RDP_3340

If you have the Windows Subsystem for Linux (WSL) installed on your computer, you can use a simple PowerShell script to create a port forwarding rule for your WSL 2 virtual machine. A WSL 2 VM has its own virtual Ethernet adapter with a unique IP address. The following script automatically gets the IP address of the WSL machine and enables a port forwarding rule.

wsl --shutdown;
netsh interface portproxy reset;
$wsl_ipaddr = wsl -d Ubuntu-20.04 hostname -I;
netsh interface portproxy add v4tov4 listenport=443 listenaddress=0.0.0.0 connectport=443 connectaddress=$wsl_ipaddr ;
netsh interface portproxy show all;
exit;

Another implicit feature of PortProxy is that it can make any remote network service appear as though it is running locally. For example, you might want to forward connections from the local port 9090 to a remote HTTPS server (google.com:443)

netsh interface portproxy add v4tov4 listenport=9090 connectport=443 connectaddress=google.com protocol=tcp

Now, the Google search page will open if you go to http://localhost:9090/ in your browser (you can ignore the SSL_ERROR_BAD_CERT_DOMAIN error). So, even though the browser is accessing the local computer address, a page from an external web server opens.

portproxy: redirect local port to remote web service

Port forwarding can also be used to redirect a port from the external IP address of a physical NIC to a port of a virtual machine running on the same host. In Hyper-V, you can configure port forwarding on the virtual switch (see below).

Windows cannot forward a range of TCP ports. If you need to forward multiple ports, you will need to create multiple portproxy rules manually.

Port Forwarding with NAT Rules on Hyper-V

If you have installed the Hyper-V role on your computer (the Hyper-V feature can be installed on both Windows 10/11, Windows Server hosts, or you can use the free Windows Hyper-V Server), you can configure DNAT port forwarding rules on the Hyper-V switch using PowerShell.

Suppose you want to forward all HTTPS traffic received by your Hyper-V host to the IP address of a virtual machine running on that host. This can be configured using the Hyper-V StaticMapping commands.

Create a Hyper-V virtual switch:

New-VMSwitch -SwitchName NAT_Switch -SwitchType Internal

create hyperv nat switch using powershell

Set the IP address for the new virtual switch:

New-NetIPAddress -IPAddress 192.168.100.1 -PrefixLength 24  -InterfaceAlias "vEthernet (NAT_Switch)"

Enable NAT for this network:

New-NetNat -Name NATNetwork -InternalIPInterfaceAddressPrefix 192.168.100.0/24

Connect the VM to your NAT_Switch and assign it a static IP address (for example, 192.168.10.80). In the virtual machine’s network settings, set the IP address of the Hyper-V virtual switch as the default gateway (192.168.100.1 in this case).

Next, enable HTTPS port forwarding from the Hyper-V host to the virtual machine:

Add-NetNatStaticMapping -NatName NATNetwork443 -Protocol TCP  -ExternalIPAddress 0.0.0.0/24  -ExternalPort 443  -InternalIPAddress 192.168.10.80  -InternalPort 443

After running these PowerShell commands, all HTTPS traffic that comes to the TCP/443 port of the Hyper-V host will be forwarded to the virtual machine’s IP address.

If you want to create a port forwarding rule for a non-standard port, don’t forget to open it in the Windows Firewall:

New-NetFirewallRule -DisplayName "HyperV_Nat_444" -Direction Inbound -LocalPort 444 -Protocol TCP -Action Allow -Enabled True

List all NAT/PAT port forwarding rules on a Hyper-V host:

Get-NetNat

UDP Port Forwarding in Windows

The netsh portproxy mode cannot be used to forward UDP traffic. If you need to enable UDP traffic forwarding, you can use Windows Server with the RRAS and NAT roles. You can configure UDP port forwarding using the RRAS graphical management console (rrasmgmt.msc) or with the following command:

netsh routing ip nat add portmapping Ethernet udp 0.0.0.0 53 192.168.1.54 53

The list of NAT port forwarding rules in Windows Server can be listed as follows:

netsh routing ip nat show interface

UDP ports can be forwarded using the lightweight 3proxy proxy server tool. The following 3proxy config example forwards inbound UDP traffic from port 3340 to port 3389.

udppm -s -i0.0.0.0 3340 192.168.1.54 3389

35 comments
15
Facebook Twitter Google + Pinterest
PowerShellWindows 10Windows 11Windows Server 2022
previous post
Get-ADComputer: Find Computer Properties in Active Directory with PowerShell
next post
Invoke-WebRequest: Perform HTTP Requests, Download Files, Parse Web with PowerShell

Related Reading

How to Repair EFI/GPT Bootloader on Windows 10...

March 16, 2024

How to Restore Deleted EFI System Partition in...

July 21, 2026

How to Allow Multiple RDP Sessions on Windows...

April 28, 2026

How to Run Program without Admin Privileges and...

June 8, 2023

How to Install RSAT (Remote Server Administration Tools)...

November 25, 2026

Wi-Fi (Internet) Disconnects After Sleep or Hibernation on...

March 15, 2024

How to Repair Windows Boot Manager, BCD and...

March 11, 2024

PowerShell: Get Folder Size on Windows

August 21, 2026

35 comments

Port Forwarding in Windows | Windows OS Hub | W... March 13, 2015 - 1:15 pm

[…] In Microsoft Windows, starting from Windows XP, there is a built-in ability to set up network ports forwarding (port forwarding). Due to it, any connection  […]

Reply
Dagg July 1, 2020 - 10:58 am

Man you saved my life! I have spent literally weeks for several sites that we host, trying everything. Looks like Windows Server 2016 isn’t best suited for hosting files outside .asp file domain (Node.js for example).

Reply
George May 13, 2015 - 2:18 am

Hi, this is a good article.
I would like to ask if there is any mechanism to not only forward  but also to copy data? For example, my server listen to TCP port 8845 and will do something when data comes in. I want to keep the original structure but in addition, to copy all coming data and then forward to another server via TCP port 8844. I know to write some codes can do it, but is there any built-in function in Windows Server 2012 can perform this?
Thank you.
George
 

Reply
Max May 13, 2015 - 10:10 am

Do you mean that some application on server processes some way the incoming network data and sends them over the network to another host or modified data is stored locally?

Reply
George May 14, 2015 - 12:29 am

My scenario is: I have a server A to listen TCP 8845 port. There is a program installed in server A to process data when it detects data comes in. What I want to do is to keep the structure in server A, but make a copy to the original incoming data and then send it to server B using TCP 8844 port from server A.
I know we can just write a program to do it, but I want to know if there is any built-in functions in Windows Server 2012 can fulfill my demands.
Thanks.

Reply
Micah Hoover April 7, 2016 - 3:51 pm

You have to use rewrites. The easiest way I could do this was to set up an IIS server, download and install ARR, then configure AAR and “URL Rewrite” in the IIS Manager. Took about a day for a software engineer (sys admin novice) to do it and get everything straightened out.

Reply
Matt November 18, 2015 - 1:31 am

Great write up!!!  Do you know if connections going through the forwarded ports count towards the Windows 7 client connection limit of 20 concurrent connections?  I’m looking to forward some traffic on my network so I can easily run scripts to redirect it if a downtime occurs but I need to know if I’m going to hit an upper limit of concurrent connections.  THANKS!

Reply
jt November 25, 2015 - 12:40 am

thank you so so so so so much youjust saved me 8 hours of driving back to a computer i forgot

Reply
MV January 19, 2016 - 4:45 pm

Excellent article. 
I would like to isolate all incoming traffic destined for port 80 to say port 8080. But all locally originated traffic for port 80 as it is. Could you please let me know how this is possible (if at all) in WINDOWS server ?

Reply
admin February 3, 2016 - 6:33 am

Try to use the following command:
netsh interface portproxy add v4tov4 listenport=80 listenaddress=127.0.0.1 connectport=8080 connectaddress=127.0.0.1

Reply
Rob Evans June 24, 2021 - 9:40 am

You create a proxy for the LAN IP as the listenaddress and listenport=80 and then set the destination connectaddress=localhost connectport=8080

Then whenever you connect via localhost:80 you will go through to localhost:80 but if you connect externally via the LAN IP port 80 you will be connected to localhost:8080

Reply
zeyad February 4, 2016 - 5:01 pm

Hi ,
i don’t understand how to forward the port ( 80 for examble ) to any ip and port .

Reply
admin February 5, 2016 - 4:39 am

Use following sintax:

netsh interface portproxy add v4tov4 listenaddress=[your_local_ip_adress] listenport=80 connectaddress=[any_ip_adress] connectport=[any_tcp_port]

For example,

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

 

Reply
jb March 11, 2016 - 8:48 pm

Thanks for this write-up!  Been trying to figure out a particularly problematic issue with a legacy application and hoping maybe this can help.
Can this be used to redirect traffic originating on the local machine and directed to a particular IP address to instead send it to a different IP?  For example, I have an application that is hard-coded to seek data in an archive at IP x.x.x.10, but the data has been moved and now resides at x.x.x.20 (and I can’t just re-IP the new archive location to make it x.x.x.10).  Any thoughts on how to get the application’s requests, even though coming out of the application addressed to x.x.x.10, to instead be redirected and sent to x.x.x.20?  Hope this makes sense…

Reply
ILGUIZ July 15, 2016 - 9:55 pm

Thanks for the quick and nice article.  The double quotes in the firewall command appear unicode not ascii.  My command line shell accepts both but makes the two names different.

Reply
Sean Vreeland August 1, 2016 - 12:49 am

THIS IS A GREAT WRITEUP!
However, question:
1) Does this work with IPv6?
2) When I’m connected to my VPN (w/ IPv6 enabled, all the ports that I have opened at my router and Win Firewall are now closed, eventho it says “listening on 0.0.0.0”.  So, do I need to forward the ports from 0.0.0.0 to the Local LAN adapter, or from the IP address of the VPN adapter to the local LAN adapter?  Kinda confused about this. 
Thanks!

Reply
Pete October 13, 2021 - 2:53 pm

Hi, regarding the second question, have you resolved it yet ? If it helps, my setup is a vpn and then trying to redirect to a virtualbox vm. Locally on the host server it works, but incoming traffic from vpn, is not connecting. Any suggestions?

Reply
admin October 26, 2021 - 11:31 am

UDP ports are commonly used for VPN traffic. You cannot forward UDP port using netsh interface portproxy...

Reply
Tony September 16, 2016 - 1:18 pm

Is there any effective way to adjust Windows Firewall to whitelist IP addresses to the ports created with portproxy?  My WF rules seem to have no effect.

Reply
nomadewolf September 20, 2016 - 3:49 pm

i want to redirect traffic that goes from a local app to a specific remote address and force it to go to a specific port:
i tried something like:
netsh interface portproxy add v4tov4 listenaddress=[remote_address] connectport=[port_i_want_to_forward_to] connectaddress=[remote_address]
can i do something like this?

Reply
ted October 19, 2016 - 7:56 am

Very good post !! Thank you

Reply
Carlos February 16, 2017 - 6:25 pm

Hi
Could I redirect 80 or 53 to other server?
Ex. My oficial site is hosted in a linux server with the same DNS name at AD server.
If I use primary DNS from AD server on stations, I can’t open my site and applicatons throug DNS hosted on second server.

Thanks

Reply
admin February 22, 2017 - 7:28 am

Hi
I did not understand, do you want to forward HTTP connections for internal clients from AD server to Linux?

PS. You can forward this way only TCP connections (DNS work over UDP potocol).

Reply
Jason April 11, 2017 - 10:06 am

You are a legend. Thanks for the great article worked like a charm!

Reply
Can I configure the Windows hosts file to use IP address plus port? – Blog SatoHost July 7, 2018 - 4:25 pm

[…] Windows Port Forwarding Example […]

Reply
pavan June 12, 2019 - 8:35 pm

Thanks . This is very useful.

It worked for me

Reply
Jasper November 2, 2019 - 7:01 am

Excellent article on the topic. We have In The Netherlands static IP addresses so a DNS is not necessary. But with some routers here (KPN Experia box) . you need to port forward on 2 different places within the router and that can be a real challenge.

Reply
Johny September 1, 2020 - 10:27 pm

Hello i cant enter pc remotely with any domain accaunt, when i wanna try show error, “Logon attemp failed, or incorrect user amd password” but username and password are correct

Reply
Patricia March 19, 2021 - 11:47 pm

Thanks so much for this amazing article! I got the necessary insight into the way port forwarding works in Windows. I’m used to work with firewalld rules in Linux and now I was faced with a Windows (19 Server) installation… didn’t quite know where to start or what to do. I appreciate it.

Reply
jimbobmcgee December 22, 2021 - 12:20 am

Do you know if the client’s original source IP/port is maintained when portproxy is used?

Many proxies I’ve worked with in the past will source-NAT the traffic so that the return path is maintained, but this can play havoc with fail2ban-type systems that block IPs on failed authentications (because the receiving service sees the proxy as the client, and so blocks the proxy IP, effectively blocking all future connections).

Was wondering if proxyport suffered from this (and, if so, what IP/port does it translate source to)?

Reply
Using port number in Windows host file – w3toppers.com June 20, 2022 - 11:32 pm

[…] Windows Port Forwarding Example […]

Reply
Rob November 2, 2022 - 12:03 pm

you save my live !

Reply
Gustavo March 1, 2023 - 11:02 am

Hi,
thank you for your article.
I’ve a new situation. usually I used this logic to redirect connections from my internal LAN to my website (running outside) that is the same as my internal domain, as example here, test.com

So, my AD domain is: test.com.
My local AD IP Address is: 10.0.0.10
My website running outside are running under the ip, as example, 200.200.200.200
Because in the LAN, if someone pings test.com, the return is not 200.200.200.200 but 10.0.0.10, as that is the IP Address of the Domain Controller.

So, usually I used this rule to redirect the requests:

netsh interface portproxy add v4tov4 listenport=80 listenaddress=10.0.0.10 connectport=80 connectaddress=200.200.200.200
netsh interface portproxy add v4tov4 listenport=443 listenaddress=10.0.0.10 connectport=443 connectaddress=200.200.200.200

For some reason, in 2 different networks, with 2 different domains, this rule is not working anymore.

Also, I did this but this, not working:
New-NetFireWallRule -DisplayName ‘Redirect 80-443′ -Direction Outbound -LocalPort @(’80’,’443′) -Action Allow -Protocol TCP
New-NetFireWallRule -DisplayName ‘Redirect 80-443′ -Direction Inbound -LocalPort @(’80’,’443′) -Action Allow -Protocol TCP

suggestions

Reply
mdidier9 August 9, 2023 - 10:02 pm

Hi
I want to forward pptp port for a vpn with my company public ip.

How to do it ?
Thanks

Reply
srg June 11, 2024 - 2:51 pm

netsh’s port proxy is handled by an “IP Helper” service (iphlpsvc).
If the port proxy connection is not working, restart this service.

Reply

Leave a Comment Cancel Reply

join us telegram channel https://t.me/woshub
Join WindowsHub Telegram channel to get the latest updates!

Recent Posts

  • Managing PowerShell Modules in Windows: Install, Update & Remove

    November 24, 2026
  • Windows Installer Folder Too Large? How to Clean Up Safely

    November 12, 2026
  • Shrink WSL2 and Docker Desktop VHDX Files in Windows

    November 11, 2026
  • We Can’t Sign In to Your Account: Fix Temporary User Profile in Windows

    October 20, 2026
  • Backup/Sync to Cloud Storage with Rclone on Windows

    October 9, 2026
  • Fix Missing “Yes” Button in User Account Control Prompt on Windows

    October 7, 2026
  • Block Specific Keyboard Shortcuts with Keyboard Filter on Windows

    October 3, 2026
  • How to Set Task Priority in Windows Task Scheduler

    September 22, 2026
  • AutoStart Program at RDP Logon in Windows RDS

    September 8, 2026
  • How to Convert Windows Machine into a Proxmox VM

    August 30, 2026

Follow us

  • Facebook
  • Twitter
  • Youtube
  • Telegram
Popular Posts
  • How to Hide (Block) a Specific Windows Update
  • Run Elevated Commands with Sudo on Windows 11
  • Fix: Slow Startup of PowerShell Console and Scripts
  • Automate Software and Settings Deployment with WinGet Configure (DSC)
  • How to Extract Printer Drivers from Windows
  • Backup/Sync to Cloud Storage with Rclone on Windows
  • Pin and Unpin Apps to Taskbar in Windows 11 via PowerShell
Footer Logo

@2014 - 2026 - Windows OS Hub. All about operating systems for sysadmins


Back To Top