WindowsFirewallRuleset

Monitoring Firewall

This document explains how to monitor Windows firewall and network activity on local system.
Note: all of these programs must be run as Administrator:

Table of Contents

Monitor your firewall like a pro

As you might already know, Windows firewall does not give us any easy to use tools to monitor what the firewall is doing.
However there are few programs and techniques available to monitor firewall activity in live.

Note that there isn’t an “All in one” solution, an ultimate program that does all the job. instead we have to deal with multiple tools, each specialized for certain purpose, if you’re serious you will need them all.

Some tools are easy to use, some require learning how to use them, some have graphical interface some are command line programs.
Some tools do the same job as other tools but complement missing features of other programs, while having other drawbacks.

For each program listed here you have a reference link (for tools built into Windows) and download link (for external programs).

All of the tools listed here are digitally signed, the only exceptions are as follows:

Table of Contents

Process Monitor

Alternate text

Download process monitor

Table of Contents

mTail

Alternate text

Download mTail

Table of Contents

mTail alternative

Alternate text

Table of Contents

Tailing logs standard alternative

Yet another standard and quick way to monitor logs is with PowerShell commands, ex:

Get-Content "%SystemRoot%\System32\LogFiles\Firewall\pfirewall.log" -Last 10 -Wait | Select-String "DROP"

Table of Contents

Event log

Alternate text

  1. Click on start and type: secpol.msc, right click and “Run as Administrator”
  2. If prompted for password, enter administrator password and click “Yes” to continue
  3. Expand node: “Advanced Audit Policy Configuration”
  4. Expand node: “System Audit Policies - Local Group Policy Object”
  5. Click on “Object Access”
  6. Double click “Audit Filtering Platform Packet drop”
  7. Check “Configure the following audit events”
  8. Check “Failure” and click OK to apply
  9. “Audit Filtering Platform Connection” (this is optional, it’s not recommend to enable this to reduce amount of data,
    and to focus on relevant, which is monitoring dropped packets)

To open Event viewer to monitor configured packet filtering events follow steps below:

  1. Click on start and type: compmgmt.msc, right click and “Run as Administrator”
  2. If prompted for password, enter administrator password and click “Yes” to continue
  3. Expand node: “Computer Management (Local)
  4. Expand node: “System Tools”
  5. Expand node: “Event Viewer”
  6. Expand node: “Windows Logs”
  7. Click on “Security”
  8. In the column “Task Category” look for “Filtering Platform Packet Drop”
  9. Click on individual event to see details about the event

Event logging reference

Table of Contents

WFP state and filter logs

Are you unable to figure out why your rules don’t work and why packets are dropped?
If so here is another powerful tool which will let you gather more information about specific firewall event.
click on image to enlarge:

Alternate text

Alternate text

Table of Contents

Windows Firewall

And of course we have Windows firewall.

Monitoring: (control panel firewall, Active store)

Alternate text

Management (Local group policy, GPO store)

Alternate text

To open GPO firewall follow steps below:

  1. Press Windows key and type: secpol.msc
  2. Right click on secpol.msc and click Run as administrator
  3. If prompted for password, enter administrator password and click “Yes” to continue
  4. Expand node: Windows Defender Firewall with Advanced Security
  5. Expand node: Windows Defender Firewall with Advanced Security - Local Group Policy Object
  6. Click on either Inbound, Outbound or Windows Defender Firewall... node

When you open GPO firewall first thing you should do is add columns that are by default not visible and remove those which are useless and only waste space, for example add:

Inside Config\System there is a Firewall.msc settings file, which saves you from doing these things every time you open GPO firewall, you can customize it and re-save your preferences.

Table of Contents

TCP View

TCP view is another tool that wil let you see which programs are listening on which ports on local system

Alternate text

Download TCPView

Table of Contents

netstat

Alternate text

A few useful commands are as follows:

Show all TCP connections and executables involved

netstat -obnq -p tcp

Show ICMP statistics:

netstat -s -p icmp

netstat reference

Table of Contents

Packet trace and analysis

In some special scenarios you might want to have much more power than what you have with firewall logs.

For example if you want to see ICMP traffic one way is to set firewall to log both allowed and dropped packets and then filter logs as needed, (ex. with filterline extension)

Other times you might want to analyse firewall or network performance.

To handle these and similar scenarios there is network capture and tracing solution.

To view and analyse an *.etl file you’ll need to install “Windows Performance Analyzer” which is availabe as an optional installment of Windows 10 SDK or Windows ADK

Once you install it and open ETL (Event Trace Log) file here is sample traffic analysis screenshot:

Alternate text

To generate an ETL file use “Windows Performance Recorder” which is part of same package in either Windows SDK or Windows ADK.

Other two (less useful) methods are described in two sections that follow in this guide.

Table of Contents

netsh trace

Alternate text

netsh trace option is similar to capturing “WFP state” and “Packet analysis” discused before.
There is no benefit to use this legacy program.

Here are few examples for netsh trace start

Capture UDP traffic where source or destination IP matches IPv4.Address value

netsh trace start capture=yes Ethernet.Type=IPv4 IPv4.Address=192.168.33.33 protocol=17 tracefile=c:\temp\trace.etl

Capture only ICMPv6 traffic

netsh trace start capture=yes protocol=58 tracefile=c:\temp\trace.etl

Capture all network traffic on a specific Network Interface and stop when capture file grows to 300 MB

netsh trace start capture=yes tracefile=c:\temp\trace.etl CaptureInterface="Ethernet interface" maxSize=300

To view status after running netsh trace run:

netsh trace show status

To stop tracing run:

netsh trace stop

For more information run:

netsh trace show capturefilterHelp

The meaning of options is as follows:

capture=yes|no

Specifies whether packet capturing is enabled in addition to tracing events.
The default is no

protocol

Specifies IP protocol for which to trace or capture traffic.
For valid values and their meaning see: Assigned Internet Protocol Numbers

traceFile=path/filename

Specifies the location and file name where to save the output.
The default is: %LOCALAPPDATA%\Temp\NetTraces\NetTrace.etl

persistent=yes|no

Specifies whether the tracing session resumes upon restarting the computer.
The default is no

fileMode=single|circular|append

Specifies which file mode is applied when tracing output is generated.
The meaning of options (probably) is as follows:

The default is circular

maxSize

Specifies maximum log file size in MB (Mega Bytes).\

To specify the maxSize=0, you must also specify filemode=single
If the value is set to 0, then there is no maximum.` The default value is 250.

overwrite=yes|no

Specifies whether an existing trace output file will be overwritten.

If parameter traceFile is not specified, then the default location and filename and any pre-existing version of the trace file is automatically overwritten.

Table of Contents

NetEventPacketCapture

NetEventPacketCapture is a PowerShell module that is a replacement for netsh trace

Almost everything netsh trace can do can be also done with NetEventPacketCapture module.

Inside Scripts\Experiment directory there are experimental Start-PacketTrace.ps1 and Stop-PacketTrace.ps1 scripts which make use of NetEventPacketCapture module, you can use them to quickly start and stop packet capture.

Keep in mind that both the netsh trace and NetEventPacketCapture generate an ETL file (Event Trace Log), problem in both cases is the lack of executable involved in traffic.

This problem can be solved with “Windows Performance Recorder” which generates required symbols.

NetEventPacketCapture reference

Table of Contents