When connect to a computer (either a Windows client or Windows Server) through the Remote Desktop
client, by default RDP
will listen on port 3389. This Port must open. And now we will custom change default port remote dekstop to other port.
Change via Registry Editor
We can change that listening port on Windows computers by modifying the registry.
- Start the registry editor. (Type regedit in the Search box.)
- Navigate to the following registry subkey: HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
- Find PortNumber
- Click Edit > Modify, and then click Decimal.
- Type the new port number, and then click OK.
- Close the registry editor, and restart your computer.
Ok finished. If we implement a windows firewall
, please check and add the newly created port number so that it can be accessed from outside.
Other Way, Change Via PowerShell.
You can check the current port by running command below on PowerShell.
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"
The Result is :
PortNumber : 3389
PSPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal
Server\WinStations\RDP-Tcp
PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal
Server\WinStations
PSChildName : RDP-Tcp
PSDrive : HKLM
PSProvider : Microsoft.PowerShell.Core\Registry
Change the RDP port by running the following PowerShell command. In this command, we’ll specify the new RDP port as 33890.
To add a new RDP Port to the registry:
Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value 33890
New-NetFirewallRule -DisplayName 'RDPPORTLatest' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort 33890
- First line, is set
RDP
port open in port 33890. - Second line, is set
firewall
allow/open incoming traffic to port 33890.
That is simple tips change default port remote dekstop. May be it’s helpful, please feel free to leave a comment if you have any questions and I’ll appreciate it.
source: microsoft.