首页 栏目5 远程桌面 端口 远程桌面端口修改

远程桌面 端口 远程桌面端口修改

在Windows10中更改默认的远程桌面(RDP)端口3389

在所有Windows操作系统中,分配给RDP(远程桌面协议)的默认端口为TCP 3389

如果您的计算机直接连接到Internet(例如VDS / VPS服务器),或者您已将边缘路由器上的3389 / RDP端口配置为端口转发到本地网络中的Windows计算机(服务器),则可以更改默认设置。 3389 / RDP端口可连接任何其他端口。通过更改RDP端口号,您可以对端口扫描程序隐藏RDP服务器,减少利用RDP漏洞的可能性(CDP-2019-0708中描述了RDP BlueKeep中的最后一个已知漏洞),减少了RDP暴力攻击的次数(不要忘记定期分析RDP连接日志),SYN和其他攻击(尤其是在禁用NLA时)。

当一台具有白色IP地址的路由器被运行Windows的多台计算机使用,而您需要向其提供外部RDP访问时,可以更改默认RDP端口。您可以在每台计算机上配置一个唯一的RDP端口,并配置到路由器上本地计算机的端口转发(PAT)(取决于RDP端口号,远程会话将转发到其中一台内部计算机)。

选择非标准RDP端口时,请注意,建议不要使用端口1-1023(已知端口)和动态RPC端口范围49152-65535

让我们尝试将远程桌面服务的端口更改为1350。去做吧:

  1. 打开注册表编辑器,然后转到注册表项HKEY_LOCAL_MACHINE \ System \ CurrentControlSet \ Control \ Terminal Server \ WinStations \ RDP-Tcp
  2. 找到名称为PortNumberDWORD参数。此参数显示远程桌面服务正在侦听的端口。
  3. 更改此参数的值。我已将RDP端口更改为1350(十进制);

您可以使用PowerShell更改注册表参数:Set-ItemProperty -Path &34;HKLM:\System\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp\&34; -Name PortNumber -Value 1350

如果计算机上启用了Windows防火墙,则必须创建一个新规则,以允许入站连接到新RDP端口。(如果通过RDP重新配置远程服务器而不创建防火墙规则,则将失去对服务器的访问权限。)您可以在Windows Defender防火墙控制台(防火墙)中为新的TCP / UDP RDP端口手动创建允许入站规则。 cpl)或使用NetSecurity模块中的 PowerShell cmdlet :New-NetFirewallRule -DisplayName &34;New RDP Port 1350&34; -Direction Inbound -LocalPort 1350 -Protocol TCP -Action allowNew-NetFirewallRule -DisplayName &34;New RDP Port 1350&34; -Direction Inbound -LocalPort 1350 -Protocol UDP -Action allow

使用以下命令重新启动计算机或重新启动远程桌面服务: net stop termservice & net start termservice

要通过RDP连接到此Windows计算机,您必须使用冒号在mstsc.exe客户端中指定新的RDP连接端口,如下所示:RDPComputerName:1350或通过IP地址:192.168.1.10:1350或从命令提示符下:mstsc.exe /v 192.168.1.10:1350

您将使用新的RDP端口成功连接到计算机的远程桌面。您可以使用该netstat –na | Find “LIST” 命令来确保您的RDS正在侦听另一个端口。

更改RDP端口号,创建防火墙规则并在新端口上重新启动远程桌面服务的完整PowerShell脚本如下所示:

Write-host &34;Specify the number of your new RDP port: &34; -ForegroundColor Yellow -NoNewline;$RDPPort = Read-Host

Set-ItemProperty -Path &34;HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-TCP\&34; -Name PortNumber -Value $RDPPort

New-NetFirewallRule -DisplayName &34;New RDP Port $RDPPort&34; -Direction Inbound –LocalPort $RDPPort -Protocol TCP -Action Allow

New-NetFirewallRule -DisplayName &34;New RDP Port $RDPPort&34; -Direction Inbound –LocalPort $RDPPort -Protocol UDP -Action Allow

Restart-Service termservice -force

Write-host &34;The number of the RDP port has been changed to $RDPPort &34; -ForegroundColor Magenta

您可以使用Invoke-Command和Get-ADComputer cmdlet 在AD域(在特定的OU中)的多台计算机上远程更改RDP编号:

Write-host &34;Specify the number of your new RDP port: &34; -ForegroundColor Yellow -NoNewline;$RDPPort = Read-Host

$PCs = Get-ADComputer -Filter * -SearchBase &34;CN=IT,CN=Computers,CN=NY,DC=woshub,DC=com&34;

Foreach ($PC in $PCs) {

Invoke-Command -ComputerName $PC.Name -ScriptBlock {

param ($RDPPort)

Set-ItemProperty -Path &34;HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-TCP\&34; -Name PortNumber -Value $RDPPort

New-NetFirewallRule -DisplayName &34;New RDP Port $RDPPort&34; -Direction Inbound –LocalPort $RDPPort -Protocol TCP -Action Allow

New-NetFirewallRule -DisplayName &34;New RDP Port $RDPPort&34; -Direction Inbound –LocalPort $RDPPort -Protocol TCP -Action Allow

Restart-Service termservice -force

}

该更改标准RDP端口的指南适用于从Windows XP(Windows Server 2003)开始以及最新的Windows 10 / Windows Server 2019内部版本的任何Windows版本。

版权声明:本网站内容来源于网络和互联网作者投稿,本站不享有任何版权,如有侵权请联系删除 QQ邮箱:11111111@.qq.com

作者: tiger

为您推荐

发表回复

您的电子邮箱地址不会被公开。 必填项已用 *标注