Pun*_*015 57
对数据库运行以下查询
select distinct local_net_address, local_tcp_port from sys.dm_exec_connections where local_net_address is not null
以上查询显示本地IP以及侦听端口号
Ank*_*ain 27
Open Run in your system
Type %windir%\System32\cliconfg.exe
Click on ok button then check an TCP ip pop-up is open
Highlight TCP/IP under the Enabled protocols window.
Click the Properties button.
Enter in the new port number, then click OK.
Run Code Online (Sandbox Code Playgroud)

小智 6
这个查询对我有用:
SELECT DISTINCT
local_tcp_port
FROM sys.dm_exec_connections
WHERE local_tcp_port IS NOT NULL
Run Code Online (Sandbox Code Playgroud)
PowerShell 解决方案显示主机上的所有实例及其传入流量地址。如果您只知道 DNS,第二部分可能会有所帮助:
ForEach ($SQL_Proc in Get-Process | Select-Object -Property ProcessName, Id | Where-Object {$_.ProcessName -like "*SQL*"})
{
Get-NetTCPConnection | `
Where-Object {$_.OwningProcess -eq $SQL_Proc.id} | `
Select-Object -Property `
@{Label ="Process_Name";e={$SQL_Proc.ProcessName}}, `
@{Label ="Local_Address";e={$_.LocalAddress + ":" + $_.LocalPort }}, `
@{Label ="Remote_Address";e={$_.RemoteAddress + ":" + $_.RemotePort}}, State | `
Format-Table
}
Run Code Online (Sandbox Code Playgroud)
要检查在所有端口上侦听的所有应用程序,请使用以下命令:
netstat -ntpl
Run Code Online (Sandbox Code Playgroud)