Filter syntax: names, PIDs, IP ranges, CIDR and ports
One small language aims the tool at programs, addresses and ports. It works the same in the window and on the command line, and every example on this page is checked against the program's own parser.
Where it is used
In the window: the target process field, the address and port fields under
Destination targeting and under Blocking (firewall), and the two payload size fields. On
the command line: --target,
--dst-ip, --dst-port, --block-ip,
--block-port, --payload-udp and --payload-tcp. An empty
field means everything.
Building blocks
| Write | It means | Example |
|---|---|---|
a,b,c | a list: any of them matches | 80,443 |
a-b | a range, both ends included | 10.0.0.1-10.0.0.50 |
> < >= <= | a comparison, for numbers and addresses | >1024 |
! | leave this out | !53 |
* ? | a wildcard: any run of characters, or one character | chrome* |
re: | a regular expression, case doesn't matter | re:^chrome\.exe$ |
a.b.c.d/n | a CIDR block, addresses only | 192.168.1.0/24 |
Spaces around commas are ignored, and so is an empty place between two commas. A
! with nothing after it is a mistake: 80,! is
refused.
How terms combine
The terms without ! add up: a value matches when any of them matches, or when
there are none. The terms with ! then take away. The order does not matter, so
80,!53 and !53,80 are the same.
| Write | It matches |
|---|---|
443 | port 443 only |
!53 | everything except 53, since there is nothing to add up |
!53,!443 | everything except 53 and 443 |
1000-2000,!1500 | 1000 to 2000, without 1500 |
80,443,8000-8100,>9000,!8080 | 80, 443, 8000 to 8100 and everything above 9000, except 8080 |
Programs
A term is a name or a PID, and one field may mix them. A plain name matches anywhere in the
program's name, without regard to case, so chrome catches
chrome.exe and chromedriver.exe. A bare number, a range or a comparison
is a PID. Wildcards and re: match the name. A comparison on a name, such as
>chrome, is refused rather than matching nothing.
| Write | It matches |
|---|---|
chrome.exe | every program with chrome.exe in its name |
chrome,!chromedriver | Chrome, but not chromedriver |
chrome.exe,firefox.exe | two programs at once |
12345 | one PID |
1000-2000 | every PID in that range |
firefox* | a name that starts with firefox |
re:^(chrome|firefox)\.exe$ | exactly chrome.exe or firefox.exe |
firefox,12345 | a name and a PID in one field |
A packet carries addresses and ports, never a program's name, so the tool finds the local ports each matching program holds and aims at those, and follows the new connections it opens. A few ports are shared by several programs at once (mDNS 5353, SSDP 1900, DHCP 67 and 68). On those it is all or nothing, and the log says which.
Addresses
IPv4 and IPv6 both work, and one field may mix them: a rule for one family never matches an
address of the other. How an address is written does not matter, so
2001:0db8:0000:0000:0000:0000:0000:0001 and 2001:db8::1 are the same
address.
| Write | It matches |
|---|---|
1.2.3.4,8.8.8.8 | two addresses |
10.0.0.1-10.0.0.50,!10.0.0.7 | a range with a hole |
192.168.1.0/24 | a whole subnet |
192.168.1.* | the same subnet, by wildcard |
!8.8.8.8 | every address except 8.8.8.8 |
2001:db8::/32 | an IPv6 subnet |
10.0.0.0/8,2001:db8::/32 | IPv4 and IPv6 in one field |
Ports
Ports go from 0 to 65535; 99999 is refused rather than
skipped. The payload size fields take the same syntax, counted in bytes of data.
| Write | It matches |
|---|---|
8000-8100 | a range, both ends included |
>1024 | the high ports |
<=1024 | the privileged ports |
80,443,8000-8100,!8080 | a mix |
Regular expressions
A term is a regular expression only with re: in front, so a dot in
chrome.exe stays a dot. The pattern ignores case and may match anywhere in the text;
use ^ and $ to match the whole of it. A comma inside a pattern needs a
backslash, because a comma separates terms: re:^ch.{1\,8}e\.exe$
works. Without the backslash, re:^ch.{1,8}e\.exe$ is cut at the comma into two
terms that both load and match something else.
A repeat inside a repeat, such as re:^(\w+)+$, is
refused as too slow: it can take seconds on one name that almost matches, and an address is
checked on every packet. Write the repeat once: re:^\w+$.
Cases that catch people out
chromecatches chromedriver, andchrome.exedoes not: a plain name is a piece of the name.chrome*also catches chromedriver. For exactly one program, writere:^chrome\.exe$.8*in a port field is a wildcard on the digits, so it catches 8, 80, 8080 and 8443, but not 443. You almost always meant a range such as8000-8999.!53also covers traffic with no port at all, such as ping, because a ping packet is not port 53.- An address and a port set together must both match. For one or the other, use two runs.
2000-1000, a range written backwards, is refused.- A wildcard is not a regular expression: in
re:chrome*the star repeats the letter e.
Every mistake is reported at once: the field in the window turns red with the reason under it, and the command line stops with a readable message.