컴퓨터에서 원격 데스크톱의 수신 대기 포트 변경

적용 대상: Windows Server 2022, Windows 11, Windows 10, Windows Server 2019, Windows Server 2016

원격 데스크톱 클라이언트를 통해 컴퓨터(Windows 클라이언트 또는 Windows Server)에 연결할 때 컴퓨터의 원격 데스크톱 기능이 정의된 수신 포트(기본적으로 3389)를 통해 연결 요청을 "수신"합니다. 레지스트리를 수정하여 Windows 컴퓨터에서 해당 수신 포트를 변경할 수 있습니다.

  1. 레지스트리 편집기를 시작합니다. (검색 상자에 regedit을 입력합니다.)
  2. 다음 레지스트리 하위 키 로 이동합니다. HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
  3. PortNumber를 찾습니다.
  4. 편집 > 수정을 클릭하고 Decimal을 클릭합니다.
  5. 새 포트 번호를 입력하고 확인을 클릭합니다.
  6. 레지스트리 편집기를 닫고 컴퓨터를 다시 시작합니다.

다음번에 원격 데스크톱 연결을 사용하여 이 컴퓨터에 연결할 때 새 포트를 입력해야 합니다. 방화벽을 사용하는 경우 새 포트 번호로의 연결을 허용하도록 방화벽을 구성해야 합니다.

다음 PowerShell 명령을 실행하여 현재 포트를 확인할 수 있습니다.

Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"

예시:

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

다음 PowerShell 명령을 실행하여 RDP 포트를 확인할 수도 있습니다. 이 명령에서는 새 RDP 포트를 3390으로 지정합니다.

레지스트리에 새 RDP 포트를 추가하려면 다음을 수행합니다.

$portvalue = 3390

Set-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber" -Value $portvalue 

New-NetFirewallRule -DisplayName 'RDPPORTLatest-TCP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol TCP -LocalPort $portvalue 
New-NetFirewallRule -DisplayName 'RDPPORTLatest-UDP-In' -Profile 'Public' -Direction Inbound -Action Allow -Protocol UDP -LocalPort $portvalue