Print this page
11622 clean up rarer mandoc lint warnings

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man4/ipf.4
          +++ new/usr/src/man/man4/ipf.4
   1    1  '\" te
   2    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
        3 +.\" default path is /usr/lib/ipf/IPFILTER.LICENCE. If the illumos operating
   4    4  .\" environment has been installed anywhere other than the default, modify the
   5    5  .\" given path to access the file at the installed location.
   6    6  .\" Portions Copyright (c) 2015, Joyent, Inc.
   7    7  .TH IPF 4 "Mar 18, 2015"
   8    8  .SH NAME
   9    9  ipf, ipf.conf, ipf6.conf \- IP packet filter rule syntax
  10   10  .SH DESCRIPTION
  11      -.PP
  12   11  A rule file for \fBipf\fP may have any name or even be stdin.  As
  13   12  \fBipfstat\fP produces parsable rules as output when displaying the internal
  14   13  kernel filter lists, it is quite plausible to use its output to feed back
  15   14  into \fBipf\fP.  Thus, to remove all filters on input packets, the following
  16   15  could be done:
  17   16  .nf
  18   17  
  19      -\fC# ipfstat \-i | ipf \-rf \-\fP
       18 +# ipfstat \-i | ipf \-rf \-\fP
  20   19  .fi
  21   20  .SH GRAMMAR
  22      -.PP
  23   21  The format used by \fBipf\fP for construction of filtering rules can be
  24   22  described using the following grammar in BNF:
  25      -\fC
  26   23  .nf
  27   24  filter-rule = [ insert ] action in-out [ options ] [ tos ] [ ttl ]
  28   25                [ proto ] ip [ group ].
  29   26  
  30   27  insert  = "@" decnumber .
  31   28  action  = block | "pass" | log | "count" | skip | auth | call .
  32   29  in-out  = "in" | "out" .
  33   30  options = [ log ] [ tag ] [ "quick" ] [ "on" interface-name [ dup ]
  34   31             [ froute ] [ replyto ] ] .
  35   32  tos     = "tos" decnumber | "tos" hexnumber .
↓ open down ↓ 72 lines elided ↑ open up ↑
 108  105  range   = "<>" | "><" .
 109  106  hexdigit = digit | "a" | "b" | "c" | "d" | "e" | "f" .
 110  107  digit   = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" .
 111  108  flag    = "F" | "S" | "R" | "P" | "A" | "U" .
 112  109  .fi
 113  110  .PP
 114  111  This syntax is somewhat simplified for readability, some combinations
 115  112  that match this grammar are disallowed by the software because they do
 116  113  not make sense (such as tcp \fBflags\fP for non-TCP packets).
 117  114  .SH FILTER RULES
 118      -.PP
 119  115  The "briefest" valid rules are (currently) no-ops and are of the form:
 120  116  .nf
 121  117         block in all
 122  118         pass in all
 123  119         log out all
 124  120         count in all
 125  121  .fi
 126  122  .PP
 127  123  Filter rules are checked in order, with the last matching rule
 128  124  determining the fate of the packet (but see the \fBquick\fP option,
 129  125  below).
 130  126  .PP
 131  127  Filters are installed by default at the end of the kernel's filter
 132  128  lists, prepending the rule with \fB@n\fP will cause it to be inserted
 133  129  as the n'th entry in the current list. This is especially useful when
 134  130  modifying and testing active filter rulesets. See \fBipf\fP(1M) for more
 135  131  information.
 136  132  .SH ACTIONS
 137      -.PP
 138  133  The action indicates what to do with the packet if it matches the rest
 139  134  of the filter rule. Each rule MUST have an action. The following
 140  135  actions are recognised:
 141  136  .TP
 142  137  .B block
 143  138  indicates that the packet should be flagged to be dropped. In response
 144  139  to blocking a packet, the filter may be instructed to send a reply
 145  140  packet, either an ICMP packet (\fBreturn-icmp\fP), an ICMP packet
 146  141  masquerading as being from the original packet's destination
 147  142  (\fBreturn-icmp-as-dest\fP), or a TCP "reset" (\fBreturn-rst\fP).  An
↓ open down ↓ 55 lines elided ↑ open up ↑
 203  198  \fIlogs in\fP to the firewall and it sets up some temporary rules defining
 204  199  the access for that person.
 205  200  .PP
 206  201  The next word must be either \fBin\fP or \fBout\fP.  Each packet
 207  202  moving through the kernel is either inbound (just been received on an
 208  203  interface, and moving towards the kernel's protocol processing) or
 209  204  outbound (transmitted or forwarded by the stack, and on its way to an
 210  205  interface). There is a requirement that each filter rule explicitly
 211  206  state which side of the I/O it is to be used on.
 212  207  .SH OPTIONS
 213      -.PP
 214  208  The list of options is brief, and all are indeed optional. Where
 215  209  options are used, they must be present in the order shown here. These
 216  210  are the currently supported options:
 217  211  .TP
 218  212  .B log
 219  213  indicates that, should this be the last matching rule, the packet
 220  214  header will be written to the \fBipl\fP log (as described in the
 221  215  LOGGING section below).
 222  216  .TP
 223  217  .B tag tagid
↓ open down ↓ 38 lines elided ↑ open up ↑
 262  256  .TP
 263  257  .B to
 264  258  causes the packet to be moved to the outbound queue on the
 265  259  specified interface. This can be used to circumvent kernel routing
 266  260  decisions, and even to bypass the rest of the kernel processing of the
 267  261  packet (if applied to an inbound rule). It is thus possible to
 268  262  construct a firewall that behaves transparently, like a filtering hub
 269  263  or switch, rather than a router. The \fBfastroute\fP keyword is a
 270  264  synonym for this option.
 271  265  .SH MATCHING PARAMETERS
 272      -.PP
 273  266  The keywords described in this section are used to describe attributes
 274  267  of the packet to be used when determining whether rules match or don't
 275  268  match. The following general-purpose attributes are provided for
 276  269  matching, and must be used in this order:
 277  270  .TP
 278  271  .B tos
 279  272  packets with different Type-Of-Service values can be filtered.
 280  273  Individual service levels or combinations can be filtered upon.  The
 281  274  value for the TOS mask can either be represented as a hex number or a
 282  275  decimal integer value.
↓ open down ↓ 123 lines elided ↑ open up ↑
 406  399                          # with BOTH SYN and ACK set, but WILL match "SFP".
 407  400  .fi
 408  401  .TP
 409  402  .B icmp-type
 410  403  is only effective when used with \fBproto icmp\fP and must NOT be used
 411  404  in conjunction with \fBflags\fP.  There are a number of types, which can be
 412  405  referred to by an abbreviation recognised by this language, or the numbers
 413  406  with which they are associated can be used.  The most important from
 414  407  a security point of view is the ICMP redirect.
 415  408  .SH KEEP HISTORY
 416      -.PP
 417  409  The second last parameter which can be set for a filter rule is whether or not
 418  410  to record historical information for that packet, and what sort to keep. The
 419  411  following information can be kept:
 420  412  .TP
 421  413  .B state
 422  414  keeps information about the flow of a communication session. State can
 423  415  be kept for TCP, UDP, and ICMP packets.
 424  416  .TP
 425  417  .B frags
 426  418  keeps information on fragmented packets, to be applied to later
↓ open down ↓ 12 lines elided ↑ open up ↑
 439  431  .PP
 440  432  A rule may be both the head for a new group and a member of a non-default
 441  433  group (\fBhead\fP and \fBgroup\fP may be used together in a rule).
 442  434  .TP
 443  435  .B "head <n>"
 444  436  indicates that a new group (number n) should be created.
 445  437  .TP
 446  438  .B "group <n>"
 447  439  indicates that the rule should be put in group (number n) rather than group 0.
 448  440  .SH LOGGING
 449      -.PP
 450  441  When a packet is logged, with either the \fBlog\fP action or option,
 451  442  the headers of the packet are written to the \fBipl\fP packet logging
 452  443  pseudo-device. Immediately following the \fBlog\fP keyword, the
 453  444  following qualifiers may be used (in order):
 454  445  .TP
 455  446  .B body
 456  447  indicates that the first 128 bytes of the packet contents will be
 457  448  logged after the headers.
 458  449  .TP
 459  450  .B first
↓ open down ↓ 8 lines elided ↑ open up ↑
 468  459  .TP
 469  460  .B "level <loglevel>"
 470  461  indicates what logging facility and priority, or just priority with
 471  462  the default facility being used, will be used to log information about
 472  463  this packet using ipmon's -s option.
 473  464  .PP
 474  465  See ipl(4) for the format of records written
 475  466  to this device. The ipmon(1M) program can be used to read and format
 476  467  this log.
 477  468  .SH EXAMPLES
 478      -.PP
 479  469  The \fBquick\fP option is good for rules such as:
 480      -\fC
 481  470  .nf
 482  471  block in quick from any to any with ipopts
 483  472  .fi
 484  473  .PP
 485  474  which will match any packet with a non-standard header length (IP
 486  475  options present) and abort further processing of later rules,
 487  476  recording a match and also that the packet should be blocked.
 488  477  .PP
 489  478  The "fall-through" rule parsing allows for effects such as this:
 490  479  .LP
↓ open down ↓ 25 lines elided ↑ open up ↑
 516  505  processing all inbound packets on le0/le1/lo0, with the default being to block
 517  506  all inbound packets, we would do something like:
 518  507  .LP
 519  508  .nf
 520  509         block in all
 521  510         block in quick on le0 all head 100
 522  511         block in quick on le1 all head 200
 523  512         block in quick on lo0 all head 300
 524  513  .fi
 525  514  .PP
 526      -
 527  515  and to then allow ICMP packets in on le0, only, we would do:
 528  516  .LP
 529  517  .nf
 530  518         pass in proto icmp all group 100
 531  519  .fi
 532  520  .PP
 533  521  Note that because only inbound packets on le0 are used processed by group 100,
 534  522  there is no need to respecify the interface name.  Likewise, we could further
 535  523  breakup processing of TCP, etc, as follows:
 536  524  .LP
↓ open down ↓ 26 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX