summaryrefslogtreecommitdiffstats
path: root/contrib/pf/man
diff options
context:
space:
mode:
authormlaier <mlaier@FreeBSD.org>2007-07-03 12:30:03 +0000
committermlaier <mlaier@FreeBSD.org>2007-07-03 12:30:03 +0000
commitedb0b6417988e1d0a2c39481b4ca6c7c2005ed9e (patch)
treec0024fcd4a5dafb6f9b2cf493310b65dbd5df8e6 /contrib/pf/man
parentd1f1f8d084d2091974a8e980ff26076ab5252319 (diff)
downloadFreeBSD-src-edb0b6417988e1d0a2c39481b4ca6c7c2005ed9e.zip
FreeBSD-src-edb0b6417988e1d0a2c39481b4ca6c7c2005ed9e.tar.gz
Commit resolved import of OpenBSD 4.1 pf userland from perforce.
Approved by: re (kensmith)
Diffstat (limited to 'contrib/pf/man')
-rw-r--r--contrib/pf/man/pf.4225
-rw-r--r--contrib/pf/man/pf.conf.5921
-rw-r--r--contrib/pf/man/pf.os.528
-rw-r--r--contrib/pf/man/pflog.422
-rw-r--r--contrib/pf/man/pfsync.47
5 files changed, 686 insertions, 517 deletions
diff --git a/contrib/pf/man/pf.4 b/contrib/pf/man/pf.4
index 41d8c44..16e74ab 100644
--- a/contrib/pf/man/pf.4
+++ b/contrib/pf/man/pf.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pf.4,v 1.54 2004/12/22 17:17:55 dhartmei Exp $
+.\" $OpenBSD: pf.4,v 1.58 2007/02/09 11:39:06 henning Exp $
.\"
.\" Copyright (C) 2001, Kjell Wooding. All rights reserved.
.\"
@@ -186,6 +186,11 @@ using the
obtained through a preceding
.Dv DIOCGETRULES
call.
+If
+.Va action
+is set to
+.Dv PF_GET_CLR_CNTR ,
+the per-rule statistics on the requested rule are cleared.
.It Dv DIOCGETADDRS Fa "struct pfioc_pooladdr *pp"
Get a
.Va ticket
@@ -348,6 +353,7 @@ struct pf_status {
u_int32_t debug;
u_int32_t hostid;
char ifname[IFNAMSIZ];
+ u_int8_t pf_chksum[MD5_DIGEST_LENGTH];
};
.Ed
.It Dv DIOCCLRSTATUS
@@ -391,19 +397,14 @@ struct pfioc_states {
.Pp
If
.Va ps_len
-is zero, all states will be gathered into
-.Va pf_states
-and
+is non-zero on entry, as many states as possible that can fit into this
+size will be copied into the supplied buffer
+.Va ps_states .
+On exit,
.Va ps_len
-will be set to the size they take in memory (i.e.,
+is always set to the total size required to hold all state table entries
+(i.e., it is set to
.Li sizeof(struct pf_state) * nr ) .
-If
-.Va ps_len
-is non-zero, as many states that can fit into
-.Va ps_len
-as possible will be gathered, and
-.Va ps_len
-will be updated to the size those rules take in memory.
.It Dv DIOCCHANGERULE Fa "struct pfioc_rule *pcr"
Add or remove the
.Va rule
@@ -485,7 +486,8 @@ struct pfioc_limit {
unsigned limit;
};
-enum { PF_LIMIT_STATES, PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS };
+enum { PF_LIMIT_STATES, PF_LIMIT_SRC_NODES, PF_LIMIT_FRAGS,
+ PF_LIMIT_TABLES, PF_LIMIT_TABLE_ENTRIES, PF_LIMIT_MAX };
.Ed
.It Dv DIOCGETLIMIT Fa "struct pfioc_limit *pl"
Get the hard
@@ -523,10 +525,15 @@ struct pfioc_table {
.It Dv DIOCRADDTABLES Fa "struct pfioc_table *io"
Create one or more tables.
On entry,
-.Va pfrio_buffer[pfrio_size]
-contains a table of
-.Vt pfr_table
-structures.
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_table
+containing at least
+.Vt pfrio_size
+elements.
+.Vt pfrio_esize
+must be the size of
+.Vt struct pfr_table .
On exit,
.Va pfrio_nadd
contains the number of tables effectively created.
@@ -541,12 +548,17 @@ struct pfr_table {
.It Dv DIOCRDELTABLES Fa "struct pfioc_table *io"
Delete one or more tables.
On entry,
-.Va pfrio_buffer[pfrio_size]
-contains a table of
-.Vt pfr_table
-structures.
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_table
+containing at least
+.Vt pfrio_size
+elements.
+.Vt pfrio_esize
+must be the size of
+.Vt struct pfr_table .
On exit,
-.Va pfrio_nadd
+.Va pfrio_ndel
contains the number of tables effectively deleted.
.It Dv DIOCRGETTABLES Fa "struct pfioc_table *io"
Get the list of all tables.
@@ -585,10 +597,15 @@ struct pfr_tstats {
.It Dv DIOCRCLRTSTATS Fa "struct pfioc_table *io"
Clear the statistics of one or more tables.
On entry,
-.Va pfrio_buffer[pfrio_size]
-contains a table of
-.Vt pfr_table
-structures.
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_table
+containing at least
+.Vt pfrio_size
+elements.
+.Vt pfrio_esize
+must be the size of
+.Vt struct pfr_table .
On exit,
.Va pfrio_nzero
contains the number of tables effectively cleared.
@@ -605,10 +622,15 @@ Add one or more addresses to a table.
On entry,
.Va pfrio_table
contains the table ID and
-.Va pfrio_buffer[pfrio_size]
-contains the list of
-.Vt pfr_addr
-structures to add.
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_addr
+containing at least
+.Vt pfrio_size
+elements to add to the table.
+.Vt pfrio_esize
+must be the size of
+.Vt struct pfr_addr .
On exit,
.Va pfrio_nadd
contains the number of addresses effectively added.
@@ -631,10 +653,15 @@ Delete one or more addresses from a table.
On entry,
.Va pfrio_table
contains the table ID and
-.Va pfrio_buffer[pfrio_size]
-contains the list of
-.Vt pfr_addr
-structures to delete.
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_addr
+containing at least
+.Vt pfrio_size
+elements to delete from the table.
+.Vt pfrio_esize
+must be the size of
+.Vt struct pfr_addr .
On exit,
.Va pfrio_ndel
contains the number of addresses effectively deleted.
@@ -645,10 +672,15 @@ This is the most complicated command, which uses all the structure members.
On entry,
.Va pfrio_table
contains the table ID and
-.Va pfrio_buffer[pfrio_size]
-contains the new list of
-.Vt pfr_addr
-structures.
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_addr
+containing at least
+.Vt pfrio_size
+elements which become the new contents of the table.
+.Vt pfrio_esize
+must be the size of
+.Vt struct pfr_addr .
Additionally, if
.Va pfrio_size2
is non-zero,
@@ -703,10 +735,15 @@ Clear the statistics of one or more addresses.
On entry,
.Va pfrio_table
contains the table ID and
-.Va pfrio_buffer[pfrio_size]
-contains a table of
-.Vt pfr_addr
-structures to clear.
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_addr
+containing at least
+.Vt pfrio_size
+elements to be cleared from the table.
+.Vt pfrio_esize
+must be the size of
+.Vt struct pfr_addr .
On exit,
.Va pfrio_nzero
contains the number of addresses effectively cleared.
@@ -715,13 +752,18 @@ Test if the given addresses match a table.
On entry,
.Va pfrio_table
contains the table ID and
-.Va pfrio_buffer[pfrio_size]
-contains a table of
-.Vt pfr_addr
-structures to test.
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_addr
+containing at least
+.Vt pfrio_size
+elements, each of which will be tested for a match in the table.
+.Vt pfrio_esize
+must be the size of
+.Vt struct pfr_addr .
On exit, the kernel updates the
.Vt pfr_addr
-table by setting the
+array by setting the
.Va pfra_fback
member appropriately.
.It Dv DIOCRSETTFLAGS Fa "struct pfioc_table *io"
@@ -731,14 +773,19 @@ or
.Dv PFR_TFLAG_PERSIST
flags of a table.
On entry,
-.Va pfrio_buffer[pfrio_size]
-contains a table of
-.Vt pfr_table
-structures, and
+.Va pfrio_buffer
+must point to an array of
+.Vt struct pfr_table
+containing at least
+.Vt pfrio_size
+elements.
+.Va pfrio_esize
+must be the size of
+.Vt struct pfr_table .
.Va pfrio_setflag
-contains the flags to add, while
+must contain the flags to add, while
.Va pfrio_clrflag
-contains the flags to remove.
+must contain the flags to remove.
On exit,
.Va pfrio_nchange
and
@@ -753,7 +800,7 @@ On entry,
.Va pfrio_table
contains the table ID and
.Va pfrio_buffer[pfrio_size]
-contains the list of
+contains an array of
.Vt pfr_addr
structures to put in the table.
A valid ticket must also be supplied to
@@ -955,10 +1002,6 @@ struct pfioc_iface {
int pfiio_nzero;
int pfiio_flags;
};
-
-#define PFI_FLAG_GROUP 0x0001 /* gets groups of interfaces */
-#define PFI_FLAG_INSTANCE 0x0002 /* gets single interfaces */
-#define PFI_FLAG_ALLMASK 0x0003
.Ed
.Pp
If not empty,
@@ -968,61 +1011,45 @@ can be used to restrict the search to a specific interface or driver.
is the user-supplied buffer for returning the data.
On entry,
.Va pfiio_size
-represents the number of
-.Va pfi_if
+contains the number of
+.Vt pfi_kif
entries that can fit into the buffer.
The kernel will replace this value by the real number of entries it wants
to return.
.Va pfiio_esize
should be set to
-.Li sizeof(struct pfi_if) .
-.Va pfiio_flags
-should be set to
-.Dv PFI_FLAG_GROUP ,
-.Dv PFI_FLAG_INSTANCE ,
-or both, to tell the kernel to return a group of interfaces
-(drivers, like "fxp"), real interface instances (like "fxp1") or both.
+.Li sizeof(struct pfi_kif) .
+.Pp
The data is returned in the
-.Vt pfi_if
+.Vt pfi_kif
structure described below:
.Bd -literal
-struct pfi_if {
- char pfif_name[IFNAMSIZ];
- u_int64_t pfif_packets[2][2][2];
- u_int64_t pfif_bytes[2][2][2];
- u_int64_t pfif_addcnt;
- u_int64_t pfif_delcnt;
- long pfif_tzero;
- int pfif_states;
- int pfif_rules;
- int pfif_flags;
+struct pfi_kif {
+ RB_ENTRY(pfi_kif) pfik_tree;
+ char pfik_name[IFNAMSIZ];
+ u_int64_t pfik_packets[2][2][2];
+ u_int64_t pfik_bytes[2][2][2];
+ u_int32_t pfik_tzero;
+ int pfik_flags;
+ struct pf_state_tree_lan_ext pfik_lan_ext;
+ struct pf_state_tree_ext_gwy pfik_ext_gwy;
+ TAILQ_ENTRY(pfi_kif) pfik_w_states;
+ void *pfik_ah_cookie;
+ struct ifnet *pfik_ifp;
+ struct ifg_group *pfik_group;
+ int pfik_states;
+ int pfik_rules;
+ TAILQ_HEAD(, pfi_dynaddr) pfik_dynaddrs;
};
-
-#define PFI_IFLAG_GROUP 0x0001 /* group of interfaces */
-#define PFI_IFLAG_INSTANCE 0x0002 /* single instance */
-#define PFI_IFLAG_CLONABLE 0x0010 /* clonable group */
-#define PFI_IFLAG_DYNAMIC 0x0020 /* dynamic group */
-#define PFI_IFLAG_ATTACHED 0x0040 /* interface attached */
.Ed
-.It Dv DIOCICLRISTATS Fa "struct pfioc_iface *io"
-Clear the statistics counters of one or more interfaces.
-.Va pfiio_name
-and
-.Va pfiio_flags
-can be used to select which interfaces need to be cleared.
-The filtering process is the same as for
-.Dv DIOCIGETIFACES .
-.Va pfiio_nzero
-will be set by the kernel to the number of interfaces and drivers
-that have been cleared.
.It Dv DIOCSETIFFLAG Fa "struct pfioc_iface *io"
-Set the user setable flags (described below) of the pf internal interface
-description.
+Set the user setable flags (described above) of the
+.Nm
+internal interface description.
The filtering process is the same as for
.Dv DIOCIGETIFACES .
.Bd -literal
-#define PFI_IFLAG_SKIP 0x0100 /* skip interface */
-#define PFI_IFLAG_SETABLE_MASK 0x0100 /* mask */
+#define PFI_IFLAG_SKIP 0x0100 /* skip filtering on interface */
.Ed
.It Dv DIOCCLRIFFLAG Fa "struct pfioc_iface *io"
Works as
diff --git a/contrib/pf/man/pf.conf.5 b/contrib/pf/man/pf.conf.5
index 0a7723c..d0bcd9c 100644
--- a/contrib/pf/man/pf.conf.5
+++ b/contrib/pf/man/pf.conf.5
@@ -1,5 +1,5 @@
.\" $FreeBSD$
-.\" $OpenBSD: pf.conf.5,v 1.292 2004/02/24 05:44:48 mcbride Exp $
+.\" $OpenBSD: pf.conf.5,v 1.376 2006/12/01 07:23:26 camield Exp $
.\"
.\" Copyright (c) 2002, Daniel Hartmeier
.\" All rights reserved.
@@ -63,8 +63,7 @@ Queueing provides rule-based bandwidth control.
Translation rules specify how addresses are to be mapped or redirected to
other addresses.
.It Cm Packet Filtering
-Stateful and stateless packet filtering provides rule-based blocking or
-passing of packets.
+Packet filtering provides rule-based blocking or passing of packets.
.El
.Pp
With the exception of
@@ -81,11 +80,7 @@ enforces this order (see
.Ar set require-order
below).
.Sh MACROS
-Much like
-.Xr cpp 1
-or
-.Xr m4 1 ,
-macros can be defined that will later be expanded in context.
+Macros can be defined that will later be expanded in context.
Macro names must start with a letter, and may contain letters, digits
and underscores.
Macro names may not be reserved words (for example
@@ -98,8 +93,8 @@ For example,
.Bd -literal -offset indent
ext_if = \&"kue0\&"
all_ifs = \&"{\&" $ext_if lo0 \&"}\&"
-pass out on $ext_if from any to any keep state
-pass in on $ext_if proto tcp from any to any port 25 keep state
+pass out on $ext_if from any to any
+pass in on $ext_if proto tcp from any to any port 25
.Ed
.Sh TABLES
Tables are named structures which can hold a collection of addresses and
@@ -182,9 +177,9 @@ when running with
.Pp
For example,
.Bd -literal -offset indent
-table <private> const { 10/8, 172.16/12, 192.168/16 }
-table <badhosts> persist
-block on fxp0 from { <private>, <badhosts> } to any
+table \*(Ltprivate\*(Gt const { 10/8, 172.16/12, 192.168/16 }
+table \*(Ltbadhosts\*(Gt persist
+block on fxp0 from { \*(Ltprivate\*(Gt, \*(Ltbadhosts\*(Gt } to any
.Ed
.Pp
creates a table called private, to hold RFC 1918 private network
@@ -202,8 +197,8 @@ these hosts can be blocked by using
A table can also be initialized with an address list specified in one or more
external files, using the following syntax:
.Bd -literal -offset indent
-table <spam> persist file \&"/etc/spammers\&" file \&"/etc/openrelays\&"
-block on fxp0 from <spam> to any
+table \*(Ltspam\*(Gt persist file \&"/etc/spammers\&" file \&"/etc/openrelays\&"
+block on fxp0 from \*(Ltspam\*(Gt to any
.Ed
.Pp
The files
@@ -218,7 +213,7 @@ When the resolver is called to add a hostname to a table,
.Em all
resulting IPv4 and IPv6 addresses are placed into the table.
IP addresses can also be entered in a table by specifying a valid interface
-name or the
+name, a valid interface group or the
.Em self
keyword, in which case all addresses assigned to the interface(s) will be
added to the table.
@@ -311,7 +306,12 @@ This value is used to define the scale factor, it should not actually
be reached (set a lower state limit, see below).
.El
.Pp
-These values can be defined both globally and for each rule.
+Adaptive timeouts are enabled by default, with an adaptive.start value
+equal to 60% of the state limit, and an adaptive.end value equal to
+120% of the state limit.
+They can be disabled by setting both adaptive.start and adaptive.end to 0.
+.Pp
+The adaptive timeout values can be defined both globally and for each rule.
When used on a per-rule basis, the values relate to the number of
states created by the rule, otherwise to the total number of
states.
@@ -359,8 +359,10 @@ set limit states 20000
.Pp
sets the maximum number of entries in the memory pool used by state table
entries (generated by
-.Ar keep state
-rules) to 20000.
+.Ar pass
+rules which do not specify
+.Ar no state )
+to 20000.
Using
.Bd -literal -offset indent
set limit frags 20000
@@ -370,7 +372,7 @@ sets the maximum number of entries in the memory pool used for fragment
reassembly (generated by
.Ar scrub
rules) to 20000.
-Finally,
+Using
.Bd -literal -offset indent
set limit src-nodes 2000
.Ed
@@ -379,16 +381,63 @@ sets the maximum number of entries in the memory pool used for tracking
source IP addresses (generated by the
.Ar sticky-address
and
-.Ar source-track
+.Ar src.track
options) to 2000.
+Using
+.Bd -literal -offset indent
+set limit tables 1000
+set limit table-entries 100000
+.Ed
+.Pp
+sets limits on the memory pools used by tables.
+The first limits the number of tables that can exist to 1000.
+The second limits the overall number of addresses that can be stored
+in tables to 100000.
.Pp
-These can be combined:
+Various limits can be combined on a single line:
.Bd -literal -offset indent
set limit { states 20000, frags 20000, src-nodes 2000 }
.Ed
.Pp
+.It Ar set ruleset-optimization
+.Bl -tag -width xxxxxxxx -compact
+.It Ar none
+Disable the ruleset optimizer.
+This is the default behaviour.
+.It Ar basic
+Enable basic ruleset optimization, which does four things to improve the
+performance of ruleset evaluations:
+.Pp
+.Bl -enum -compact
+.It
+remove duplicate rules
+.It
+remove rules that are a subset of another rule
+.It
+combine multiple rules into a table when advantageous
+.It
+re-order the rules to improve evaluation performance
+.El
+.Pp
+.It Ar profile
+Uses the currently loaded ruleset as a feedback profile to tailor the
+ordering of quick rules to actual network traffic.
+.El
+.Pp
+It is important to note that the ruleset optimizer will modify the ruleset
+to improve performance.
+A side effect of the ruleset modification is that per-rule accounting
+statistics will have different meanings than before.
+If per-rule accounting is important for billing purposes or whatnot,
+either the ruleset optimizer should not be used or a label field should
+be added to all of the accounting rules to act as optimization barriers.
+.Pp
+Optimization can also be set as a command-line argument to
+.Xr pfctl 8 ,
+overriding the settings in
+.Nm .
.It Ar set optimization
-Optimize the engine for one of the following network environments:
+Optimize state timeouts for one of the following network environments:
.Pp
.Bl -tag -width xxxx -compact
.It Ar normal
@@ -443,8 +492,6 @@ option sets the default behaviour for states:
.Bl -tag -width group-bound -compact
.It Ar if-bound
States are bound to interface.
-.It Ar group-bound
-States are bound to interface group (i.e. ppp)
.It Ar floating
States can match packets on any interfaces (the default).
.El
@@ -453,6 +500,21 @@ For example:
.Bd -literal -offset indent
set state-policy if-bound
.Ed
+.It Ar set hostid
+The 32-bit
+.Ar hostid
+identifies this firewall's state table entries to other firewalls
+in a
+.Xr pfsync 4
+failover cluster.
+By default the hostid is set to a pseudo-random value, however it may be
+desirable to manually configure it, for example to more easily identify the
+source of state table entries.
+.Bd -literal -offset indent
+set hostid 1
+.Ed
+.Pp
+The hostid may be specified in either decimal or hexadecimal.
.It Ar set require-order
By default
.Xr pfctl 8
@@ -484,7 +546,7 @@ For example:
.Pp
.Dl set fingerprints \&"/etc/pf.os.devel\&"
.Pp
-.It Ar set skip on <ifspec>
+.It Ar set skip on Aq Ar ifspec
List interfaces for which packets should not be filtered.
Packets passing in or out on such interfaces are passed as if pf was
disabled, i.e. pf does not process them in any way.
@@ -551,9 +613,9 @@ Using the
modifier (see below) is recommended in combination with the
.Ar no-df
modifier to ensure unique IP identifiers.
-.It Ar min-ttl <number>
+.It Ar min-ttl Aq Ar number
Enforces a minimum TTL for matching IP packets.
-.It Ar max-mss <number>
+.It Ar max-mss Aq Ar number
Enforces a maximum MSS for matching TCP packets.
.It Ar random-id
Replaces the IP identification field with random values to compensate
@@ -772,9 +834,9 @@ declaration.
.Ar altq on
has the following keywords:
.Bl -tag -width xxxx
-.It Ar <interface>
+.It Aq Ar interface
Queueing is enabled on the named interface.
-.It Ar <scheduler>
+.It Aq Ar scheduler
Specifies which queueing scheduler to use.
Currently supported values
are
@@ -784,7 +846,7 @@ for Class Based Queueing,
for Priority Queueing and
.Ar hfsc
for the Hierarchical Fair Service Curve scheduler.
-.It Ar bandwidth <bw>
+.It Ar bandwidth Aq Ar bw
The maximum bitrate for all queues on an
interface may be specified using the
.Ar bandwidth
@@ -802,15 +864,17 @@ gigabits per second, respectively.
The value must not exceed the interface bandwidth.
If
.Ar bandwidth
-is not specified, the interface bandwidth is used.
-.It Ar qlimit <limit>
+is not specified, the interface bandwidth is used
+(but take note that some interfaces do not know their bandwidth,
+or can adapt their bandwidth rates).
+.It Ar qlimit Aq Ar limit
The maximum number of packets held in the queue.
The default is 50.
-.It Ar tbrsize <size>
+.It Ar tbrsize Aq Ar size
Adjusts the size, in bytes, of the token bucket regulator.
If not specified, heuristics based on the
interface bandwidth are used to determine the size.
-.It Ar queue <list>
+.It Ar queue Aq Ar list
Defines a list of subqueues to create on an interface.
.El
.Pp
@@ -839,10 +903,10 @@ in a parent
declaration.
The following keywords can be used:
.Bl -tag -width xxxx
-.It Ar on <interface>
+.It Ar on Aq Ar interface
Specifies the interface the queue operates on.
If not given, it operates on all matching interfaces.
-.It Ar bandwidth <bw>
+.It Ar bandwidth Aq Ar bw
Specifies the maximum bitrate to be processed by the queue.
This value must not exceed the value of the parent
.Ar queue
@@ -852,7 +916,7 @@ If not specified, defaults to 100% of the parent queue's bandwidth.
The
.Ar priq
scheduler does not support bandwidth specification.
-.It Ar priority <level>
+.It Ar priority Aq Ar level
Between queues a priority level can be set.
For
.Ar cbq
@@ -868,7 +932,7 @@ queues with a higher priority are always served first.
and
.Ar Hfsc
queues with a higher priority are preferred in the case of overload.
-.It Ar qlimit <limit>
+.It Ar qlimit Aq Ar limit
The maximum number of packets held in the queue.
The default is 50.
.El
@@ -876,7 +940,9 @@ The default is 50.
The
.Ar scheduler
can get additional parameters with
-.Ar <scheduler> Ns Li (\& Ar <parameters> No ) .
+.Xo Aq Ar scheduler
+.Pf ( Aq Ar parameters ) .
+.Xc
Parameters are as follows:
.Bl -tag -width Fl
.It Ar default
@@ -910,15 +976,16 @@ The
.Ar scheduler
supports some additional options:
.Bl -tag -width Fl
-.It Ar realtime <sc>
+.It Ar realtime Aq Ar sc
The minimum required bandwidth for the queue.
-.It Ar upperlimit <sc>
+.It Ar upperlimit Aq Ar sc
The maximum allowed bandwidth for the queue.
-.It Ar linkshare <sc>
+.It Ar linkshare Aq Ar sc
The bandwidth share of a backlogged queue.
.El
.Pp
-<sc> is an acronym for
+.Aq Ar sc
+is an acronym for
.Ar service curve .
.Pp
The format for service curve specifications is
@@ -982,13 +1049,13 @@ queue ssh_bulk bandwidth 50% priority 0 cbq(borrow)
block return out on dc0 inet all queue std
pass out on dc0 inet proto tcp from $developerhosts to any port 80 \e
- keep state queue developers
+ queue developers
pass out on dc0 inet proto tcp from $employeehosts to any port 80 \e
- keep state queue employees
+ queue employees
pass out on dc0 inet proto tcp from any to any port 22 \e
- keep state queue(ssh_bulk, ssh_interactive)
+ queue(ssh_bulk, ssh_interactive)
pass out on dc0 inet proto tcp from any to any port 25 \e
- keep state queue mail
+ queue mail
.Ed
.Sh TRANSLATION
Translation rules modify either the source or destination address of the
@@ -1048,9 +1115,9 @@ The packet is redirected to another destination and possibly a
different port.
.Ar rdr
rules can optionally specify port ranges instead of single ports.
-rdr ... port 2000:2999 -> ... port 4000
+rdr ... port 2000:2999 -\*(Gt ... port 4000
redirects ports 2000 to 2999 (inclusive) to port 4000.
-rdr ... port 2000:2999 -> ... port 4000:*
+rdr ... port 2000:2999 -\*(Gt ... port 4000:*
redirects port 2000 to 4000, 2001 to 4001, ..., 2999 to 4999.
.El
.Pp
@@ -1068,8 +1135,17 @@ Port numbers are never translated with a
.Ar binat
rule.
.Pp
-For each packet processed by the translator, the translation rules are
-evaluated in sequential order, from first to last.
+Evaluation order of the translation rules is dependent on the type
+of the translation rules and of the direction of a packet.
+.Ar binat
+rules are always evaluated first.
+Then either the
+.Ar rdr
+rules are evaluated on an inbound packet or the
+.Ar nat
+rules on an outbound packet.
+Rules of the same type are evaluated in the same order in which they
+appear in the ruleset.
The first matching rule decides what action is taken.
.Pp
The
@@ -1095,7 +1171,7 @@ or to the firewall itself.
Note that redirecting external incoming connections to the loopback
address, as in
.Bd -literal -offset indent
-rdr on ne3 inet proto tcp to port 8025 -> 127.0.0.1 port 25
+rdr on ne3 inet proto tcp to port spamd -\*(Gt 127.0.0.1 port smtp
.Ed
.Pp
will effectively allow an external host to connect to daemons
@@ -1131,6 +1207,8 @@ assigned to queues for the purpose of bandwidth control.
For each packet processed by the packet filter, the filter rules are
evaluated in sequential order, from first to last.
The last matching rule decides what action is taken.
+If no rule matches the packet, the default action is to pass
+the packet.
.Pp
The following actions can be used in the filter:
.Bl -tag -width xxxx
@@ -1170,24 +1248,87 @@ Options returning ICMP packets currently have no effect if
operates on a
.Xr if_bridge 4 ,
as the code to support this feature has not yet been implemented.
+.Pp
+The simplest mechanism to block everything by default and only pass
+packets that match explicit rules is specify a first filter rule of:
+.Bd -literal -offset indent
+block all
+.Ed
.It Ar pass
-The packet is passed.
+The packet is passed;
+state is created state unless the
+.Ar no state
+option is specified.
.El
.Pp
-If no rule matches the packet, the default action is
-.Ar pass .
+By default
+.Xr pf 4
+filters packets statefully; the first time a packet matches a
+.Ar pass
+rule, a state entry is created; for subsequent packets the filter checks
+whether the packet matches any state.
+If it does, the packet is passed without evaluation of any rules.
+After the connection is closed or times out, the state entry is automatically
+removed.
.Pp
-To block everything by default and only pass packets
-that match explicit rules, one uses
+This has several advantages.
+For TCP connections, comparing a packet to a state involves checking
+its sequence numbers, as well as TCP timestamps if a
+.Ar scrub reassemble tcp
+rule applies to the connection.
+If these values are outside the narrow windows of expected
+values, the packet is dropped.
+This prevents spoofing attacks, such as when an attacker sends packets with
+a fake source address/port but does not know the connection's sequence
+numbers.
+Similarly,
+.Xr pf 4
+knows how to match ICMP replies to states.
+For example,
.Bd -literal -offset indent
-block all
+pass out inet proto icmp all icmp-type echoreq
.Ed
.Pp
-as the first filter rule.
+allows echo requests (such as those created by
+.Xr ping 8 )
+out statefully, and matches incoming echo replies correctly to states.
.Pp
+Also, looking up states is usually faster than evaluating rules.
+If there are 50 rules, all of them are evaluated sequentially in O(n).
+Even with 50000 states, only 16 comparisons are needed to match a
+state, since states are stored in a binary search tree that allows
+searches in O(log2 n).
+.Pp
+Furthermore, correct handling of ICMP error messages is critical to
+many protocols, particularly TCP.
+.Xr pf 4
+matches ICMP error messages to the correct connection, checks them against
+connection parameters, and passes them if appropriate.
+For example if an ICMP source quench message referring to a stateful TCP
+connection arrives, it will be matched to the state and get passed.
+.Pp
+Finally, state tracking is required for
+.Ar nat , binat No and Ar rdr
+rules, in order to track address and port translations and reverse the
+translation on returning packets.
+.Pp
+.Xr pf 4
+will also create state for other protocols which are effectively stateless by
+nature.
+UDP packets are matched to states using only host addresses and ports,
+and other protocols are matched to states using only the host addresses.
+.Pp
+If stateless filtering of individual packets is desired,
+the
+.Ar no state
+keyword can be used to specify that state will not be created
+if this is the last matching rule.
+A number of parameters can also be set to affect how
+.Xr pf 4
+handles state tracking.
See
-.Sx FILTER EXAMPLES
-below.
+.Sx STATEFUL TRACKING OPTIONS
+below for further details.
.Sh PARAMETERS
The rule parameters specify the packets to which a rule applies.
A packet always comes in on, or goes out through, one interface.
@@ -1207,22 +1348,14 @@ nor
are specified, the rule will match packets in both directions.
.It Ar log
In addition to the action specified, a log message is generated.
-All packets for that connection are logged, unless the
-.Ar keep state ,
-.Ar modulate state
-or
-.Ar synproxy state
-options are specified, in which case only the
-packet that establishes the state is logged.
-(See
-.Ar keep state ,
-.Ar modulate state
-and
-.Ar synproxy state
-below).
-The logged packets are sent to the
+Only the packet that establishes the state is logged,
+unless the
+.Ar no state
+option is specified.
+The logged packets are sent to a
.Xr pflog 4
-interface.
+interface, by default
+.Ar pflog0 .
This interface is monitored by the
.Xr pflogd 8
logging daemon, which dumps the logged packets to the file
@@ -1230,35 +1363,53 @@ logging daemon, which dumps the logged packets to the file
in
.Xr pcap 3
binary format.
-.It Ar log-all
-Used with
-.Ar keep state ,
-.Ar modulate state
-or
-.Ar synproxy state
-rules to force logging of all packets for a connection.
+.It Ar log (all)
+Used to force logging of all packets for a connection.
+This is not necessary when
+.Ar no state
+is explicitly specified.
As with
.Ar log ,
packets are logged to
.Xr pflog 4 .
+.It Ar log (user)
+Logs the
+.Ux
+user ID of the user that owns the socket and the PID of the process that
+has the socket open where the packet is sourced from or destined to
+(depending on which socket is local).
+This is in addition to the normal information logged.
+.Pp
+Due to the problems described in the BUGS section only the first packet
+logged via
+.Ar log (all, user)
+will have the user credentials logged when using stateful matching.
+.It Ar log (to Aq Ar interface )
+Send logs to the specified
+.Xr pflog 4
+interface instead of
+.Ar pflog0 .
.It Ar quick
If a packet matches a rule which has the
.Ar quick
option set, this rule
is considered the last matching rule, and evaluation of subsequent rules
is skipped.
-.It Ar on <interface>
+.It Ar on Aq Ar interface
This rule applies only to packets coming in on, or going out through, this
-particular interface.
-It is also possible to simply give the interface driver name, like ppp or fxp,
-to make the rule match packets flowing through a group of interfaces.
-.It Ar <af>
+particular interface or interface group.
+For more information on interface groups,
+see the
+.Ic group
+keyword in
+.Xr ifconfig 8 .
+.It Aq Ar af
This rule applies only to packets of this address family.
Supported values are
.Ar inet
and
.Ar inet6 .
-.It Ar proto <protocol>
+.It Ar proto Aq Ar protocol
This rule applies only to packets of this protocol.
Common protocols are
.Xr icmp 4 ,
@@ -1271,8 +1422,11 @@ For a list of all the protocol name to number mappings used by
see the file
.Em /etc/protocols .
.It Xo
-.Ar from <source> port <source> os <source>
-.Ar to <dest> port <dest>
+.Ar from Aq Ar source
+.Ar port Aq Ar source
+.Ar os Aq Ar source
+.Ar to Aq Ar dest
+.Ar port Aq Ar dest
.Xc
This rule applies only to packets with the specified source and destination
addresses and ports.
@@ -1283,16 +1437,20 @@ symbolic host names or interface names, or as any of the following keywords:
.Bl -tag -width xxxxxxxxxxxxxx -compact
.It Ar any
Any address.
-.It Ar route <label>
+.It Ar route Aq Ar label
Any address whose associated route has label
-.Ar <label> .
+.Aq Ar label .
See
.Xr route 4
and
.Xr route 8 .
.It Ar no-route
Any address which is not currently routable.
-.It Ar <table>
+.It Ar urpf-failed
+Any source address that fails a unicast reverse path forwarding (URPF)
+check, i.e. packets coming in on an interface other than that which holds
+the route back to the packet's source address.
+.It Aq Ar table
Any address that matches the given table.
.El
.Pp
@@ -1339,30 +1497,33 @@ Ports and ranges of ports are specified by using these operators:
.Bd -literal -offset indent
= (equal)
!= (unequal)
-< (less than)
-<= (less than or equal)
-> (greater than)
->= (greater than or equal)
+\*(Lt (less than)
+\*(Le (less than or equal)
+\*(Gt (greater than)
+\*(Ge (greater than or equal)
: (range including boundaries)
->< (range excluding boundaries)
-<> (except range)
+\*(Gt\*(Lt (range excluding boundaries)
+\*(Lt\*(Gt (except range)
.Ed
.Pp
-><, <> and :
+.Sq \*(Gt\*(Lt ,
+.Sq \*(Lt\*(Gt
+and
+.Sq \&:
are binary operators (they take two arguments).
For instance:
.Bl -tag -width Fl
.It Ar port 2000:2004
means
-.Sq all ports >= 2000 and <= 2004 ,
+.Sq all ports \*(Ge 2000 and \*(Le 2004 ,
hence ports 2000, 2001, 2002, 2003 and 2004.
-.It Ar port 2000 >< 2004
+.It Ar port 2000 \*(Gt\*(Lt 2004
means
-.Sq all ports > 2000 and < 2004 ,
+.Sq all ports \*(Gt 2000 and \*(Lt 2004 ,
hence ports 2001, 2002 and 2003.
-.It Ar port 2000 <> 2004
+.It Ar port 2000 \*(Lt\*(Gt 2004
means
-.Sq all ports < 2000 or > 2004 ,
+.Sq all ports \*(Lt 2000 or \*(Gt 2004 ,
hence ports 1-1999 and 2005-65535.
.El
.Pp
@@ -1378,16 +1539,16 @@ The host, port and OS specifications are optional, as in the following examples:
.Bd -literal -offset indent
pass in all
pass in from any to any
-pass in proto tcp from any port <= 1024 to any
+pass in proto tcp from any port \*(Le 1024 to any
pass in proto tcp from any to any port 25
-pass in proto tcp from 10.0.0.0/8 port > 1024 \e
+pass in proto tcp from 10.0.0.0/8 port \*(Gt 1024 \e
to ! 10.1.2.3 port != ssh
-pass in proto tcp from any os "OpenBSD" flags S/SA
+pass in proto tcp from any os "OpenBSD"
pass in proto tcp from route "DTAG"
.Ed
.It Ar all
This is equivalent to "from any to any".
-.It Ar group <group>
+.It Ar group Aq Ar group
Similar to
.Ar user ,
this rule only applies to packets of sockets owned by the specified group.
@@ -1402,7 +1563,7 @@ environments may result in a deadlock.
Please see the
.Sx BUGS
section for details.
-.It Ar user <user>
+.It Ar user Aq Ar user
This rule only applies to packets of sockets owned by the specified user.
For outgoing connections initiated from the firewall, this is the user
that opened the connection.
@@ -1435,7 +1596,7 @@ can only be used with the operators
and
.Cm != .
Other constructs like
-.Cm user >= unknown
+.Cm user \*(Ge unknown
are invalid.
Forwarded packets with unknown user and group ID match only rules
that explicitly compare against
@@ -1445,29 +1606,37 @@ with the operators
or
.Cm != .
For instance
-.Cm user >= 0
+.Cm user \*(Ge 0
does not match forwarded packets.
The following example allows only selected users to open outgoing
connections:
.Bd -literal -offset indent
block out proto { tcp, udp } all
-pass out proto { tcp, udp } all \e
- user { < 1000, dhartmei } keep state
+pass out proto { tcp, udp } all user { \*(Lt 1000, dhartmei }
.Ed
-.It Ar flags <a>/<b> | /<b>
+.It Xo Ar flags Aq Ar a
+.Pf / Ns Aq Ar b
+.No \*(Ba / Ns Aq Ar b
+.No \*(Ba any
+.Xc
This rule only applies to TCP packets that have the flags
-.Ar <a>
+.Aq Ar a
set out of set
-.Ar <b> .
+.Aq Ar b .
Flags not specified in
-.Ar <b>
+.Aq Ar b
are ignored.
+For stateful connections, the default is
+.Ar flags S/SA .
+To indicate that flags should not be checkd at all, specify
+.Ar flags any .
The flags are: (F)IN, (S)YN, (R)ST, (P)USH, (A)CK, (U)RG, (E)CE, and C(W)R.
.Bl -tag -width Fl
.It Ar flags S/S
Flag SYN is set.
The other flags are ignored.
.It Ar flags S/SA
+This is the default setting for stateful connections.
Out of SYN and ACK, exactly SYN may be set.
SYN, SYN+PSH and SYN+RST match, but SYN+ACK, ACK and ACK+RST do not.
This is more restrictive than the previous example.
@@ -1475,8 +1644,38 @@ This is more restrictive than the previous example.
If the first set is not specified, it defaults to none.
All of SYN, FIN, RST and ACK must be unset.
.El
-.It Ar icmp-type <type> code <code>
-.It Ar icmp6-type <type> code <code>
+.Pp
+Because
+.Ar flags S/SA
+is applied by default (unless
+.Ar no state
+is specified), only the initial SYN packet of a TCP handshake will create
+a state for a TCP connection.
+It is possible to be less restrictive, and allow state creation from
+intermediate
+.Pq non-SYN
+packets, by specifying
+.Ar flags any .
+This will cause
+.Xr pf 4
+to synchronize to existing connections, for instance
+if one flushes the state table.
+However, states created from such intermediate packets may be missing
+connection details such as the TCP window scaling factor.
+States which modify the packet flow, such as those affected by
+.Ar nat , binat No or Ar rdr
+rules,
+.Ar modulate No or Ar synproxy state
+options, or scrubbed with
+.Ar reassemble tcp
+will also not be recoverable from intermediate packets.
+Such connections will stall and time out.
+.It Xo Ar icmp-type Aq Ar type
+.Ar code Aq Ar code
+.Xc
+.It Xo Ar icmp6-type Aq Ar type
+.Ar code Aq Ar code
+.Xc
This rule only applies to ICMP or ICMPv6 packets with the specified type
and code.
Text names for ICMP types and codes are listed in
@@ -1492,6 +1691,26 @@ or
.Ar icmp6-type
.Pc
must match.
+.It Xo Ar tos Aq Ar string
+.No \*(Ba Aq Ar number
+.Xc
+This rule applies to packets with the specified
+.Em TOS
+bits set.
+.Em TOS
+may be
+given as one of
+.Ar lowdelay ,
+.Ar throughput ,
+.Ar reliability ,
+or as either hex or decimal.
+.Pp
+For example, the following rules are identical:
+.Bd -literal -offset indent
+pass all tos lowdelay
+pass all tos 0x10
+pass all tos 16
+.Ed
.It Ar allow-opts
By default, IPv4 packets with IP options or IPv6 packets with routing
extension headers are blocked.
@@ -1507,7 +1726,7 @@ The implicit
.Ar pass
rule that is used when a packet does not match any rules does not
allow IP options.
-.It Ar label <string>
+.It Ar label Aq Ar string
Adds a label (name) to the rule, which can be used to identify the rule.
For instance,
pfctl -s labels
@@ -1536,24 +1755,27 @@ For example:
.Bd -literal -offset indent
ips = \&"{ 1.2.3.4, 1.2.3.5 }\&"
pass in proto tcp from any to $ips \e
- port > 1023 label \&"$dstaddr:$dstport\&"
+ port \*(Gt 1023 label \&"$dstaddr:$dstport\&"
.Ed
.Pp
expands to
.Bd -literal -offset indent
pass in inet proto tcp from any to 1.2.3.4 \e
- port > 1023 label \&"1.2.3.4:>1023\&"
+ port \*(Gt 1023 label \&"1.2.3.4:\*(Gt1023\&"
pass in inet proto tcp from any to 1.2.3.5 \e
- port > 1023 label \&"1.2.3.5:>1023\&"
+ port \*(Gt 1023 label \&"1.2.3.5:\*(Gt1023\&"
.Ed
.Pp
The macro expansion for the
.Ar label
directive occurs only at configuration file parse time, not during runtime.
-.It Ar queue <queue> | ( <queue> , <queue> )
+.It Xo Ar queue Aq Ar queue
+.No \*(Ba ( Aq Ar queue ,
+.Aq Ar queue )
+.Xc
Packets matching this rule will be assigned to the specified queue.
If two queues are given, packets which have a
-.Em tos
+.Em TOS
of
.Em lowdelay
and TCP ACKs with no data payload will be assigned to the second one.
@@ -1566,7 +1788,7 @@ For example:
pass in proto tcp to port 25 queue mail
pass in proto tcp to port 22 queue(ssh_bulk, ssh_prio)
.Ed
-.It Ar tag <string>
+.It Ar tag Aq Ar string
Packets matching this rule will be tagged with the
specified string.
The tag acts as an internal marker that can be used to
@@ -1581,14 +1803,6 @@ is not the last matching rule.
Further matching rules can replace the tag with a
new one but will not remove a previously applied tag.
A packet is only ever assigned one tag at a time.
-.Ar pass
-rules that use the
-.Ar tag
-keyword must also use
-.Ar keep state ,
-.Ar modulate state
-or
-.Ar synproxy state .
Packet tagging can be done during
.Ar nat ,
.Ar rdr ,
@@ -1596,7 +1810,7 @@ or
.Ar binat
rules in addition to filter rules.
Tags take the same macros as labels (see above).
-.It Ar tagged <string>
+.It Ar tagged Aq Ar string
Used with filter or translation rules to specify that packets must already
be tagged with the given tag in order to match the rule.
Inverse tag matching can also be done
@@ -1605,7 +1819,10 @@ by specifying the
operator before the
.Ar tagged
keyword.
-.It Ar probability <number>
+.It Ar rtable Aq Ar number
+Used to select an alternate routing table for the routing lookup.
+Only effective before the route lookup happened, i.e. when filtering inbound.
+.It Ar probability Aq Ar number
A probability attribute can be attached to a rule, with a value set between
0 and 1, bounds not included.
In that case, the rule will be honoured using the given probability value
@@ -1727,124 +1944,6 @@ beyond the lifetime of the states, increase the global options with
See
.Sx STATEFUL TRACKING OPTIONS
for more ways to control the source tracking.
-.Sh STATEFUL INSPECTION
-.Xr pf 4
-is a stateful packet filter, which means it can track the state of
-a connection.
-Instead of passing all traffic to port 25, for instance, it is possible
-to pass only the initial packet, and then begin to keep state.
-Subsequent traffic will flow because the filter is aware of the connection.
-.Pp
-If a packet matches a
-.Ar pass ... keep state
-rule, the filter creates a state for this connection and automatically
-lets pass all subsequent packets of that connection.
-.Pp
-Before any rules are evaluated, the filter checks whether the packet
-matches any state.
-If it does, the packet is passed without evaluation of any rules.
-.Pp
-States are removed after the connection is closed or has timed out.
-.Pp
-This has several advantages.
-Comparing a packet to a state involves checking its sequence numbers.
-If the sequence numbers are outside the narrow windows of expected
-values, the packet is dropped.
-This prevents spoofing attacks, such as when an attacker sends packets with
-a fake source address/port but does not know the connection's sequence
-numbers.
-.Pp
-Also, looking up states is usually faster than evaluating rules.
-If there are 50 rules, all of them are evaluated sequentially in O(n).
-Even with 50000 states, only 16 comparisons are needed to match a
-state, since states are stored in a binary search tree that allows
-searches in O(log2 n).
-.Pp
-For instance:
-.Bd -literal -offset indent
-block all
-pass out proto tcp from any to any flags S/SA keep state
-pass in proto tcp from any to any port 25 flags S/SA keep state
-.Ed
-.Pp
-This ruleset blocks everything by default.
-Only outgoing connections and incoming connections to port 25 are allowed.
-The initial packet of each connection has the SYN
-flag set, will be passed and creates state.
-All further packets of these connections are passed if they match a state.
-.Pp
-By default, packets coming in and out of any interface can match a state,
-but it is also possible to change that behaviour by assigning states to a
-single interface or a group of interfaces.
-.Pp
-The default policy is specified by the
-.Ar state-policy
-global option, but this can be adjusted on a per-rule basis by adding one
-of the
-.Ar if-bound ,
-.Ar group-bound
-or
-.Ar floating
-keywords to the
-.Ar keep state
-option.
-For example, if a rule is defined as:
-.Bd -literal -offset indent
-pass out on ppp from any to 10.12/16 keep state (group-bound)
-.Ed
-.Pp
-A state created on ppp0 would match packets an all PPP interfaces,
-but not packets flowing through fxp0 or any other interface.
-.Pp
-Keeping rules
-.Ar floating
-is the more flexible option when the firewall is in a dynamic routing
-environment.
-However, this has some security implications since a state created by one
-trusted network could allow potentially hostile packets coming in from other
-interfaces.
-.Pp
-Specifying
-.Ar flags S/SA
-restricts state creation to the initial SYN
-packet of the TCP handshake.
-One can also be less restrictive, and allow state creation from
-intermediate
-.Pq non-SYN
-packets.
-This will cause
-.Xr pf 4
-to synchronize to existing connections, for instance
-if one flushes the state table.
-.Pp
-For UDP, which is stateless by nature,
-.Ar keep state
-will create state as well.
-UDP packets are matched to states using only host addresses and ports.
-.Pp
-ICMP messages fall into two categories: ICMP error messages, which always
-refer to a TCP or UDP packet, are matched against the referred to connection.
-If one keeps state on a TCP connection, and an ICMP source quench message
-referring to this TCP connection arrives, it will be matched to the right
-state and get passed.
-.Pp
-For ICMP queries,
-.Ar keep state
-creates an ICMP state, and
-.Xr pf 4
-knows how to match ICMP replies to states.
-For example,
-.Bd -literal -offset indent
-pass out inet proto icmp all icmp-type echoreq keep state
-.Ed
-.Pp
-allows echo requests (such as those created by
-.Xr ping 8 )
-out, creates state, and matches incoming echo replies correctly to states.
-.Pp
-Note:
-.Ar nat , binat No and Ar rdr
-rules implicitly create state for connections.
.Sh STATE MODULATION
Much of the security derived from TCP is attributable to how well the
initial sequence numbers (ISNs) are chosen.
@@ -1867,25 +1966,10 @@ For instance:
.Bd -literal -offset indent
block all
pass out proto tcp from any to any modulate state
-pass in proto tcp from any to any port 25 flags S/SA modulate state
+pass in proto tcp from any to any port 25 flags S/SFRA modulate state
.Ed
.Pp
-There are two caveats associated with state modulation:
-A
-.Ar modulate state
-rule can not be applied to a pre-existing but unmodulated connection.
-Such an application would desynchronize TCP's strict
-sequencing between the two endpoints.
-Instead,
-.Xr pf 4
-will treat the
-.Ar modulate state
-modifier as a
-.Ar keep state
-modifier and the pre-existing connection will be inferred without
-the protection conferred by modulation.
-.Pp
-The other caveat affects currently modulated states when the state table
+Note that modulated connections will not recover when the state table
is lost (firewall reboot, flushing the state table, etc...).
.Xr pf 4
will not be able to infer a connection again after the state table flushes
@@ -1894,11 +1978,20 @@ When the state is lost, the connection may be left dangling until the
respective endpoints time out the connection.
It is possible on a fast local network for the endpoints to start an ACK
storm while trying to resynchronize after the loss of the modulator.
-Using a
-.Ar flags S/SA
-modifier on
+The default
+.Ar flags
+settings (or a more strict equivalent) should be used on
.Ar modulate state
-rules between fast networks is suggested to prevent ACK storms.
+rules to prevent ACK storms.
+.Pp
+Note that alternative methods are available
+to prevent loss of the state table
+and allow for firewall failover.
+See
+.Xr carp 4
+and
+.Xr pfsync 4
+for further information.
.Sh SYN PROXY
By default,
.Xr pf 4
@@ -1924,12 +2017,9 @@ chooses random initial sequence numbers for both handshakes.
Once the handshakes are completed, the sequence number modulators
(see previous section) are used to translate further packets of the
connection.
-Hence,
.Ar synproxy state
includes
-.Ar modulate state
-and
-.Ar keep state .
+.Ar modulate state .
.Pp
Rules with
.Ar synproxy
@@ -1940,18 +2030,21 @@ operates on a
.Pp
Example:
.Bd -literal -offset indent
-pass in proto tcp from any to any port www flags S/SA synproxy state
+pass in proto tcp from any to any port www synproxy state
.Ed
.Sh STATEFUL TRACKING OPTIONS
-All three of
+A number of options related to stateful tracking can be applied on a
+per-rule basis.
.Ar keep state ,
.Ar modulate state
and
.Ar synproxy state
-support the following options:
+support these options, and
+.Ar keep state
+must be specified explicitly to apply options to a rule.
.Pp
.Bl -tag -width xxxx -compact
-.It Ar max <number>
+.It Ar max Aq Ar number
Limits the number of concurrent states the rule may create.
When this limit is reached, further packets matching the rule that would
create state are dropped, until existing states time out.
@@ -1959,7 +2052,9 @@ create state are dropped, until existing states time out.
Prevent state changes for states created by this rule from appearing on the
.Xr pfsync 4
interface.
-.It Ar <timeout> <seconds>
+.It Xo Aq Ar timeout
+.Aq Ar seconds
+.Xc
Changes the timeout values used for states created by this rule.
For a list of all valid timeout names, see
.Sx OPTIONS
@@ -1969,7 +2064,7 @@ above.
Multiple options can be specified, separated by commas:
.Bd -literal -offset indent
pass in proto tcp from any to any \e
- port www flags S/SA keep state \e
+ port www keep state \e
(max 100, source-track rule, max-src-nodes 75, \e
max-src-states 3, tcp.established 60, tcp.closing 5)
.Ed
@@ -1983,7 +2078,7 @@ keyword is specified, the number of states per source IP is tracked.
The maximum number of states created by this rule is limited by the rule's
.Ar max-src-nodes
and
-.Ar max-src-state
+.Ar max-src-states
options.
Only state entries created by this particular rule count toward the rule's
limits.
@@ -2000,10 +2095,10 @@ each individual rule's limits.
The following limits can be set:
.Pp
.Bl -tag -width xxxx -compact
-.It Ar max-src-nodes <number>
+.It Ar max-src-nodes Aq Ar number
Limits the maximum number of source addresses which can simultaneously
have state table entries.
-.It Ar max-src-states <number>
+.It Ar max-src-states Aq Ar number
Limits the maximum number of simultaneous state entries that a single
source address can create with this rule.
.El
@@ -2013,10 +2108,12 @@ which have completed the TCP 3-way handshake) can also be enforced
per source IP.
.Pp
.Bl -tag -width xxxx -compact
-.It Ar max-src-conn <number>
+.It Ar max-src-conn Aq Ar number
Limits the maximum number of simultaneous TCP connections which have
completed the 3-way handshake that a single host can make.
-.It Ar max-src-conn-rate <number> / <seconds>
+.It Xo Ar max-src-conn-rate Aq Ar number
+.No / Aq Ar seconds
+.Xc
Limit the rate of new connections over a time interval.
The connection rate is an approximation calculated as a moving average.
.El
@@ -2024,7 +2121,7 @@ The connection rate is an approximation calculated as a moving average.
Because the 3-way handshake ensures that the source address is not being
spoofed, more aggressive action can be taken based on these limits.
With the
-.Ar overload <table>
+.Ar overload Aq Ar table
state option, source IP addresses which hit either of the limits on
established connections will be added to the named table.
This table can be used in the ruleset to block further activity from
@@ -2043,13 +2140,15 @@ offending host, regardless of which rule created the state.
For example, the following rules will protect the webserver against
hosts making more than 100 connections in 10 seconds.
Any host which connects faster than this rate will have its address added
-to the <bad_hosts> table and have all states originating from it flushed.
+to the
+.Aq bad_hosts
+table and have all states originating from it flushed.
Any new packets arriving from this host will be dropped unconditionally
by the block rule.
.Bd -literal -offset indent
-block quick from <bad_hosts>
-pass in on $ext_if proto tcp to $webserver port www flags S/SA keep state \e
- (max-src-conn-rate 100/10, overload <bad_hosts> flush global)
+block quick from \*(Ltbad_hosts\*(Gt
+pass in on $ext_if proto tcp to $webserver port www keep state \e
+ (max-src-conn-rate 100/10, overload \*(Ltbad_hosts\*(Gt flush global)
.Ed
.Sh OPERATING SYSTEM FINGERPRINTING
Passive OS Fingerprinting is a mechanism to inspect nuances of a TCP
@@ -2062,17 +2161,23 @@ upon.
The fingerprints may be specified by operating system class, by
version, or by subtype/patchlevel.
The class of an operating system is typically the vendor or genre
-and would be OpenBSD for the
+and would be
+.Ox
+for the
.Xr pf 4
firewall itself.
-The version of the oldest available OpenBSD release on the main ftp site
+The version of the oldest available
+.Ox
+release on the main FTP site
would be 2.6 and the fingerprint would be written
.Pp
.Dl \&"OpenBSD 2.6\&"
.Pp
The subtype of an operating system is typically used to describe the
patchlevel if that patch led to changes in the TCP stack behavior.
-In the case of OpenBSD, the only subtype is for a fingerprint that was
+In the case of
+.Ox ,
+the only subtype is for a fingerprint that was
normalized by the
.Ar no-df
scrub option and would be specified as
@@ -2100,12 +2205,12 @@ which no operating system fingerprint is known.
.Pp
Examples:
.Bd -literal -offset indent
-pass out proto tcp from any os OpenBSD keep state
+pass out proto tcp from any os OpenBSD
block out proto tcp from any os Doors
block out proto tcp from any os "Doors PT"
block out proto tcp from any os "Doors PT SP3"
block out from any os "unknown"
-pass on lo0 proto tcp from any os "OpenBSD 3.3 lo0" keep state
+pass on lo0 proto tcp from any os "OpenBSD 3.3 lo0"
.Ed
.Pp
Operating system fingerprinting is limited only to the TCP SYN packet.
@@ -2254,25 +2359,28 @@ attachment point
using the following kinds
of rules:
.Bl -tag -width xxxx
-.It Ar nat-anchor <name>
+.It Ar nat-anchor Aq Ar name
Evaluates the
.Ar nat
rules in the specified
.Ar anchor .
-.It Ar rdr-anchor <name>
+.It Ar rdr-anchor Aq Ar name
Evaluates the
.Ar rdr
rules in the specified
.Ar anchor .
-.It Ar binat-anchor <name>
+.It Ar binat-anchor Aq Ar name
Evaluates the
.Ar binat
rules in the specified
.Ar anchor .
-.It Ar anchor <name>
+.It Ar anchor Aq Ar name
Evaluates the filter rules in the specified
.Ar anchor .
-.It Ar load anchor <name> from <file>
+.It Xo Ar load anchor
+.Aq Ar name
+.Ar from Aq Ar file
+.Xc
Loads the rules from the specified file into the
anchor
.Ar name .
@@ -2284,11 +2392,17 @@ rule,
.Xr pf 4
will proceed to evaluate all rules specified in that anchor.
.Pp
-Matching filter and translation rules in anchors with the
+Matching filter and translation rules marked with the
.Ar quick
option are final and abort the evaluation of the rules in other
-anchors
-and the main ruleset.
+anchors and the main ruleset.
+If the
+.Ar anchor
+itself is marked with the
+.Ar quick
+option,
+ruleset evaluation will terminate when the anchor is exited if the packet is
+matched by any rule within the anchor.
.Pp
.Ar anchor
rules are evaluated relative to the anchor in which they are contained.
@@ -2312,9 +2426,9 @@ For example,
ext_if = \&"kue0\&"
block on $ext_if all
anchor spam
-pass out on $ext_if all keep state
+pass out on $ext_if all
pass in on $ext_if proto tcp from any \e
- to $ext_if port smtp keep state
+ to $ext_if port smtp
.Ed
.Pp
blocks all packets on the external interface by default, then evaluates
@@ -2362,8 +2476,8 @@ This allows conditional evaluation of anchors, like:
.Bd -literal -offset indent
block on $ext_if all
anchor spam proto tcp from any to any port smtp
-pass out on $ext_if all keep state
-pass in on $ext_if proto tcp from any to $ext_if port smtp keep state
+pass out on $ext_if all
+pass in on $ext_if proto tcp from any to $ext_if port smtp
.Ed
.Pp
The rules inside
@@ -2418,6 +2532,22 @@ anchor, if any, before finally evaluating the
.Ar pass
rule.
.Pp
+Filter rule
+.Ar anchors
+can also be loaded inline in the ruleset within a brace ('{' '}') delimited
+block.
+Brace delimited blocks may contain rules or other brace-delimited blocks.
+When anchors are loaded this way the anchor name becomes optional.
+.Bd -literal -offset indent
+anchor "external" on egress {
+ block
+ anchor out {
+ pass proto tcp from any to port { 25, 80, 443 }
+ }
+ pass in proto tcp to any port 22
+}
+.Ed
+.Pp
Since the parser specification for anchor names is a string, any
reference to an anchor name containing solidus
.Pq Sq /
@@ -2433,7 +2563,7 @@ and therefore lacks permission to bind to port 80).
ext_if = \&"ne3\&"
# map daemon on 8080 to appear to be on 80
-rdr on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 port 8080
+rdr on $ext_if proto tcp from any to any port 80 -\*(Gt 127.0.0.1 port 8080
.Ed
.Pp
If the
@@ -2441,7 +2571,7 @@ If the
modifier is given, packets matching the translation rule are passed without
inspecting the filter rules:
.Bd -literal
-rdr pass on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 \e
+rdr pass on $ext_if proto tcp from any to any port 80 -\*(Gt 127.0.0.1 \e
port 8080
.Ed
.Pp
@@ -2454,7 +2584,7 @@ network appear as though it is the Internet routable address
for the nodes on vlan12.
(Thus, 192.168.168.1 can talk to the 192.168.168.0/24 nodes.)
.Bd -literal
-nat on ! vlan12 from 192.168.168.0/24 to any -> 204.92.77.111
+nat on ! vlan12 from 192.168.168.0/24 to any -\*(Gt 204.92.77.111
.Ed
.Pp
In the example below, the machine sits between a fake internal 144.19.74.*
@@ -2465,7 +2595,7 @@ rule excludes protocol AH from being translated.
.Bd -literal
# NO NAT
no nat on $ext_if proto ah from 144.19.74.0/24 to any
-nat on $ext_if from 144.19.74.0/24 to any -> 204.92.77.100
+nat on $ext_if from 144.19.74.0/24 to any -\*(Gt 204.92.77.100
.Ed
.Pp
In the example below, packets bound for one specific server, as well as those
@@ -2474,46 +2604,51 @@ generated by the sysadmins are not proxied; all other connections are.
# NO RDR
no rdr on $int_if proto { tcp, udp } from any to $server port 80
no rdr on $int_if proto { tcp, udp } from $sysadmins to any port 80
-rdr on $int_if proto { tcp, udp } from any to any port 80 -> 127.0.0.1 \e
+rdr on $int_if proto { tcp, udp } from any to any port 80 -\*(Gt 127.0.0.1 \e
port 80
.Ed
.Pp
This longer example uses both a NAT and a redirection.
The external interface has the address 157.161.48.183.
-On the internal interface, we are running
+On localhost, we are running
.Xr ftp-proxy 8 ,
-listening for outbound ftp sessions captured to port 8021.
+waiting for FTP sessions to be redirected to it.
+The three mandatory anchors for
+.Xr ftp-proxy 8
+are omitted from this example; see the
+.Xr ftp-proxy 8
+manpage.
.Bd -literal
# NAT
# Translate outgoing packets' source addresses (any protocol).
# In this case, any address but the gateway's external address is mapped.
-nat on $ext_if inet from ! ($ext_if) to any -> ($ext_if)
+nat on $ext_if inet from ! ($ext_if) to any -\*(Gt ($ext_if)
# NAT PROXYING
# Map outgoing packets' source port to an assigned proxy port instead of
# an arbitrary port.
# In this case, proxy outgoing isakmp with port 500 on the gateway.
-nat on $ext_if inet proto udp from any port = isakmp to any -> ($ext_if) \e
+nat on $ext_if inet proto udp from any port = isakmp to any -\*(Gt ($ext_if) \e
port 500
# BINAT
# Translate outgoing packets' source address (any protocol).
# Translate incoming packets' destination address to an internal machine
# (bidirectional).
-binat on $ext_if from 10.1.2.150 to any -> $ext_if
+binat on $ext_if from 10.1.2.150 to any -\*(Gt $ext_if
# RDR
# Translate incoming packets' destination addresses.
# As an example, redirect a TCP and UDP port to an internal machine.
rdr on $ext_if inet proto tcp from any to ($ext_if) port 8080 \e
- -> 10.1.2.151 port 22
+ -\*(Gt 10.1.2.151 port 22
rdr on $ext_if inet proto udp from any to ($ext_if) port 8080 \e
- -> 10.1.2.151 port 53
+ -\*(Gt 10.1.2.151 port 53
# RDR
# Translate outgoing ftp control connections to send them to localhost
# for proxying with ftp-proxy(8) running on port 8021.
-rdr on $int_if proto tcp from any to any port 21 -> 127.0.0.1 port 8021
+rdr on $int_if proto tcp from any to any port 21 -\*(Gt 127.0.0.1 port 8021
.Ed
.Pp
In this example, a NAT gateway is set up to translate internal addresses
@@ -2525,13 +2660,13 @@ network.
# Translate outgoing packets' source addresses using an address pool.
# A given source address is always translated to the same pool address by
# using the source-hash keyword.
-nat on $ext_if inet from any to any -> 192.0.2.16/28 source-hash
+nat on $ext_if inet from any to any -\*(Gt 192.0.2.16/28 source-hash
# RDR ROUND ROBIN
# Translate incoming web server connections to a group of web servers on
# the internal network.
rdr on $ext_if proto tcp from any to any port 80 \e
- -> { 10.1.2.155, 10.1.2.160, 10.1.2.161 } round-robin
+ -\*(Gt { 10.1.2.155, 10.1.2.160, 10.1.2.161 } round-robin
.Ed
.Sh FILTER EXAMPLES
.Bd -literal
@@ -2551,6 +2686,10 @@ block return log on $ext_if all
# block anything coming from source we have no back routes for
block in from no-route to any
+# block packets whose ingress interface does not match the one in
+# the route back to their source address
+block in from urpf-failed to any
+
# block and log outgoing packets that do not have our address as source,
# they are either spoofed or something is misconfigured (NAT disabled,
# for instance), we want to be nice and do not send out garbage.
@@ -2572,15 +2711,15 @@ block in log quick on $ext_if from { 10.0.0.0/8, 172.16.0.0/12, \e
# so replies (like 0/0 for 8/0) will match queries
# ICMP error messages (which always refer to a TCP/UDP packet) are
# handled by the TCP/UDP states
-pass on $ext_if inet proto icmp all icmp-type 8 code 0 keep state
+pass on $ext_if inet proto icmp all icmp-type 8 code 0
# UDP
# pass out all UDP connections and keep state
-pass out on $ext_if proto udp all keep state
+pass out on $ext_if proto udp all
# pass in certain UDP connections and keep state (DNS)
-pass in on $ext_if proto udp from any to any port domain keep state
+pass in on $ext_if proto udp from any to any port domain
# TCP
@@ -2589,18 +2728,19 @@ pass out on $ext_if proto tcp all modulate state
# pass in certain TCP connections and keep state (SSH, SMTP, DNS, IDENT)
pass in on $ext_if proto tcp from any to any port { ssh, smtp, domain, \e
- auth } flags S/SA keep state
-
-# pass in data mode connections for ftp-proxy running on this host.
-# (see ftp-proxy(8) for details)
-pass in on $ext_if proto tcp from any to 157.161.48.183 port >= 49152 \e
- flags S/SA keep state
+ auth }
# Do not allow Windows 9x SMTP connections since they are typically
# a viral worm. Alternately we could limit these OSes to 1 connection each.
block in on $ext_if proto tcp from any os {"Windows 95", "Windows 98"} \e
to any port smtp
+# IPv6
+# pass in/out all IPv6 traffic: note that we have to enable this in two
+# different ways, on both our physical interface and our tunnel
+pass quick on gif0 inet6
+pass quick on $ext_if proto ipv6
+
# Packet Tagging
# three interfaces: $int_if, $ext_if, and $wifi_if (wireless). NAT is
@@ -2609,21 +2749,21 @@ block in on $ext_if proto tcp from any os {"Windows 95", "Windows 98"} \e
# outgoing packets (i.e., packets from the wireless network) are only
# permitted to access port 80.
-pass in on $int_if from any to any tag INTNET keep state
-pass in on $wifi_if from any to any keep state
+pass in on $int_if from any to any tag INTNET
+pass in on $wifi_if from any to any
block out on $ext_if from any to any
-pass out quick on $ext_if tagged INTNET keep state
-pass out on $ext_if proto tcp from any to any port 80 keep state
+pass out quick on $ext_if tagged INTNET
+pass out on $ext_if proto tcp from any to any port 80
# tag incoming packets as they are redirected to spamd(8). use the tag
# to pass those packets through the packet filter.
-rdr on $ext_if inet proto tcp from <spammers> to port smtp \e
- tag SPAMD -> 127.0.0.1 port spamd
+rdr on $ext_if inet proto tcp from \*(Ltspammers\*(Gt to port smtp \e
+ tag SPAMD -\*(Gt 127.0.0.1 port spamd
block in on $ext_if
-pass in on $ext_if inet proto tcp tagged SPAMD keep state
+pass in on $ext_if inet proto tcp tagged SPAMD
.Ed
.Sh GRAMMAR
Syntax for
@@ -2631,59 +2771,66 @@ Syntax for
in BNF:
.Bd -literal
line = ( option | pf-rule | nat-rule | binat-rule | rdr-rule |
- antispoof-rule | altq-rule | queue-rule | anchor-rule |
- trans-anchors | load-anchors | table-rule )
+ antispoof-rule | altq-rule | queue-rule | trans-anchors |
+ anchor-rule | anchor-close | load-anchor | table-rule | )
option = "set" ( [ "timeout" ( timeout | "{" timeout-list "}" ) ] |
+ [ "ruleset-optimization" [ "none" | "basic" | "profile" ]] |
[ "optimization" [ "default" | "normal" |
"high-latency" | "satellite" |
"aggressive" | "conservative" ] ]
[ "limit" ( limit-item | "{" limit-list "}" ) ] |
[ "loginterface" ( interface-name | "none" ) ] |
[ "block-policy" ( "drop" | "return" ) ] |
- [ "state-policy" ( "if-bound" | "group-bound" |
- "floating" ) ]
+ [ "state-policy" ( "if-bound" | "floating" ) ]
[ "require-order" ( "yes" | "no" ) ]
[ "fingerprints" filename ] |
+ [ "skip on" ( interface-name | "{" interface-list "}" ) ] |
[ "debug" ( "none" | "urgent" | "misc" | "loud" ) ] )
pf-rule = action [ ( "in" | "out" ) ]
- [ "log" | "log-all" ] [ "quick" ]
- [ "on" ifspec ] [ route ] [ af ] [ protospec ]
+ [ "log" [ "(" logopts ")"] ] [ "quick" ]
+ [ "on" ifspec ] [ "fastroute" | route ] [ af ] [ protospec ]
hosts [ filteropt-list ]
+logopts = logopt [ "," logopts ]
+logopt = "all" | "user" | "to" interface-name
+
filteropt-list = filteropt-list filteropt | filteropt
filteropt = user | group | flags | icmp-type | icmp6-type | tos |
- ( "keep" | "modulate" | "synproxy" ) "state"
+ ( "no" | "keep" | "modulate" | "synproxy" ) "state"
[ "(" state-opts ")" ] |
"fragment" | "no-df" | "min-ttl" number |
"max-mss" number | "random-id" | "reassemble tcp" |
fragmentation | "allow-opts" |
- "label" string | "tag" string | [ ! ] "tagged" string
+ "label" string | "tag" string | [ ! ] "tagged" string |
"queue" ( string | "(" string [ [ "," ] string ] ")" ) |
- "probability" number"%"
+ "rtable" number | "probability" number"%"
-nat-rule = [ "no" ] "nat" [ "pass" ] [ "on" ifspec ] [ af ]
+nat-rule = [ "no" ] "nat" [ "pass" [ "log" [ "(" logopts ")" ] ] ]
+ [ "on" ifspec ] [ af ]
[ protospec ] hosts [ "tag" string ] [ "tagged" string ]
- [ "->" ( redirhost | "{" redirhost-list "}" )
+ [ "-\*(Gt" ( redirhost | "{" redirhost-list "}" )
[ portspec ] [ pooltype ] [ "static-port" ] ]
-binat-rule = [ "no" ] "binat" [ "pass" ] [ "on" interface-name ]
- [ af ] [ "proto" ( proto-name | proto-number ) ]
+binat-rule = [ "no" ] "binat" [ "pass" [ "log" [ "(" logopts ")" ] ] ]
+ [ "on" interface-name ] [ af ]
+ [ "proto" ( proto-name | proto-number ) ]
"from" address [ "/" mask-bits ] "to" ipspec
[ "tag" string ] [ "tagged" string ]
- [ "->" address [ "/" mask-bits ] ]
+ [ "-\*(Gt" address [ "/" mask-bits ] ]
-rdr-rule = [ "no" ] "rdr" [ "pass" ] [ "on" ifspec ] [ af ]
+rdr-rule = [ "no" ] "rdr" [ "pass" [ "log" [ "(" logopts ")" ] ] ]
+ [ "on" ifspec ] [ af ]
[ protospec ] hosts [ "tag" string ] [ "tagged" string ]
- [ "->" ( redirhost | "{" redirhost-list "}" )
+ [ "-\*(Gt" ( redirhost | "{" redirhost-list "}" )
[ portspec ] [ pooltype ] ]
antispoof-rule = "antispoof" [ "log" ] [ "quick" ]
"for" ( interface-name | "{" interface-list "}" )
[ af ] [ "label" string ]
-table-rule = "table" "<" string ">" [ tableopts-list ]
+table-rule = "table" "\*(Lt" string "\*(Gt" [ tableopts-list ]
tableopts-list = tableopts-list tableopts | tableopts
tableopts = "persist" | "const" | "file" string |
"{" [ tableaddr-list ] "}"
@@ -2697,8 +2844,10 @@ altq-rule = "altq on" interface-name queueopts-list
queue-rule = "queue" string [ "on" interface-name ] queueopts-list
subqueue
-anchor-rule = "anchor" string [ ( "in" | "out" ) ] [ "on" ifspec ]
- [ af ] [ "proto" ] [ protospec ] [ hosts ]
+anchor-rule = "anchor" [ string ] [ ( "in" | "out" ) ] [ "on" ifspec ]
+ [ af ] [ protospec ] [ hosts ] [ "{" ]
+
+anchor-close = "}"
trans-anchors = ( "nat-anchor" | "rdr-anchor" | "binat-anchor" ) string
[ "on" ifspec ] [ af ] [ "proto" ] [ protospec ] [ hosts ]
@@ -2714,15 +2863,14 @@ bandwidth-spec = "number" ( "b" | "Kb" | "Mb" | "Gb" | "%" )
action = "pass" | "block" [ return ] | [ "no" ] "scrub"
return = "drop" | "return" | "return-rst" [ "( ttl" number ")" ] |
- "return-icmp" [ "(" icmpcode ["," icmp6code ] ")" ] |
+ "return-icmp" [ "(" icmpcode [ [ "," ] icmp6code ] ")" ] |
"return-icmp6" [ "(" icmp6code ")" ]
icmpcode = ( icmp-code-name | icmp-code-number )
icmp6code = ( icmp6-code-name | icmp6-code-number )
ifspec = ( [ "!" ] interface-name ) | "{" interface-list "}"
interface-list = [ "!" ] interface-name [ [ "," ] interface-list ]
-route = "fastroute" |
- ( "route-to" | "reply-to" | "dup-to" )
+route = ( "route-to" | "reply-to" | "dup-to" )
( routehost | "{" routehost-list "}" )
[ pooltype ]
af = "inet" | "inet6"
@@ -2732,15 +2880,15 @@ protospec = "proto" ( proto-name | proto-number |
proto-list = ( proto-name | proto-number ) [ [ "," ] proto-list ]
hosts = "all" |
- "from" ( "any" | "no-route" | "self" | host |
+ "from" ( "any" | "no-route" | "urpf-failed" | "self" | host |
"{" host-list "}" | "route" string ) [ port ] [ os ]
"to" ( "any" | "no-route" | "self" | host |
"{" host-list "}" | "route" string ) [ port ]
ipspec = "any" | host | "{" host-list "}"
-host = [ "!" ] ( address [ "/" mask-bits ] | "<" string ">" )
+host = [ "!" ] ( address [ "/" mask-bits ] | "\*(Lt" string "\*(Gt" )
redirhost = address [ "/" mask-bits ]
-routehost = ( interface-name [ address [ "/" mask-bits ] ] )
+routehost = "(" interface-name [ address [ "/" mask-bits ] ] ")"
address = ( interface-name | "(" interface-name ")" | hostname |
ipv4-dotted-quad | ipv6-coloned-hex )
host-list = host [ [ "," ] host-list ]
@@ -2753,15 +2901,15 @@ os = "os" ( os-name | "{" os-list "}" )
user = "user" ( unary-op | binary-op | "{" op-list "}" )
group = "group" ( unary-op | binary-op | "{" op-list "}" )
-unary-op = [ "=" | "!=" | "<" | "<=" | ">" | ">=" ]
+unary-op = [ "=" | "!=" | "\*(Lt" | "\*(Le" | "\*(Gt" | "\*(Ge" ]
( name | number )
-binary-op = number ( "<>" | "><" | ":" ) number
+binary-op = number ( "\*(Lt\*(Gt" | "\*(Gt\*(Lt" | ":" ) number
op-list = ( unary-op | binary-op ) [ [ "," ] op-list ]
os-name = operating-system-name
os-list = os-name [ [ "," ] os-list ]
-flags = "flags" [ flag-set ] "/" flag-set
+flags = "flags" ( [ flag-set ] "/" flag-set | "any" )
flag-set = [ "F" ] [ "S" ] [ "R" ] [ "P" ] [ "A" ] [ "U" ] [ "E" ]
[ "W" ]
@@ -2780,8 +2928,8 @@ state-opt = ( "max" number | "no-sync" | timeout |
"max-src-nodes" number | "max-src-states" number |
"max-src-conn" number |
"max-src-conn-rate" number "/" number |
- "overload" "<" string ">" [ "flush" ] |
- "if-bound" | "group-bound" | "floating" )
+ "overload" "\*(Lt" string "\*(Gt" [ "flush" ] |
+ "if-bound" | "floating" )
fragmentation = [ "fragment reassemble" | "fragment crop" |
"fragment drop-ovl" ]
@@ -2839,19 +2987,15 @@ and
.Ar user
filter parameter in conjuction with a Giant-free netstack
can result in a deadlock.
-If you have to use
-.Ar group
-or
+A workaround is available under the
+.Va debug.pfugidhack
+sysctl which is automatically enabled when a
.Ar user
-you must set
-.Va debug.mpsafenet
-to
-.Dq 0
-from the
-.Xr loader 8 ,
-for the moment.
-This workaround will still produce the LOR, but Giant will protect from the
-deadlock.
+/
+.Ar group
+rule is added or
+.Ar log (user)
+is specified.
.Pp
Route labels are not supported by the
.Fx
@@ -2860,6 +3004,7 @@ system.
Rules with a route label do not match any traffic.
.Sh SEE ALSO
.Xr altq 4 ,
+.Xr carp 4 ,
.Xr icmp 4 ,
.Xr icmp6 4 ,
.Xr ip 4 ,
diff --git a/contrib/pf/man/pf.os.5 b/contrib/pf/man/pf.os.5
index 07e0927..ac2b7a8 100644
--- a/contrib/pf/man/pf.os.5
+++ b/contrib/pf/man/pf.os.5
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pf.os.5,v 1.6 2004/03/31 11:13:03 dhartmei Exp $
+.\" $OpenBSD: pf.os.5,v 1.7 2005/11/16 20:07:18 stevesk Exp $
.\"
.\" Copyright (c) 2003 Mike Frantzen <frantzen@w4g.org>
.\"
@@ -207,37 +207,15 @@ The
output of
.Bd -literal
# tcpdump -s128 -c1 -nv 'tcp[13] == 2'
- 03:13:48.118526 10.0.0.1.3377 > 10.0.0.0.2: S [tcp sum ok] \e
+ 03:13:48.118526 10.0.0.1.3377 > 10.0.0.2.80: S [tcp sum ok] \e
534596083:534596083(0) win 57344 <mss 1460> (DF) [tos 0x10] \e
- (ttl 64, id 11315)
+ (ttl 64, id 11315, len 44)
.Ed
.Pp
almost translates into the following fingerprint
.Bd -literal
57344:64:1:44:M1460: exampleOS:1.0::exampleOS 1.0
.Ed
-.Pp
-.Xr tcpdump 1
-does not explicitly give the packet length.
-But it can usually be derived by adding the size of the IPv4 header to
-the size of the TCP header to the size of the TCP options.
-The size of both headers is typically twenty each and the usual
-sizes of the TCP options are:
-.Pp
-.Bl -tag -width timestamp -offset indent -compact
-.It mss
-four bytes.
-.It nop
-1 byte.
-.It sackOK
-two bytes.
-.It timestamp
-ten bytes.
-.It wscale
-three bytes.
-.El
-.Pp
-In the above example, the packet size comes out to 44 bytes.
.Sh SEE ALSO
.Xr tcpdump 1 ,
.Xr pf 4 ,
diff --git a/contrib/pf/man/pflog.4 b/contrib/pf/man/pflog.4
index 3040139..7ab96e9 100644
--- a/contrib/pf/man/pflog.4
+++ b/contrib/pf/man/pflog.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pflog.4,v 1.7 2004/03/21 19:47:59 miod Exp $
+.\" $OpenBSD: pflog.4,v 1.9 2006/10/25 12:51:31 jmc Exp $
.\"
.\" Copyright (c) 2001 Tobias Weingartner
.\" All rights reserved.
@@ -47,6 +47,14 @@ on the
interface, or stored to disk using
.Xr pflogd 8 .
.Pp
+The pflog0 interface is created automatically at boot if both
+.Xr pf 4
+and
+.Xr pflogd 8
+are enabled;
+further instances can be created using
+.Xr ifconfig 8 .
+.Pp
Each packet retrieved on this interface has a header associated
with it of length
.Dv PFLOG_HDRLEN .
@@ -65,14 +73,22 @@ struct pfloghdr {
char ruleset[PF_RULESET_NAME_SIZE];
u_int32_t rulenr;
u_int32_t subrulenr;
+ uid_t uid;
+ pid_t pid;
+ uid_t rule_uid;
+ pid_t rule_pid;
u_int8_t dir;
u_int8_t pad[3];
};
.Ed
.Sh EXAMPLES
+Create a
+.Nm
+interface
+and monitor all packets logged on it:
.Bd -literal -offset indent
-# ifconfig pflog0 up
-# tcpdump -n -e -ttt -i pflog0
+# ifconfig pflog1 up
+# tcpdump -n -e -ttt -i pflog1
.Ed
.Sh SEE ALSO
.Xr tcpdump 1
diff --git a/contrib/pf/man/pfsync.4 b/contrib/pf/man/pfsync.4
index c919ca0..63adca9 100644
--- a/contrib/pf/man/pfsync.4
+++ b/contrib/pf/man/pfsync.4
@@ -1,4 +1,4 @@
-.\" $OpenBSD: pfsync.4,v 1.22 2005/02/24 15:53:17 jmc Exp $
+.\" $OpenBSD: pfsync.4,v 1.24 2006/10/23 07:05:49 jmc Exp $
.\"
.\" Copyright (c) 2002 Michael Shalayeff
.\" Copyright (c) 2003-2004 Ryan McBride
@@ -209,7 +209,7 @@ The following should be added to the top of
.Pa /etc/pf.conf :
.Bd -literal -offset indent
pass quick on { sis2 } proto pfsync
-pass quick on { sis0 sis1 } proto carp keep state
+pass on { sis0 sis1 } proto carp
.Ed
.Pp
If it is preferable that one firewall handle the traffic,
@@ -248,6 +248,9 @@ yet.
.Xr pf.conf 5 ,
.Xr protocols 5 ,
.Xr rc.conf 5
+.Xr ifconfig 8 ,
+.Xr ifstated 8 ,
+.Xr tcpdump 8
.Sh HISTORY
The
.Nm
OpenPOWER on IntegriCloud