0

First of all this does not contain my answer.

I want to find which firewall rule allows specific port 1433

In my server, Plesk has been installed and "MS SQL over TCP protocol" firewall rule is disabled. Somehow I can connect to the SQL Server from remote connection. There is one firewall rule allows 1433 TCP Connection but which one? Is there any command to find which firewall rule allows 1433.

Fatih TAN
  • 778
  • 1
  • 5
  • 23

2 Answers2

0

Source

Run as administrator

cls
Get-NetFirewallPortFilter | Where-Object { $_.LocalPort -Eq "1433" } | Get-NetFirewallRule |
Format-Table -Autosize -Property DisplayName,
@{Name='Protocol';Expression={($PSItem | Get-NetFirewallPortFilter).Protocol}},
@{Name='LocalPort';Expression={($PSItem | Get-NetFirewallPortFilter).LocalPort}},
@{Name='RemotePort';Expression={($PSItem | Get-NetFirewallPortFilter).RemotePort}},
@{Name='RemoteAddress';Expression={($PSItem | Get-NetFirewallAddressFilter).RemoteAddress}},
Enabled, Profile, Direction, Action
lptr
  • 1
  • 2
  • 6
  • 16
  • Result is MS SQL over TCP protocol TCP. However, Enabled property is False. So, This does not give me correct result. – Fatih TAN Feb 09 '20 at 12:25
  • Port configuration can get pretty complex, multiple rules in a string, like: "1433, 1434, 1435 - 1440". $_.LocalPort -Eq "1433" assumes a single port configuration. You might want to adjust the where condition $_.LocalPort -Eq "1433" to parse the value of $_.LocalPort, (split it by commas, create ranges if pairs are delimited by - and find if port 1433 is covered by any rule) – lptr Feb 09 '20 at 12:33
0

Easiest way to figure this out is through netevents.

  1. Start command line as administrator.
  2. Run netsh wfp cap start keywords=19
  3. Let the traffic flow through port 1433
  4. Run netsh wfp cap stop
  5. Open Wfpdiag.xml in Wfpdaig.cab generated by above step.
  6. Search for all NetEvents with <localPort>1433</localPort> and get filterId from <classifyAllow>
  7. Search for the filterId and the <displayData> should tell you which rule allowed the packet.
Goutham
  • 343
  • 2
  • 6