Windows OS Hub
  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2012
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Group Policies
  • Windows Clients
    • Windows 10
    • Windows 8
    • Windows 7
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
  • PowerShell
  • Exchange

 Windows OS Hub / Windows 10 / Changing the Default Remote Desktop (RDP) Port 3389 in Windows

October 28, 2019 Windows 10Windows Server 2016

Changing the Default Remote Desktop (RDP) Port 3389 in Windows

In all Windows operation systems the default port assigned to RDP (Remote Desktop Protocol) is TCP 3389.

If your computer is connected to the Internet directly (e. g., a VDS/VPS server) or you have configured port forwarding of 3389/RDP port on your edge router to a Windows computer (server) in the local network, you can change the default 3389/RDP port to any other. By changing the RDP port number, you can hide your RDP server from port scanners, reduce the possibility of exploiting RDP vulnerabilities (the last known vulnerability in RDP BlueKeep is described in CVE-2019-0708), reduce the number of RDP brute force attacks (don’t forget to regularly analyze RDP connection logs), SYN and other attacks (especially, when NLA is disabled).

You can change the default RDP port when a router with one white IP address is used by multiple computers running Windows to which you need to provide external RDP access. You can configure a unique RDP port on each computer and configure port forwarding (PAT) to local computers on your router (depending on the RDP port number, the remote session is forwarded to one of the internal computers).

When choosing a non-standard RDP port, please note that it is not recommended to use port 1-1023 (known ports) and dynamic RPC port range 49152-65535.

Let’s try to change the port of Remote Desktop service to 1350. To do it:

  1. Open the Registry Editor and go to the registry key HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp;
  2. Find the DWORD parameter with the name PortNumber. This parameter shows the port, on which the Remote Desktop service is listening;
  3. Change the value of this parameter. I have changed the RDP port to 1350 (Decimal); registry set rdp Port Number in windows 10
    You can change the registry parameter using PowerShell: Set-ItemProperty -Path "HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\" -Name PortNumber -Value 1350
  4. If Windows Firewall is enabled on your computer, you will have to create a new rule that allows inbound connection to your new RDP port. (If you reconfigure a remote server through RDP without creating the rule for your firewall, you will lose access to your server.) You can create an allowing inbound rule for your new TCP/UDP RDP port manually in Windows Defender Firewall console (firewall.cpl) or using PowerShell cmdlets from the NetSecurity module:New-NetFirewallRule -DisplayName "New RDP Port 1350" -Direction Inbound -LocalPort 1350 -Protocol TCP -Action allowNew-NetFirewallRule -DisplayName "New RDP Port 1350" -Direction Inbound -LocalPort 1350 -Protocol UDP -Action allow New-NetFirewallRule - allow incoming new rdp port connections
  5. Restart your computer or restart your Remote Desktop service with this command: net stop termservice & net start termservice
  6. To connect to this Windows computer via RDP, you have to specify the new RDP connection port in your mstsc.exe client using the colon as follows: RDPComputerName:1350 or by IP address: 192.168.1.10:1350 or from the command prompt: mstsc.exe /v 192.168.1.10:1350 mstsc connect to non-standart RDP port

    If you are using RDCMan to manage multiple RDP connections, you can specify the RDP port you have configured in the Connection Settings tab. rdcman - change default rdp port 3389
  7. Then you will successfully connect to the remote desktop of a computer using the new RDP port. You can use the netstat –na | Find “LIST” command to make sure that your RDS is listening on another port. nestat find new rdp port number
Note: If you change the default RDP listening port number, you may have some troubles with using Remote Assistance and shadow RDP connections in Windows 10, as well as RDS shadowing on Windows Server.

The full PowerShell script to change the RDP port number, create the firewall rule and restart the Remote Desktop service on the new port may look like this:

Write-host "Specify the number of your new RDP port: " -ForegroundColor Yellow -NoNewline;$RDPPort = Read-Host
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-TCP\" -Name PortNumber -Value $RDPPort
New-NetFirewallRule -DisplayName "New RDP Port $RDPPort" -Direction Inbound –LocalPort $RDPPort -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "New RDP Port $RDPPort" -Direction Inbound –LocalPort $RDPPort -Protocol UDP -Action Allow
Restart-Service termservice -force
Write-host "The number of the RDP port has been changed to $RDPPort " -ForegroundColor Magenta

You can change the RDP number remotely on multiple computers in your AD domain (in the specific OU) using Invoke-Command and Get-ADComputer cmdlets:

Write-host "Specify the number of your new RDP port: " -ForegroundColor Yellow -NoNewline;$RDPPort = Read-Host
$PCs = Get-ADComputer -Filter * -SearchBase "CN=IT,CN=Computers,CN=NY,DC=woshub,DC=com"
Foreach ($PC in $PCs) {
Invoke-Command -ComputerName $PC.Name -ScriptBlock {
param ($RDPPort)
Set-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-TCP\" -Name PortNumber -Value $RDPPort
New-NetFirewallRule -DisplayName "New RDP Port $RDPPort" -Direction Inbound –LocalPort $RDPPort -Protocol TCP -Action Allow
New-NetFirewallRule -DisplayName "New RDP Port $RDPPort" -Direction Inbound –LocalPort $RDPPort -Protocol TCP -Action Allow
Restart-Service termservice -force
}

This guide to change the standard RDP port is suitable for any Windows version starting from Windows XP (Windows Server 2003) and up to modern Windows 10  / Windows Server 2019 builds.

0 comment
2
Facebook Twitter Google + Pinterest
previous post
Error Code: 0x80070035 “The Network Path was not found” after Windows 10 Update
next post
How to Measure Storage Performance and IOPS on Windows?

Related Reading

How to Disable NetBIOS and LLMNR Protocols in...

April 9, 2021

Enable Windows Lock Screen after Inactivity via GPO

April 8, 2021

How to Create and Manage Scheduled Tasks with...

April 7, 2021

Updating Windows VM Templates on VMWare with PowerShell

April 5, 2021

Running Multiple IIS Websites on the Same Port...

April 1, 2021

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange
  • Windows 10
  • Windows 8
  • Windows 7
  • Windows Server 2016
  • Windows Server 2012 R2
  • Windows Server 2008 R2
  • PowerShell
  • VMWare
  • MS Office

Recent Posts

  • How to Disable NetBIOS and LLMNR Protocols in Windows Using GPO?

    April 9, 2021
  • Enable Windows Lock Screen after Inactivity via GPO

    April 8, 2021
  • How to Create and Manage Scheduled Tasks with PowerShell?

    April 7, 2021
  • Updating Windows VM Templates on VMWare with PowerShell

    April 5, 2021
  • Running Multiple IIS Websites on the Same Port or IP Address

    April 1, 2021
  • Can’t Copy and Paste via Remote Desktop (RDP) Clipboard

    March 31, 2021
  • UAC: This App Has Been Blocked for Your Protection on Windows 10

    March 30, 2021
  • How to Unlock a File Locked by Any Process or SYSTEM?

    March 29, 2021
  • Configuring a Domain Password Policy in the Active Directory

    March 26, 2021
  • Using Native Package Manager (WinGet) on Windows 10

    March 24, 2021

Follow us

woshub.com
  • Facebook
  • Twitter
  • RSS
Popular Posts
  • How to Allow Multiple RDP Sessions in Windows 10?
  • How to Repair EFI/GPT Bootloader on Windows 10?
  • How to Restore Deleted EFI System Partition in Windows 10?
  • Network Computers are not Showing Up in Windows 10
  • Booting Windows 7 / 10 from GPT Disk on BIOS (non-UEFI) systems
  • Removable USB Flash Drive as Local HDD in Windows 10 / 7
  • How to Create a Wi-Fi Hotspot on your Windows 10 PC
Footer Logo

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


Back To Top