Skip to content

Commit 36cc50b

Browse files
committed
docs
1 parent c2a18cd commit 36cc50b

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

usr.sbin/npf/npfctl/npf.conf.5

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,45 @@ syntax, for example:
311311
.Pp
312312
Fragments are not selectable since NPF always reassembles packets
313313
before further processing.
314+
.Ss User/group ID filtering
315+
.Pp
316+
NPF allows filtering by user or group identity. Packet filtering by user or group
317+
controls data packet flows based on the user or group identity of the process
318+
that generated the traffic, or is waiting to receive traffic,
319+
rather than just traditional parameters like IP address, port number, and protocol.
320+
.Pp
321+
There are many situations where this is useful:
322+
.Bl -bullet -hang
323+
.It Finer-grained access control
324+
One can allow specific destinations to be accessed only by certain users
325+
or groups.
326+
.It Application level security
327+
Two processes are using a specific port, but only one should be allowed to
328+
access packets originating from a particular host.
329+
.It Improves isolation in multi-tenant systems
330+
Prevent an untrusted user from making any network connections
331+
.It Security hardening and containment
332+
A user application that has been exploited can be prevented from making
333+
network connections to a command-and-control server.
334+
.It Compliance and policy enforcement
335+
Can restrict access to particular networks to network administrators only.
336+
.El
337+
This filtering process can be achieved by passing the user or group ID on the rule.
338+
.Pp
339+
.Dl pass out from all user jack group < 1000
340+
.Pp
341+
The above rule only allows sockets of processes owned by user jack
342+
and belonging to a group with an id value of less than 1000.
343+
.Pp
344+
.Dl block in from all user > 100 group wheel
345+
.Pp
346+
The above rule prevents all listening sockets bound by processes owned by any user
347+
with the id value greater than 100 and belonging to the wheel group.
348+
.Pp
349+
A rule can have either a user ID or group ID set. If both are set, both must
350+
agree to be a match to the socket involved in communication.
351+
Numbers or names can be used for the identification of the user or group as they
352+
still resolve to a numeric ID of the user or group.
314353
.Ss Stateful
315354
NPF supports stateful packet inspection which can be used to bypass
316355
unnecessary rule processing as well as to complement NAT.
@@ -620,11 +659,19 @@ proto-opts = "flags" tcp-flags [ "/" tcp-flag-mask ] |
620659
"icmp-type" type [ "code" icmp-code ]
621660
proto = "proto" protocol [ proto-opts ]
622661

623-
filt-opts = "from" filt-addr [ port-opts ] "to" filt-addr [ port-opts ]
662+
filt-opts = "from" filt-addr [ port-opts ] "to" filt-addr [ port-opts ] user_id group_id
624663
filt-addr = [ "!" ] [ interface | addr-mask | table-id | "any" ]
625664

626665
port-opts = "port" ( port-num | port-from "-" port-to | var-name )
627666
addr-mask = addr [ "/" mask ]
667+
668+
user_id = "user" id_items
669+
group_id = "group" id_items
670+
671+
id_items = [id] | [op_unary id] | [id op_binary id]
672+
673+
op_unary = ["="] | ["!="] | ["<="] | [">="] | [">"] | ["<"]
674+
op_binary = ["<>"] | ["><"]
628675
.Ed
629676
.\" -----
630677
.Sh FILES

0 commit comments

Comments
 (0)