To add a new RDP Port to the registry:
Open PowerShell with Administrator mode and run the below command to change your default RDP Port from 3389 to 9999.
PS C:\Windows\system32> $portvalue = 9999PS C:\Windows\system32> Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue
Allow to Firewall:
To Add this non-default firewall policy run the below command,
To Add this non-default firewall policy run the below command,
PS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Any' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvaluePS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Any' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
or,
PS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvaluePS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
or,
PS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Private' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvaluePS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Private' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
or,
PS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Private' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvaluePS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Private' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
Check the port status,
or,
PS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvaluePS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
or,
PS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Private' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvaluePS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Private' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
or,
PS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Private' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvaluePS C:\Windows\system32> New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Private' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue
Check the port status,
PS C:\Windows\system32> cmd /c 'netstat -ano | find "9999"'
To determine which application is using this port 9999, enter the following command,
To determine which application is using this port 9999, enter the following command,
PS C:\Windows\system32> cmd /c 'tasklist /svc | find "<pid listening on 9999>"'
If your organization uses an external firewall, you must also allow this port on that firewall.
If your organization uses an external firewall, you must also allow this port on that firewall.
Check whether a firewall is blocking the RDP port:
For Windows Clients,
PS C:\Windows\system32> psping -accepteula <RPD Server IP>:9999
For Linux Clients,
For Linux Clients,
[user@host ~]$ telnet <RPD Server IP> 9999
Comment if you find any problems.
Comments
Post a Comment