Print this page
11622 clean up rarer mandoc lint warnings
   1 '\" te
   2 .\" To view license terms, attribution, and copyright for IP Filter, the
   3 .\" default path is /usr/lib/ipf/IPFILTER.LICENCE. If the Illumos operating
   4 .\" environment has been installed anywhere other than the default, modify the
   5 .\" given path to access the file at the installed location.
   6 .\" Portions Copyright (c) 2015, Joyent, Inc.
   7 .TH IPF 4 "Mar 18, 2015"
   8 .SH NAME
   9 ipf, ipf.conf, ipf6.conf \- IP packet filter rule syntax
  10 .SH DESCRIPTION
  11 .PP
  12 A rule file for \fBipf\fP may have any name or even be stdin.  As
  13 \fBipfstat\fP produces parsable rules as output when displaying the internal
  14 kernel filter lists, it is quite plausible to use its output to feed back
  15 into \fBipf\fP.  Thus, to remove all filters on input packets, the following
  16 could be done:
  17 .nf
  18 
  19 \fC# ipfstat \-i | ipf \-rf \-\fP
  20 .fi
  21 .SH GRAMMAR
  22 .PP
  23 The format used by \fBipf\fP for construction of filtering rules can be
  24 described using the following grammar in BNF:
  25 \fC
  26 .nf
  27 filter-rule = [ insert ] action in-out [ options ] [ tos ] [ ttl ]
  28               [ proto ] ip [ group ].
  29 
  30 insert  = "@" decnumber .
  31 action  = block | "pass" | log | "count" | skip | auth | call .
  32 in-out  = "in" | "out" .
  33 options = [ log ] [ tag ] [ "quick" ] [ "on" interface-name [ dup ]
  34            [ froute ] [ replyto ] ] .
  35 tos     = "tos" decnumber | "tos" hexnumber .
  36 ttl     = "ttl" decnumber .
  37 proto   = "proto" protocol .
  38 ip      = srcdst [ flags ] [ with withopt ] [ icmp ] [ keep ] .
  39 group   = [ "head" decnumber ] [ "group" decnumber ] .
  40 
  41 block   = "block" [ return-icmp[return-code] | "return-rst" ] .
  42 log     = "log" [ "body" ] [ "first" ] [ "or-block" ] [ "level" loglevel ] .
  43 tag     = "tag" tagid .
  44 skip    = "skip" decnumber .
  45 auth    = "auth" | "preauth" .


  98            "local3" | "local4" | "local5" | "local6" | "local7" .
  99 priority = "emerg" | "alert" | "crit" | "err" | "warn" | "notice" |
 100            "info" | "debug" .
 101 
 102 hexnumber = "0" "x" hexstring .
 103 hexstring = hexdigit [ hexstring ] .
 104 decnumber = digit [ decnumber ] .
 105 
 106 compare = "=" | "!=" | "<" | ">" | "<=" | ">=" | "eq" | "ne" | "lt" |
 107           "gt" | "le" | "ge" .
 108 range   = "<>" | "><" .
 109 hexdigit = digit | "a" | "b" | "c" | "d" | "e" | "f" .
 110 digit   = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" .
 111 flag    = "F" | "S" | "R" | "P" | "A" | "U" .
 112 .fi
 113 .PP
 114 This syntax is somewhat simplified for readability, some combinations
 115 that match this grammar are disallowed by the software because they do
 116 not make sense (such as tcp \fBflags\fP for non-TCP packets).
 117 .SH FILTER RULES
 118 .PP
 119 The "briefest" valid rules are (currently) no-ops and are of the form:
 120 .nf
 121        block in all
 122        pass in all
 123        log out all
 124        count in all
 125 .fi
 126 .PP
 127 Filter rules are checked in order, with the last matching rule
 128 determining the fate of the packet (but see the \fBquick\fP option,
 129 below).
 130 .PP
 131 Filters are installed by default at the end of the kernel's filter
 132 lists, prepending the rule with \fB@n\fP will cause it to be inserted
 133 as the n'th entry in the current list. This is especially useful when
 134 modifying and testing active filter rulesets. See \fBipf\fP(1M) for more
 135 information.
 136 .SH ACTIONS
 137 .PP
 138 The action indicates what to do with the packet if it matches the rest
 139 of the filter rule. Each rule MUST have an action. The following
 140 actions are recognised:
 141 .TP
 142 .B block
 143 indicates that the packet should be flagged to be dropped. In response
 144 to blocking a packet, the filter may be instructed to send a reply
 145 packet, either an ICMP packet (\fBreturn-icmp\fP), an ICMP packet
 146 masquerading as being from the original packet's destination
 147 (\fBreturn-icmp-as-dest\fP), or a TCP "reset" (\fBreturn-rst\fP).  An
 148 ICMP packet may be generated in response to any IP packet, and its
 149 type may optionally be specified, but a TCP reset may only be used
 150 with a rule which is being applied to TCP packets.  When using
 151 \fBreturn-icmp\fP or \fBreturn-icmp-as-dest\fP, it is possible to specify
 152 the actual unreachable `type'.  That is, whether it is a network
 153 unreachable, port unreachable or even administratively
 154 prohibited. This is done by enclosing the ICMP code associated with
 155 it in parenthesis directly following \fBreturn-icmp\fP or
 156 \fBreturn-icmp-as-dest\fP as follows:
 157 .nf


 193 or not.  Such a program might look at the source address and request some sort
 194 of authentication from the user (such as a password) before allowing the
 195 packet through or telling the kernel to drop it if from an unrecognised source.
 196 .TP
 197 .B preauth
 198 tells the filter that for packets of this class, it should look in the
 199 pre-authenticated list for further clarification.  If no further matching
 200 rule is found, the packet will be dropped (the FR_PREAUTH is not the same
 201 as FR_PASS).  If a further matching rule is found, the result from that is
 202 used in its instead.  This might be used in a situation where a person
 203 \fIlogs in\fP to the firewall and it sets up some temporary rules defining
 204 the access for that person.
 205 .PP
 206 The next word must be either \fBin\fP or \fBout\fP.  Each packet
 207 moving through the kernel is either inbound (just been received on an
 208 interface, and moving towards the kernel's protocol processing) or
 209 outbound (transmitted or forwarded by the stack, and on its way to an
 210 interface). There is a requirement that each filter rule explicitly
 211 state which side of the I/O it is to be used on.
 212 .SH OPTIONS
 213 .PP
 214 The list of options is brief, and all are indeed optional. Where
 215 options are used, they must be present in the order shown here. These
 216 are the currently supported options:
 217 .TP
 218 .B log
 219 indicates that, should this be the last matching rule, the packet
 220 header will be written to the \fBipl\fP log (as described in the
 221 LOGGING section below).
 222 .TP
 223 .B tag tagid
 224 indicates that, if this rule causes the packet to be logged or entered
 225 in the state table, the tagid will be logged as part of the log entry.
 226 This can be used to quickly match "similar" rules in scripts that post
 227 process the log files for e.g. generation of security reports or accounting
 228 purposes. The tagid is a 32 bit unsigned integer.
 229 .TP
 230 .B quick
 231 allows "short-cut" rules in order to speed up the filter or override
 232 later rules.  If a packet matches a filter rule which is marked as
 233 \fBquick\fP, this rule will be the last rule checked, allowing a


 252 This option is especially useful for simple IP-spoofing protection:
 253 packets should only be allowed to pass inbound on the interface from
 254 which the specified source address would be expected, others may be
 255 logged and/or dropped.
 256 .TP
 257 .B dup-to
 258 causes the packet to be copied, and the duplicate packet to be sent
 259 outbound on the specified interface, optionally with the destination
 260 IP address changed to that specified. This is useful for off-host
 261 logging, using a network sniffer.
 262 .TP
 263 .B to
 264 causes the packet to be moved to the outbound queue on the
 265 specified interface. This can be used to circumvent kernel routing
 266 decisions, and even to bypass the rest of the kernel processing of the
 267 packet (if applied to an inbound rule). It is thus possible to
 268 construct a firewall that behaves transparently, like a filtering hub
 269 or switch, rather than a router. The \fBfastroute\fP keyword is a
 270 synonym for this option.
 271 .SH MATCHING PARAMETERS
 272 .PP
 273 The keywords described in this section are used to describe attributes
 274 of the packet to be used when determining whether rules match or don't
 275 match. The following general-purpose attributes are provided for
 276 matching, and must be used in this order:
 277 .TP
 278 .B tos
 279 packets with different Type-Of-Service values can be filtered.
 280 Individual service levels or combinations can be filtered upon.  The
 281 value for the TOS mask can either be represented as a hex number or a
 282 decimal integer value.
 283 .TP
 284 .B ttl
 285 packets may also be selected by their Time-To-Live value.  The value given in
 286 the filter rule must exactly match that in the packet for a match to occur.
 287 This value can only be given as a decimal integer value.
 288 .TP
 289 .B proto
 290 allows a specific protocol to be matched against.  All protocol names
 291 found in \fB/etc/protocols\fP are recognised and may be used.
 292 However, the protocol may also be given as a DECIMAL number, allowing


 396                         # packets with ONLY the SYN flag set.
 397 
 398         ... flags SA
 399                         # becomes "flags SA/AUPRFS" and will match any
 400                         # packet with only the SYN and ACK flags set.
 401 
 402         ... flags S/SA
 403                         # will match any packet with just the SYN flag set
 404                         # out of the SYN-ACK pair; the common "establish"
 405                         # keyword action.  "S/SA" will NOT match a packet
 406                         # with BOTH SYN and ACK set, but WILL match "SFP".
 407 .fi
 408 .TP
 409 .B icmp-type
 410 is only effective when used with \fBproto icmp\fP and must NOT be used
 411 in conjunction with \fBflags\fP.  There are a number of types, which can be
 412 referred to by an abbreviation recognised by this language, or the numbers
 413 with which they are associated can be used.  The most important from
 414 a security point of view is the ICMP redirect.
 415 .SH KEEP HISTORY
 416 .PP
 417 The second last parameter which can be set for a filter rule is whether or not
 418 to record historical information for that packet, and what sort to keep. The
 419 following information can be kept:
 420 .TP
 421 .B state
 422 keeps information about the flow of a communication session. State can
 423 be kept for TCP, UDP, and ICMP packets.
 424 .TP
 425 .B frags
 426 keeps information on fragmented packets, to be applied to later
 427 fragments.
 428 .PP
 429 allowing packets which match these to flow straight through, rather
 430 than going through the access control list.
 431 .SH GROUPS
 432 The last pair of parameters control filter rule "grouping".  By default, all
 433 filter rules are placed in group 0 if no other group is specified.  To add a
 434 rule to a non-default group, the group must first be started by creating a
 435 group \fIhead\fP.  If a packet matches a rule which is the \fIhead\fP of a
 436 group, the filter processing then switches to the group, using that rule as
 437 the default for the group.  If \fBquick\fP is used with a \fBhead\fP rule, rule
 438 processing isn't stopped until it has returned from processing the group.
 439 .PP
 440 A rule may be both the head for a new group and a member of a non-default
 441 group (\fBhead\fP and \fBgroup\fP may be used together in a rule).
 442 .TP
 443 .B "head <n>"
 444 indicates that a new group (number n) should be created.
 445 .TP
 446 .B "group <n>"
 447 indicates that the rule should be put in group (number n) rather than group 0.
 448 .SH LOGGING
 449 .PP
 450 When a packet is logged, with either the \fBlog\fP action or option,
 451 the headers of the packet are written to the \fBipl\fP packet logging
 452 pseudo-device. Immediately following the \fBlog\fP keyword, the
 453 following qualifiers may be used (in order):
 454 .TP
 455 .B body
 456 indicates that the first 128 bytes of the packet contents will be
 457 logged after the headers.
 458 .TP
 459 .B first
 460 If log is being used in conjunction with a "keep" option, it is recommended
 461 that this option is also applied so that only the triggering packet is logged
 462 and not every packet which thereafter matches state information.
 463 .TP
 464 .B or-block
 465 indicates that, if for some reason the filter is unable to log the
 466 packet (such as the log reader being too slow) then the rule should be
 467 interpreted as if the action was \fBblock\fP for this packet.
 468 .TP
 469 .B "level <loglevel>"
 470 indicates what logging facility and priority, or just priority with
 471 the default facility being used, will be used to log information about
 472 this packet using ipmon's -s option.
 473 .PP
 474 See ipl(4) for the format of records written
 475 to this device. The ipmon(1M) program can be used to read and format
 476 this log.
 477 .SH EXAMPLES
 478 .PP
 479 The \fBquick\fP option is good for rules such as:
 480 \fC
 481 .nf
 482 block in quick from any to any with ipopts
 483 .fi
 484 .PP
 485 which will match any packet with a non-standard header length (IP
 486 options present) and abort further processing of later rules,
 487 recording a match and also that the packet should be blocked.
 488 .PP
 489 The "fall-through" rule parsing allows for effects such as this:
 490 .LP
 491 .nf
 492         block in from any to any port < 6000
 493         pass in from any to any port >= 6000
 494         block in from any to any port > 6003
 495 .fi
 496 .PP
 497 which sets up the range 6000-6003 as being permitted and all others being
 498 denied.  Note that the effect of the first rule is overridden by subsequent
 499 rules.  Another (easier) way to do the same is:
 500 .LP


 506 Note that both the "block" and "pass" are needed here to effect a
 507 result as a failed match on the "block" action does not imply a pass,
 508 only that the rule hasn't taken effect.  To then allow ports < 1024, a
 509 rule such as:
 510 .LP
 511 .nf
 512         pass in quick from any to any port < 1024
 513 .fi
 514 .PP
 515 would be needed before the first block.  To create a new group for
 516 processing all inbound packets on le0/le1/lo0, with the default being to block
 517 all inbound packets, we would do something like:
 518 .LP
 519 .nf
 520        block in all
 521        block in quick on le0 all head 100
 522        block in quick on le1 all head 200
 523        block in quick on lo0 all head 300
 524 .fi
 525 .PP
 526 
 527 and to then allow ICMP packets in on le0, only, we would do:
 528 .LP
 529 .nf
 530        pass in proto icmp all group 100
 531 .fi
 532 .PP
 533 Note that because only inbound packets on le0 are used processed by group 100,
 534 there is no need to respecify the interface name.  Likewise, we could further
 535 breakup processing of TCP, etc, as follows:
 536 .LP
 537 .nf
 538        block in proto tcp all head 110 group 100
 539        pass in from any to any port = 23 group 110
 540 .fi
 541 .PP
 542 and so on.  The last line, if written without the groups would be:
 543 .LP
 544 .nf
 545        pass in on le0 proto tcp from any to any port = telnet
 546 .fi
   1 '\" te
   2 .\" To view license terms, attribution, and copyright for IP Filter, the
   3 .\" default path is /usr/lib/ipf/IPFILTER.LICENCE. If the illumos operating
   4 .\" environment has been installed anywhere other than the default, modify the
   5 .\" given path to access the file at the installed location.
   6 .\" Portions Copyright (c) 2015, Joyent, Inc.
   7 .TH IPF 4 "Mar 18, 2015"
   8 .SH NAME
   9 ipf, ipf.conf, ipf6.conf \- IP packet filter rule syntax
  10 .SH DESCRIPTION

  11 A rule file for \fBipf\fP may have any name or even be stdin.  As
  12 \fBipfstat\fP produces parsable rules as output when displaying the internal
  13 kernel filter lists, it is quite plausible to use its output to feed back
  14 into \fBipf\fP.  Thus, to remove all filters on input packets, the following
  15 could be done:
  16 .nf
  17 
  18 # ipfstat \-i | ipf \-rf \-\fP
  19 .fi
  20 .SH GRAMMAR

  21 The format used by \fBipf\fP for construction of filtering rules can be
  22 described using the following grammar in BNF:

  23 .nf
  24 filter-rule = [ insert ] action in-out [ options ] [ tos ] [ ttl ]
  25               [ proto ] ip [ group ].
  26 
  27 insert  = "@" decnumber .
  28 action  = block | "pass" | log | "count" | skip | auth | call .
  29 in-out  = "in" | "out" .
  30 options = [ log ] [ tag ] [ "quick" ] [ "on" interface-name [ dup ]
  31            [ froute ] [ replyto ] ] .
  32 tos     = "tos" decnumber | "tos" hexnumber .
  33 ttl     = "ttl" decnumber .
  34 proto   = "proto" protocol .
  35 ip      = srcdst [ flags ] [ with withopt ] [ icmp ] [ keep ] .
  36 group   = [ "head" decnumber ] [ "group" decnumber ] .
  37 
  38 block   = "block" [ return-icmp[return-code] | "return-rst" ] .
  39 log     = "log" [ "body" ] [ "first" ] [ "or-block" ] [ "level" loglevel ] .
  40 tag     = "tag" tagid .
  41 skip    = "skip" decnumber .
  42 auth    = "auth" | "preauth" .


  95            "local3" | "local4" | "local5" | "local6" | "local7" .
  96 priority = "emerg" | "alert" | "crit" | "err" | "warn" | "notice" |
  97            "info" | "debug" .
  98 
  99 hexnumber = "0" "x" hexstring .
 100 hexstring = hexdigit [ hexstring ] .
 101 decnumber = digit [ decnumber ] .
 102 
 103 compare = "=" | "!=" | "<" | ">" | "<=" | ">=" | "eq" | "ne" | "lt" |
 104           "gt" | "le" | "ge" .
 105 range   = "<>" | "><" .
 106 hexdigit = digit | "a" | "b" | "c" | "d" | "e" | "f" .
 107 digit   = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" .
 108 flag    = "F" | "S" | "R" | "P" | "A" | "U" .
 109 .fi
 110 .PP
 111 This syntax is somewhat simplified for readability, some combinations
 112 that match this grammar are disallowed by the software because they do
 113 not make sense (such as tcp \fBflags\fP for non-TCP packets).
 114 .SH FILTER RULES

 115 The "briefest" valid rules are (currently) no-ops and are of the form:
 116 .nf
 117        block in all
 118        pass in all
 119        log out all
 120        count in all
 121 .fi
 122 .PP
 123 Filter rules are checked in order, with the last matching rule
 124 determining the fate of the packet (but see the \fBquick\fP option,
 125 below).
 126 .PP
 127 Filters are installed by default at the end of the kernel's filter
 128 lists, prepending the rule with \fB@n\fP will cause it to be inserted
 129 as the n'th entry in the current list. This is especially useful when
 130 modifying and testing active filter rulesets. See \fBipf\fP(1M) for more
 131 information.
 132 .SH ACTIONS

 133 The action indicates what to do with the packet if it matches the rest
 134 of the filter rule. Each rule MUST have an action. The following
 135 actions are recognised:
 136 .TP
 137 .B block
 138 indicates that the packet should be flagged to be dropped. In response
 139 to blocking a packet, the filter may be instructed to send a reply
 140 packet, either an ICMP packet (\fBreturn-icmp\fP), an ICMP packet
 141 masquerading as being from the original packet's destination
 142 (\fBreturn-icmp-as-dest\fP), or a TCP "reset" (\fBreturn-rst\fP).  An
 143 ICMP packet may be generated in response to any IP packet, and its
 144 type may optionally be specified, but a TCP reset may only be used
 145 with a rule which is being applied to TCP packets.  When using
 146 \fBreturn-icmp\fP or \fBreturn-icmp-as-dest\fP, it is possible to specify
 147 the actual unreachable `type'.  That is, whether it is a network
 148 unreachable, port unreachable or even administratively
 149 prohibited. This is done by enclosing the ICMP code associated with
 150 it in parenthesis directly following \fBreturn-icmp\fP or
 151 \fBreturn-icmp-as-dest\fP as follows:
 152 .nf


 188 or not.  Such a program might look at the source address and request some sort
 189 of authentication from the user (such as a password) before allowing the
 190 packet through or telling the kernel to drop it if from an unrecognised source.
 191 .TP
 192 .B preauth
 193 tells the filter that for packets of this class, it should look in the
 194 pre-authenticated list for further clarification.  If no further matching
 195 rule is found, the packet will be dropped (the FR_PREAUTH is not the same
 196 as FR_PASS).  If a further matching rule is found, the result from that is
 197 used in its instead.  This might be used in a situation where a person
 198 \fIlogs in\fP to the firewall and it sets up some temporary rules defining
 199 the access for that person.
 200 .PP
 201 The next word must be either \fBin\fP or \fBout\fP.  Each packet
 202 moving through the kernel is either inbound (just been received on an
 203 interface, and moving towards the kernel's protocol processing) or
 204 outbound (transmitted or forwarded by the stack, and on its way to an
 205 interface). There is a requirement that each filter rule explicitly
 206 state which side of the I/O it is to be used on.
 207 .SH OPTIONS

 208 The list of options is brief, and all are indeed optional. Where
 209 options are used, they must be present in the order shown here. These
 210 are the currently supported options:
 211 .TP
 212 .B log
 213 indicates that, should this be the last matching rule, the packet
 214 header will be written to the \fBipl\fP log (as described in the
 215 LOGGING section below).
 216 .TP
 217 .B tag tagid
 218 indicates that, if this rule causes the packet to be logged or entered
 219 in the state table, the tagid will be logged as part of the log entry.
 220 This can be used to quickly match "similar" rules in scripts that post
 221 process the log files for e.g. generation of security reports or accounting
 222 purposes. The tagid is a 32 bit unsigned integer.
 223 .TP
 224 .B quick
 225 allows "short-cut" rules in order to speed up the filter or override
 226 later rules.  If a packet matches a filter rule which is marked as
 227 \fBquick\fP, this rule will be the last rule checked, allowing a


 246 This option is especially useful for simple IP-spoofing protection:
 247 packets should only be allowed to pass inbound on the interface from
 248 which the specified source address would be expected, others may be
 249 logged and/or dropped.
 250 .TP
 251 .B dup-to
 252 causes the packet to be copied, and the duplicate packet to be sent
 253 outbound on the specified interface, optionally with the destination
 254 IP address changed to that specified. This is useful for off-host
 255 logging, using a network sniffer.
 256 .TP
 257 .B to
 258 causes the packet to be moved to the outbound queue on the
 259 specified interface. This can be used to circumvent kernel routing
 260 decisions, and even to bypass the rest of the kernel processing of the
 261 packet (if applied to an inbound rule). It is thus possible to
 262 construct a firewall that behaves transparently, like a filtering hub
 263 or switch, rather than a router. The \fBfastroute\fP keyword is a
 264 synonym for this option.
 265 .SH MATCHING PARAMETERS

 266 The keywords described in this section are used to describe attributes
 267 of the packet to be used when determining whether rules match or don't
 268 match. The following general-purpose attributes are provided for
 269 matching, and must be used in this order:
 270 .TP
 271 .B tos
 272 packets with different Type-Of-Service values can be filtered.
 273 Individual service levels or combinations can be filtered upon.  The
 274 value for the TOS mask can either be represented as a hex number or a
 275 decimal integer value.
 276 .TP
 277 .B ttl
 278 packets may also be selected by their Time-To-Live value.  The value given in
 279 the filter rule must exactly match that in the packet for a match to occur.
 280 This value can only be given as a decimal integer value.
 281 .TP
 282 .B proto
 283 allows a specific protocol to be matched against.  All protocol names
 284 found in \fB/etc/protocols\fP are recognised and may be used.
 285 However, the protocol may also be given as a DECIMAL number, allowing


 389                         # packets with ONLY the SYN flag set.
 390 
 391         ... flags SA
 392                         # becomes "flags SA/AUPRFS" and will match any
 393                         # packet with only the SYN and ACK flags set.
 394 
 395         ... flags S/SA
 396                         # will match any packet with just the SYN flag set
 397                         # out of the SYN-ACK pair; the common "establish"
 398                         # keyword action.  "S/SA" will NOT match a packet
 399                         # with BOTH SYN and ACK set, but WILL match "SFP".
 400 .fi
 401 .TP
 402 .B icmp-type
 403 is only effective when used with \fBproto icmp\fP and must NOT be used
 404 in conjunction with \fBflags\fP.  There are a number of types, which can be
 405 referred to by an abbreviation recognised by this language, or the numbers
 406 with which they are associated can be used.  The most important from
 407 a security point of view is the ICMP redirect.
 408 .SH KEEP HISTORY

 409 The second last parameter which can be set for a filter rule is whether or not
 410 to record historical information for that packet, and what sort to keep. The
 411 following information can be kept:
 412 .TP
 413 .B state
 414 keeps information about the flow of a communication session. State can
 415 be kept for TCP, UDP, and ICMP packets.
 416 .TP
 417 .B frags
 418 keeps information on fragmented packets, to be applied to later
 419 fragments.
 420 .PP
 421 allowing packets which match these to flow straight through, rather
 422 than going through the access control list.
 423 .SH GROUPS
 424 The last pair of parameters control filter rule "grouping".  By default, all
 425 filter rules are placed in group 0 if no other group is specified.  To add a
 426 rule to a non-default group, the group must first be started by creating a
 427 group \fIhead\fP.  If a packet matches a rule which is the \fIhead\fP of a
 428 group, the filter processing then switches to the group, using that rule as
 429 the default for the group.  If \fBquick\fP is used with a \fBhead\fP rule, rule
 430 processing isn't stopped until it has returned from processing the group.
 431 .PP
 432 A rule may be both the head for a new group and a member of a non-default
 433 group (\fBhead\fP and \fBgroup\fP may be used together in a rule).
 434 .TP
 435 .B "head <n>"
 436 indicates that a new group (number n) should be created.
 437 .TP
 438 .B "group <n>"
 439 indicates that the rule should be put in group (number n) rather than group 0.
 440 .SH LOGGING

 441 When a packet is logged, with either the \fBlog\fP action or option,
 442 the headers of the packet are written to the \fBipl\fP packet logging
 443 pseudo-device. Immediately following the \fBlog\fP keyword, the
 444 following qualifiers may be used (in order):
 445 .TP
 446 .B body
 447 indicates that the first 128 bytes of the packet contents will be
 448 logged after the headers.
 449 .TP
 450 .B first
 451 If log is being used in conjunction with a "keep" option, it is recommended
 452 that this option is also applied so that only the triggering packet is logged
 453 and not every packet which thereafter matches state information.
 454 .TP
 455 .B or-block
 456 indicates that, if for some reason the filter is unable to log the
 457 packet (such as the log reader being too slow) then the rule should be
 458 interpreted as if the action was \fBblock\fP for this packet.
 459 .TP
 460 .B "level <loglevel>"
 461 indicates what logging facility and priority, or just priority with
 462 the default facility being used, will be used to log information about
 463 this packet using ipmon's -s option.
 464 .PP
 465 See ipl(4) for the format of records written
 466 to this device. The ipmon(1M) program can be used to read and format
 467 this log.
 468 .SH EXAMPLES

 469 The \fBquick\fP option is good for rules such as:

 470 .nf
 471 block in quick from any to any with ipopts
 472 .fi
 473 .PP
 474 which will match any packet with a non-standard header length (IP
 475 options present) and abort further processing of later rules,
 476 recording a match and also that the packet should be blocked.
 477 .PP
 478 The "fall-through" rule parsing allows for effects such as this:
 479 .LP
 480 .nf
 481         block in from any to any port < 6000
 482         pass in from any to any port >= 6000
 483         block in from any to any port > 6003
 484 .fi
 485 .PP
 486 which sets up the range 6000-6003 as being permitted and all others being
 487 denied.  Note that the effect of the first rule is overridden by subsequent
 488 rules.  Another (easier) way to do the same is:
 489 .LP


 495 Note that both the "block" and "pass" are needed here to effect a
 496 result as a failed match on the "block" action does not imply a pass,
 497 only that the rule hasn't taken effect.  To then allow ports < 1024, a
 498 rule such as:
 499 .LP
 500 .nf
 501         pass in quick from any to any port < 1024
 502 .fi
 503 .PP
 504 would be needed before the first block.  To create a new group for
 505 processing all inbound packets on le0/le1/lo0, with the default being to block
 506 all inbound packets, we would do something like:
 507 .LP
 508 .nf
 509        block in all
 510        block in quick on le0 all head 100
 511        block in quick on le1 all head 200
 512        block in quick on lo0 all head 300
 513 .fi
 514 .PP

 515 and to then allow ICMP packets in on le0, only, we would do:
 516 .LP
 517 .nf
 518        pass in proto icmp all group 100
 519 .fi
 520 .PP
 521 Note that because only inbound packets on le0 are used processed by group 100,
 522 there is no need to respecify the interface name.  Likewise, we could further
 523 breakup processing of TCP, etc, as follows:
 524 .LP
 525 .nf
 526        block in proto tcp all head 110 group 100
 527        pass in from any to any port = 23 group 110
 528 .fi
 529 .PP
 530 and so on.  The last line, if written without the groups would be:
 531 .LP
 532 .nf
 533        pass in on le0 proto tcp from any to any port = telnet
 534 .fi