当前位置:网站首页>There are many ways to confirm and modify the remote port number

There are many ways to confirm and modify the remote port number

2022-06-24 04:52:00 shawyang

How to confirm the remote port number , There are many ways , Here it is 3 Kind of

1、 Make sure the TermService Of pid, Re pass pid Confirm remote port

tasklist /svc|findstr "Term"

netstat -ano|findstr " Process number "

2、powershell To confirm , The principle is the same as above

$rdppid=(get-wmiobject win32_service | where { $_.name -eq 'termservice'}).processID

netstat -ano|findstr $rdppid|findstr LISTENING

3、Reg query To query ,16 Base number d3d yes 10 It's binary 3389

The resulting value is converted to 10 It can be done in decimal

set /a a=0xd3d

reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /s|findstr /c:"PortNumber" reg query "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /s|findstr /c:"PortNumber" reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Terminal Server\WinStations\RDP-Tcp" /s|findstr /c:"PortNumber" reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /s|findstr /c:"PortNumber" reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Terminal Server\WinStations\RDP-Tcp" /s|findstr /c:"PortNumber" reg query "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /s|findstr /c:"PortNumber"

How to modify a remote port number , There are many ways

1、 Refer to the Microsoft official website documentation :( apply 2008R2/Win7 The above system )

https://docs.microsoft.com/en-GB/windows-server/remote/remote-desktop-services/clients/change-listening-port

give an example , Change it to 33899

$portvalue = 33899

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、 adopt reg add Command to change

give an example , Change it to 33899

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber" /t REG_DWORD /d 33899 /f

reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v "PortNumber" /t REG_DWORD /d 33899 /f

reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber" /t REG_DWORD /d 33899 /f

reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v "PortNumber" /t REG_DWORD /d 33899 /f

reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Terminal Server\WinStations\RDP-Tcp" /v "PortNumber" /t REG_DWORD /d 33899 /f

reg add "HKEY_LOCAL_MACHINE\SYSTEM\ControlSet002\Control\Terminal Server\Wds\rdpwd\Tds\tcp" /v "PortNumber" /t REG_DWORD /d 33899 /f

3、 Reference resources 3389 Windows Remote port modification tool

All the methods , After changing the remote port , You need to restart the remote service

The command to restart the remote service is powershell -c "& { restart-service termservice -force}"

But restarting the remote service is prone to unexpected situations , That is, restarting the remote service is a process of first shutting down and then starting , It is similar to restarting the machine , It is the process of turning off the machine before turning it on , If the first half gets stuck , In the second half there was no way .

To make sure that there is no risk , It is recommended to restart the machine after modifying the remote port .

Restart after restart mstsc Pay attention to the slogan at the end , Yes, of course , If you don't understand mstsc, There is one Simple software ( It is essentially the bottom layer of the call mstsc), But it's very simple 、 To use , You can also remember the password on your local computer , In the future, you can double-click it to access it remotely , Very convenient .

原网站

版权声明
本文为[shawyang]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/09/20210901223646955n.html