更改Windows上的远程桌面的侦听端口

《微软官网更改计算机上的远程桌面的侦听端口》

适用范围:Windows Server 2022、Windows 10、Windows 8.1、Windows 8、Windows Server 2019、Windows Server 2016、Windows Server 2012 R2、Windows Server 2008 R2

通过远程桌面客户端连接到计算机(Windows 客户端或 Windows Server)时,计算机上的远程桌面功能会通过定义的侦听端口(默认情况下为 3389)"侦听"连接请求。 可以通过修改注册表来更改 Windows 计算机上的侦听端口。

  1. 启动注册表编辑器。 (在"搜索"框中键入 regedit。)
  2. 导航到以下注册表子项:计算机\HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp
  3. 找到PortNumber修改端口号
  4. 单击"编辑">"修改",然后单击"十进制"。
  5. 键入新端口号,然后单击"确定" 。
  6. 关闭注册表编辑器,然后重新启动计算机。

下次使用远程桌面连接连接到此计算机时,必须键入新端口。 如果正在使用防火墙,请确保将防火墙配置为允许连接到新端口号。

可运行以下 PowerShell 命令来查看当前端口:

powershell 复制代码
Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp' -name "PortNumber"

例如:

powershell 复制代码
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 端口:

powershell 复制代码
$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
相关推荐
柳鲲鹏2 天前
编译Windows版本的zlib
windows
Name_NaN_None2 天前
安卓手机远程控制电脑方法(Android/Windows) —— 「小白教程」
android·windows·智能手机·电脑·笔记本
宝桥南山2 天前
Visual Studio - 记录一个Visual Studio 2026(Insiders)的更新问题
windows·microsoft·微软·.net·.netcore·visual studio
JosieBook2 天前
【鸿蒙开源】把 Windows 任务栏上的流量表搬到鸿蒙 PC:TrafficMonitor 1.86 的 C++ 内核移植实践
c++·windows·harmonyos
Vex2une3 天前
把 Windows 装进 U 盘随身携带:Windows To Go 现状与 WinToUSB 制作完全指南
windows·vhdx·windows to go·wintousb·便携windows·系统带进u盘·随身系统
无奈笑天下4 天前
Wine适配Windows程序常见故障标准处理流程
linux·运维·服务器·windows
广东程序猿小展4 天前
PotPlayer 播放 4K 视频卡顿怎么办(硬解与渲染设置)
windows·工具·软件
xx z4 天前
Radmin LAN 怎么联机(虚拟局域网建房与加入教程)
windows·工具·软件
广东程序猿小展4 天前
谷歌相机配置文件怎么导入(GCam 配置导入与不生效排查)
windows·工具·软件