pktmon filter add

Applies to: Windows Server 2022, Windows Server 2019, Windows 10, Azure Stack HCI, Azure Stack Hub, Azure

Pktmon filter add allows you to add a filter to control which packets are reported. For a packet to be reported, it must match all conditions specified in at least one filter. Up to 32 filters can be active at once.


pktmon filter add <name> [-m <mac> [mac2]] [-v <vlan>] [-d { IPv4 | IPv6 | number }]
                         [-t { TCP [flags...] | UDP | ICMP | ICMPv6 | number }]
                         [-i <ip> [ip2]] [-p <port> [port2]] [-b] [-e [port]]

You may provide an optional name or description of the filter.


When two MACs (-m), IPs (-i), or ports (-p) are specified, the filter matches packets that contain both. It will not distinguish between source or destination for this purpose.


You can supply parameters for Ethernet frame, IP header, TCP/UDP header, cluster heartbeat, and encapsulation.

Parameter Description
-m, --mac[-address] Match source or destination MAC address. See note above.
-v, --vlan Match by VLAN ID (VID) in the 802.1Q header.
-d, --data-link[-protocol], --ethertype Match by data link (layer 2) protocol. Can be IPv4, IPv6, ARP, or a protocol number.
-t, --transport[-protocol], --ip-protocol Match by transport (layer 4) protocol. Can be TCP, UDP, ICMP, ICMPv6, or a protocol number. To further filter TCP packets, an optional list of TCP flags to match can be provided. Supported flags are FIN, SYN, RST, PSH, ACK, URG, ECE, and CWR.
-i, --ip[-address] Match source or destination IP address. See note above. To match by subnet, use CIDR notation with the prefix length.
-p, --port Match source or destination port number. See note above.
-b, --heartbeat Match RCP heartbeat messages over UDP port 3343.
-e, --encap Apply above filtering parameters to both inner and outer encapsulation headers. Supported encapsulation methods are VXLAN, GRE, NVGRE, and IP-in-IP. Custom VXLAN port is optional, and defaults to 4789.


The following set of filters will capture any ICMP traffic from or to the IP address along with any traffic on port 53.

C:\Test> pktmon filter add -i -t icmp
C:\Test> pktmon filter add -p 53

The following filter will capture all the SYN packets sent or received by the IP address

C:\Test> pktmon filter add -i -t tcp syn

The following filter called MyPing pings using the ICMP protocol:

C:\Test> pktmon filter add MyPing -i -t ICMP

The following filter called MySmbSyb captures TCP synchronized SMB traffic:

C:\Test> pktmon filter add MySmbSyn -i -t TCP SYN -p 445

The following filter called MySubnet captures traffic on the subnet mask, or /24 in CIDR notation:

C:\Test> pktmon filter add MySubnet -i

Other references