Some Windows administrators often change the default RDP port (3389) to another port in order to prevent brute force attacks.
How do I change the RDP port using CMD?
In this tutorial we’ll teach you how to change the RDP access port with just 2 CMD commands.
First, let’s release the port in the Firewall with a command in CMD. start your system’s CMD and run the command below, by simply substituting localport=9999 for the new port you want to use to access. In our example, we’re going to allow access to port 9999:
netsh advfirewall firewall add rule name="Porta RDP" dir=in action=allow protocol=TCP localport=9999
Now, let’s actually change the RDP port with the command below. Remember that in our example we’re changing it to port 9999, so replace the number 9999 in the command below with the port you want:
reg add "HKLM\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-TCP" /v PortNumber /t REG_DWORD /d 9999 /f
Now just restart the operating system and start accessing through the new port.