Deleted Added
sdiff udiff text old ( 163787 ) new ( 169844 )
full compact
1.\" $FreeBSD: head/contrib/pf/man/pf.conf.5 169844 2007-05-21 20:12:35Z dhartmei $
2.\" $OpenBSD: pf.conf.5,v 1.292 2004/02/24 05:44:48 mcbride Exp $
3.\"
4.\" Copyright (c) 2002, Daniel Hartmeier
5.\" All rights reserved.
6.\"
7.\" Redistribution and use in source and binary forms, with or without
8.\" modification, are permitted provided that the following conditions
9.\" are met:
10.\"
11.\" - Redistributions of source code must retain the above copyright
12.\" notice, this list of conditions and the following disclaimer.
13.\" - Redistributions in binary form must reproduce the above
14.\" copyright notice, this list of conditions and the following
15.\" disclaimer in the documentation and/or other materials provided
16.\" with the distribution.
17.\"
18.\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19.\" "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20.\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
21.\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
22.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
23.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
24.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26.\" CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
28.\" ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29.\" POSSIBILITY OF SUCH DAMAGE.
30.\"
31.Dd October 30, 2006
32.Dt PF.CONF 5
33.Os
34.Sh NAME
35.Nm pf.conf
36.Nd packet filter configuration file
37.Sh DESCRIPTION
38The
39.Xr pf 4
40packet filter modifies, drops or passes packets according to rules or
41definitions specified in
42.Nm pf.conf .
43.Sh STATEMENT ORDER
44There are seven types of statements in
45.Nm pf.conf :
46.Bl -tag -width xxxx
47.It Cm Macros
48User-defined variables may be defined and used later, simplifying
49the configuration file.
50Macros must be defined before they are referenced in
51.Nm pf.conf .
52.It Cm Tables
53Tables provide a mechanism for increasing the performance and flexibility of
54rules with large numbers of source or destination addresses.
55.It Cm Options
56Options tune the behaviour of the packet filtering engine.
57.It Cm Traffic Normalization Li (e.g. Em scrub )
58Traffic normalization protects internal machines against inconsistencies
59in Internet protocols and implementations.
60.It Cm Queueing
61Queueing provides rule-based bandwidth control.
62.It Cm Translation Li (Various forms of NAT)
63Translation rules specify how addresses are to be mapped or redirected to
64other addresses.
65.It Cm Packet Filtering
66Stateful and stateless packet filtering provides rule-based blocking or
67passing of packets.
68.El
69.Pp
70With the exception of
71.Cm macros
72and
73.Cm tables ,
74the types of statements should be grouped and appear in
75.Nm pf.conf
76in the order shown above, as this matches the operation of the underlying
77packet filtering engine.
78By default
79.Xr pfctl 8
80enforces this order (see
81.Ar set require-order
82below).
83.Sh MACROS
84Much like
85.Xr cpp 1
86or
87.Xr m4 1 ,
88macros can be defined that will later be expanded in context.
89Macro names must start with a letter, and may contain letters, digits
90and underscores.
91Macro names may not be reserved words (for example
92.Ar pass ,
93.Ar in ,
94.Ar out ) .
95Macros are not expanded inside quotes.
96.Pp
97For example,
98.Bd -literal -offset indent
99ext_if = \&"kue0\&"
100all_ifs = \&"{\&" $ext_if lo0 \&"}\&"
101pass out on $ext_if from any to any keep state
102pass in on $ext_if proto tcp from any to any port 25 keep state
103.Ed
104.Sh TABLES
105Tables are named structures which can hold a collection of addresses and
106networks.
107Lookups against tables in
108.Xr pf 4
109are relatively fast, making a single rule with tables much more efficient,
110in terms of
111processor usage and memory consumption, than a large number of rules which
112differ only in IP address (either created explicitly or automatically by rule
113expansion).
114.Pp
115Tables can be used as the source or destination of filter rules,
116.Ar scrub
117rules
118or
119translation rules such as
120.Ar nat
121or
122.Ar rdr
123(see below for details on the various rule types).
124Tables can also be used for the redirect address of
125.Ar nat
126and
127.Ar rdr
128rules and in the routing options of filter rules, but only for
129.Ar round-robin
130pools.
131.Pp
132Tables can be defined with any of the following
133.Xr pfctl 8
134mechanisms.
135As with macros, reserved words may not be used as table names.
136.Bl -tag -width "manually"
137.It Ar manually
138Persistent tables can be manually created with the
139.Ar add
140or
141.Ar replace
142option of
143.Xr pfctl 8 ,
144before or after the ruleset has been loaded.
145.It Pa pf.conf
146Table definitions can be placed directly in this file, and loaded at the
147same time as other rules are loaded, atomically.
148Table definitions inside
149.Nm pf.conf
150use the
151.Ar table
152statement, and are especially useful to define non-persistent tables.
153The contents of a pre-existing table defined without a list of addresses
154to initialize it is not altered when
155.Nm pf.conf
156is loaded.
157A table initialized with the empty list,
158.Li { } ,
159will be cleared on load.
160.El
161.Pp
162Tables may be defined with the following two attributes:
163.Bl -tag -width persist
164.It Ar persist
165The
166.Ar persist
167flag forces the kernel to keep the table even when no rules refer to it.
168If the flag is not set, the kernel will automatically remove the table
169when the last rule referring to it is flushed.
170.It Ar const
171The
172.Ar const
173flag prevents the user from altering the contents of the table once it
174has been created.
175Without that flag,
176.Xr pfctl 8
177can be used to add or remove addresses from the table at any time, even
178when running with
179.Xr securelevel 7
180= 2.
181.El
182.Pp
183For example,
184.Bd -literal -offset indent
185table <private> const { 10/8, 172.16/12, 192.168/16 }
186table <badhosts> persist
187block on fxp0 from { <private>, <badhosts> } to any
188.Ed
189.Pp
190creates a table called private, to hold RFC 1918 private network
191blocks, and a table called badhosts, which is initially empty.
192A filter rule is set up to block all traffic coming from addresses listed in
193either table.
194The private table cannot have its contents changed and the badhosts table
195will exist even when no active filter rules reference it.
196Addresses may later be added to the badhosts table, so that traffic from
197these hosts can be blocked by using
198.Bd -literal -offset indent
199# pfctl -t badhosts -Tadd 204.92.77.111
200.Ed
201.Pp
202A table can also be initialized with an address list specified in one or more
203external files, using the following syntax:
204.Bd -literal -offset indent
205table <spam> persist file \&"/etc/spammers\&" file \&"/etc/openrelays\&"
206block on fxp0 from <spam> to any
207.Ed
208.Pp
209The files
210.Pa /etc/spammers
211and
212.Pa /etc/openrelays
213list IP addresses, one per line.
214Any lines beginning with a # are treated as comments and ignored.
215In addition to being specified by IP address, hosts may also be
216specified by their hostname.
217When the resolver is called to add a hostname to a table,
218.Em all
219resulting IPv4 and IPv6 addresses are placed into the table.
220IP addresses can also be entered in a table by specifying a valid interface
221name or the
222.Em self
223keyword, in which case all addresses assigned to the interface(s) will be
224added to the table.
225.Sh OPTIONS
226.Xr pf 4
227may be tuned for various situations using the
228.Ar set
229command.
230.Bl -tag -width xxxx
231.It Ar set timeout
232.Pp
233.Bl -tag -width "src.track" -compact
234.It Ar interval
235Interval between purging expired states and fragments.
236.It Ar frag
237Seconds before an unassembled fragment is expired.
238.It Ar src.track
239Length of time to retain a source tracking entry after the last state
240expires.
241.El
242.Pp
243When a packet matches a stateful connection, the seconds to live for the
244connection will be updated to that of the
245.Ar proto.modifier
246which corresponds to the connection state.
247Each packet which matches this state will reset the TTL.
248Tuning these values may improve the performance of the
249firewall at the risk of dropping valid idle connections.
250.Pp
251.Bl -tag -width xxxx -compact
252.It Ar tcp.first
253The state after the first packet.
254.It Ar tcp.opening
255The state before the destination host ever sends a packet.
256.It Ar tcp.established
257The fully established state.
258.It Ar tcp.closing
259The state after the first FIN has been sent.
260.It Ar tcp.finwait
261The state after both FINs have been exchanged and the connection is closed.
262Some hosts (notably web servers on Solaris) send TCP packets even after closing
263the connection.
264Increasing
265.Ar tcp.finwait
266(and possibly
267.Ar tcp.closing )
268can prevent blocking of such packets.
269.It Ar tcp.closed
270The state after one endpoint sends an RST.
271.El
272.Pp
273ICMP and UDP are handled in a fashion similar to TCP, but with a much more
274limited set of states:
275.Pp
276.Bl -tag -width xxxx -compact
277.It Ar udp.first
278The state after the first packet.
279.It Ar udp.single
280The state if the source host sends more than one packet but the destination
281host has never sent one back.
282.It Ar udp.multiple
283The state if both hosts have sent packets.
284.It Ar icmp.first
285The state after the first packet.
286.It Ar icmp.error
287The state after an ICMP error came back in response to an ICMP packet.
288.El
289.Pp
290Other protocols are handled similarly to UDP:
291.Pp
292.Bl -tag -width xxxx -compact
293.It Ar other.first
294.It Ar other.single
295.It Ar other.multiple
296.El
297.Pp
298Timeout values can be reduced adaptively as the number of state table
299entries grows.
300.Pp
301.Bl -tag -width xxxx -compact
302.It Ar adaptive.start
303When the number of state entries exceeds this value, adaptive scaling
304begins.
305All timeout values are scaled linearly with factor
306(adaptive.end - number of states) / (adaptive.end - adaptive.start).
307.It Ar adaptive.end
308When reaching this number of state entries, all timeout values become
309zero, effectively purging all state entries immediately.
310This value is used to define the scale factor, it should not actually
311be reached (set a lower state limit, see below).
312.El
313.Pp
314These values can be defined both globally and for each rule.
315When used on a per-rule basis, the values relate to the number of
316states created by the rule, otherwise to the total number of
317states.
318.Pp
319For example:
320.Bd -literal -offset indent
321set timeout tcp.first 120
322set timeout tcp.established 86400
323set timeout { adaptive.start 6000, adaptive.end 12000 }
324set limit states 10000
325.Ed
326.Pp
327With 9000 state table entries, the timeout values are scaled to 50%
328(tcp.first 60, tcp.established 43200).
329.Pp
330.It Ar set loginterface
331Enable collection of packet and byte count statistics for the given interface.
332These statistics can be viewed using
333.Bd -literal -offset indent
334# pfctl -s info
335.Ed
336.Pp
337In this example
338.Xr pf 4
339collects statistics on the interface named dc0:
340.Bd -literal -offset indent
341set loginterface dc0
342.Ed
343.Pp
344One can disable the loginterface using:
345.Bd -literal -offset indent
346set loginterface none
347.Ed
348.Pp
349.It Ar set limit
350Sets hard limits on the memory pools used by the packet filter.
351See
352.Xr zone 9
353for an explanation of memory pools.
354.Pp
355For example,
356.Bd -literal -offset indent
357set limit states 20000
358.Ed
359.Pp
360sets the maximum number of entries in the memory pool used by state table
361entries (generated by
362.Ar keep state
363rules) to 20000.
364Using
365.Bd -literal -offset indent
366set limit frags 20000
367.Ed
368.Pp
369sets the maximum number of entries in the memory pool used for fragment
370reassembly (generated by
371.Ar scrub
372rules) to 20000.
373Finally,
374.Bd -literal -offset indent
375set limit src-nodes 2000
376.Ed
377.Pp
378sets the maximum number of entries in the memory pool used for tracking
379source IP addresses (generated by the
380.Ar sticky-address
381and
382.Ar source-track
383options) to 2000.
384.Pp
385These can be combined:
386.Bd -literal -offset indent
387set limit { states 20000, frags 20000, src-nodes 2000 }
388.Ed
389.Pp
390.It Ar set optimization
391Optimize the engine for one of the following network environments:
392.Pp
393.Bl -tag -width xxxx -compact
394.It Ar normal
395A normal network environment.
396Suitable for almost all networks.
397.It Ar high-latency
398A high-latency environment (such as a satellite connection).
399.It Ar satellite
400Alias for
401.Ar high-latency .
402.It Ar aggressive
403Aggressively expire connections.
404This can greatly reduce the memory usage of the firewall at the cost of
405dropping idle connections early.
406.It Ar conservative
407Extremely conservative settings.
408Avoid dropping legitimate connections at the
409expense of greater memory utilization (possibly much greater on a busy
410network) and slightly increased processor utilization.
411.El
412.Pp
413For example:
414.Bd -literal -offset indent
415set optimization aggressive
416.Ed
417.Pp
418.It Ar set block-policy
419The
420.Ar block-policy
421option sets the default behaviour for the packet
422.Ar block
423action:
424.Pp
425.Bl -tag -width xxxxxxxx -compact
426.It Ar drop
427Packet is silently dropped.
428.It Ar return
429A TCP RST is returned for blocked TCP packets,
430an ICMP UNREACHABLE is returned for blocked UDP packets,
431and all other packets are silently dropped.
432.El
433.Pp
434For example:
435.Bd -literal -offset indent
436set block-policy return
437.Ed
438.It Ar set state-policy
439The
440.Ar state-policy
441option sets the default behaviour for states:
442.Pp
443.Bl -tag -width group-bound -compact
444.It Ar if-bound
445States are bound to interface.
446.It Ar group-bound
447States are bound to interface group (i.e. ppp)
448.It Ar floating
449States can match packets on any interfaces (the default).
450.El
451.Pp
452For example:
453.Bd -literal -offset indent
454set state-policy if-bound
455.Ed
456.It Ar set require-order
457By default
458.Xr pfctl 8
459enforces an ordering of the statement types in the ruleset to:
460.Em options ,
461.Em normalization ,
462.Em queueing ,
463.Em translation ,
464.Em filtering .
465Setting this option to
466.Ar no
467disables this enforcement.
468There may be non-trivial and non-obvious implications to an out of
469order ruleset.
470Consider carefully before disabling the order enforcement.
471.It Ar set fingerprints
472Load fingerprints of known operating systems from the given filename.
473By default fingerprints of known operating systems are automatically
474loaded from
475.Xr pf.os 5
476in
477.Pa /etc
478but can be overridden via this option.
479Setting this option may leave a small period of time where the fingerprints
480referenced by the currently active ruleset are inconsistent until the new
481ruleset finishes loading.
482.Pp
483For example:
484.Pp
485.Dl set fingerprints \&"/etc/pf.os.devel\&"
486.Pp
487.It Ar set skip on <ifspec>
488List interfaces for which packets should not be filtered.
489Packets passing in or out on such interfaces are passed as if pf was
490disabled, i.e. pf does not process them in any way.
491This can be useful on loopback and other virtual interfaces, when
492packet filtering is not desired and can have unexpected effects.
493For example:
494.Pp
495.Dl set skip on lo0
496.Pp
497.It Ar set debug
498Set the debug
499.Ar level
500to one of the following:
501.Pp
502.Bl -tag -width xxxxxxxxxxxx -compact
503.It Ar none
504Don't generate debug messages.
505.It Ar urgent
506Generate debug messages only for serious errors.
507.It Ar misc
508Generate debug messages for various errors.
509.It Ar loud
510Generate debug messages for common conditions.
511.El
512.El
513.Sh TRAFFIC NORMALIZATION
514Traffic normalization is used to sanitize packet content in such
515a way that there are no ambiguities in packet interpretation on
516the receiving side.
517The normalizer does IP fragment reassembly to prevent attacks
518that confuse intrusion detection systems by sending overlapping
519IP fragments.
520Packet normalization is invoked with the
521.Ar scrub
522directive.
523.Pp
524.Ar scrub
525has the following options:
526.Bl -tag -width xxxx
527.It Ar no-df
528Clears the
529.Ar dont-fragment
530bit from a matching IP packet.
531Some operating systems are known to generate fragmented packets with the
532.Ar dont-fragment
533bit set.
534This is particularly true with NFS.
535.Ar Scrub
536will drop such fragmented
537.Ar dont-fragment
538packets unless
539.Ar no-df
540is specified.
541.Pp
542Unfortunately some operating systems also generate their
543.Ar dont-fragment
544packets with a zero IP identification field.
545Clearing the
546.Ar dont-fragment
547bit on packets with a zero IP ID may cause deleterious results if an
548upstream router later fragments the packet.
549Using the
550.Ar random-id
551modifier (see below) is recommended in combination with the
552.Ar no-df
553modifier to ensure unique IP identifiers.
554.It Ar min-ttl <number>
555Enforces a minimum TTL for matching IP packets.
556.It Ar max-mss <number>
557Enforces a maximum MSS for matching TCP packets.
558.It Ar random-id
559Replaces the IP identification field with random values to compensate
560for predictable values generated by many hosts.
561This option only applies to packets that are not fragmented
562after the optional fragment reassembly.
563.It Ar fragment reassemble
564Using
565.Ar scrub
566rules, fragments can be reassembled by normalization.
567In this case, fragments are buffered until they form a complete
568packet, and only the completed packet is passed on to the filter.
569The advantage is that filter rules have to deal only with complete
570packets, and can ignore fragments.
571The drawback of caching fragments is the additional memory cost.
572But the full reassembly method is the only method that currently works
573with NAT.
574This is the default behavior of a
575.Ar scrub
576rule if no fragmentation modifier is supplied.
577.It Ar fragment crop
578The default fragment reassembly method is expensive, hence the option
579to crop is provided.
580In this case,
581.Xr pf 4
582will track the fragments and cache a small range descriptor.
583Duplicate fragments are dropped and overlaps are cropped.
584Thus data will only occur once on the wire with ambiguities resolving to
585the first occurrence.
586Unlike the
587.Ar fragment reassemble
588modifier, fragments are not buffered, they are passed as soon as they
589are received.
590The
591.Ar fragment crop
592reassembly mechanism does not yet work with NAT.
593.Pp
594.It Ar fragment drop-ovl
595This option is similar to the
596.Ar fragment crop
597modifier except that all overlapping or duplicate fragments will be
598dropped, and all further corresponding fragments will be
599dropped as well.
600.It Ar reassemble tcp
601Statefully normalizes TCP connections.
602.Ar scrub reassemble tcp
603rules may not have the direction (in/out) specified.
604.Ar reassemble tcp
605performs the following normalizations:
606.Pp
607.Bl -tag -width timeout -compact
608.It ttl
609Neither side of the connection is allowed to reduce their IP TTL.
610An attacker may send a packet such that it reaches the firewall, affects
611the firewall state, and expires before reaching the destination host.
612.Ar reassemble tcp
613will raise the TTL of all packets back up to the highest value seen on
614the connection.
615.It timestamp modulation
616Modern TCP stacks will send a timestamp on every TCP packet and echo
617the other endpoint's timestamp back to them.
618Many operating systems will merely start the timestamp at zero when
619first booted, and increment it several times a second.
620The uptime of the host can be deduced by reading the timestamp and multiplying
621by a constant.
622Also observing several different timestamps can be used to count hosts
623behind a NAT device.
624And spoofing TCP packets into a connection requires knowing or guessing
625valid timestamps.
626Timestamps merely need to be monotonically increasing and not derived off a
627guessable base time.
628.Ar reassemble tcp
629will cause
630.Ar scrub
631to modulate the TCP timestamps with a random number.
632.It extended PAWS checks
633There is a problem with TCP on long fat pipes, in that a packet might get
634delayed for longer than it takes the connection to wrap its 32-bit sequence
635space.
636In such an occurrence, the old packet would be indistinguishable from a
637new packet and would be accepted as such.
638The solution to this is called PAWS: Protection Against Wrapped Sequence
639numbers.
640It protects against it by making sure the timestamp on each packet does
641not go backwards.
642.Ar reassemble tcp
643also makes sure the timestamp on the packet does not go forward more
644than the RFC allows.
645By doing this,
646.Xr pf 4
647artificially extends the security of TCP sequence numbers by 10 to 18
648bits when the host uses appropriately randomized timestamps, since a
649blind attacker would have to guess the timestamp as well.
650.El
651.El
652.Pp
653For example,
654.Bd -literal -offset indent
655scrub in on $ext_if all fragment reassemble
656.Ed
657.Pp
658The
659.Ar no
660option prefixed to a scrub rule causes matching packets to remain unscrubbed,
661much in the same way as
662.Ar drop quick
663works in the packet filter (see below).
664This mechanism should be used when it is necessary to exclude specific packets
665from broader scrub rules.
666.Sh QUEUEING/ALTQ
667The ALTQ system is currently not available in the GENERIC kernel nor as
668loadable modules.
669In order to use the herein after called queueing options one has to use a
670custom built kernel.
671Please refer to
672.Xr altq 4
673to learn about the related kernel options.
674.Pp
675Packets can be assigned to queues for the purpose of bandwidth
676control.
677At least two declarations are required to configure queues, and later
678any packet filtering rule can reference the defined queues by name.
679During the filtering component of
680.Nm pf.conf ,
681the last referenced
682.Ar queue
683name is where any packets from
684.Ar pass
685rules will be queued, while for
686.Ar block
687rules it specifies where any resulting ICMP or TCP RST
688packets should be queued.
689The
690.Ar scheduler
691defines the algorithm used to decide which packets get delayed, dropped, or
692sent out immediately.
693There are three
694.Ar schedulers
695currently supported.
696.Bl -tag -width xxxx
697.It Ar cbq
698Class Based Queueing.
699.Ar Queues
700attached to an interface build a tree, thus each
701.Ar queue
702can have further child
703.Ar queues .
704Each queue can have a
705.Ar priority
706and a
707.Ar bandwidth
708assigned.
709.Ar Priority
710mainly controls the time packets take to get sent out, while
711.Ar bandwidth
712has primarily effects on throughput.
713.Ar cbq
714achieves both partitioning and sharing of link bandwidth
715by hierarchically structured classes.
716Each class has its own
717.Ar queue
718and is assigned its share of
719.Ar bandwidth .
720A child class can borrow bandwidth from its parent class
721as long as excess bandwidth is available
722(see the option
723.Ar borrow ,
724below).
725.It Ar priq
726Priority Queueing.
727.Ar Queues
728are flat attached to the interface, thus,
729.Ar queues
730cannot have further child
731.Ar queues .
732Each
733.Ar queue
734has a unique
735.Ar priority
736assigned, ranging from 0 to 15.
737Packets in the
738.Ar queue
739with the highest
740.Ar priority
741are processed first.
742.It Ar hfsc
743Hierarchical Fair Service Curve.
744.Ar Queues
745attached to an interface build a tree, thus each
746.Ar queue
747can have further child
748.Ar queues .
749Each queue can have a
750.Ar priority
751and a
752.Ar bandwidth
753assigned.
754.Ar Priority
755mainly controls the time packets take to get sent out, while
756.Ar bandwidth
757has primarily effects on throughput.
758.Ar hfsc
759supports both link-sharing and guaranteed real-time services.
760It employs a service curve based QoS model,
761and its unique feature is an ability to decouple
762.Ar delay
763and
764.Ar bandwidth
765allocation.
766.El
767.Pp
768The interfaces on which queueing should be activated are declared using
769the
770.Ar altq on
771declaration.
772.Ar altq on
773has the following keywords:
774.Bl -tag -width xxxx
775.It Ar <interface>
776Queueing is enabled on the named interface.
777.It Ar <scheduler>
778Specifies which queueing scheduler to use.
779Currently supported values
780are
781.Ar cbq
782for Class Based Queueing,
783.Ar priq
784for Priority Queueing and
785.Ar hfsc
786for the Hierarchical Fair Service Curve scheduler.
787.It Ar bandwidth <bw>
788The maximum bitrate for all queues on an
789interface may be specified using the
790.Ar bandwidth
791keyword.
792The value can be specified as an absolute value or as a
793percentage of the interface bandwidth.
794When using an absolute value, the suffixes
795.Ar b ,
796.Ar Kb ,
797.Ar Mb ,
798and
799.Ar Gb
800are used to represent bits, kilobits, megabits, and
801gigabits per second, respectively.
802The value must not exceed the interface bandwidth.
803If
804.Ar bandwidth
805is not specified, the interface bandwidth is used.
806.It Ar qlimit <limit>
807The maximum number of packets held in the queue.
808The default is 50.
809.It Ar tbrsize <size>
810Adjusts the size, in bytes, of the token bucket regulator.
811If not specified, heuristics based on the
812interface bandwidth are used to determine the size.
813.It Ar queue <list>
814Defines a list of subqueues to create on an interface.
815.El
816.Pp
817In the following example, the interface dc0
818should queue up to 5 Mbit/s in four second-level queues using
819Class Based Queueing.
820Those four queues will be shown in a later example.
821.Bd -literal -offset indent
822altq on dc0 cbq bandwidth 5Mb queue { std, http, mail, ssh }
823.Ed
824.Pp
825Once interfaces are activated for queueing using the
826.Ar altq
827directive, a sequence of
828.Ar queue
829directives may be defined.
830The name associated with a
831.Ar queue
832must match a queue defined in the
833.Ar altq
834directive (e.g. mail), or, except for the
835.Ar priq
836.Ar scheduler ,
837in a parent
838.Ar queue
839declaration.
840The following keywords can be used:
841.Bl -tag -width xxxx
842.It Ar on <interface>
843Specifies the interface the queue operates on.
844If not given, it operates on all matching interfaces.
845.It Ar bandwidth <bw>
846Specifies the maximum bitrate to be processed by the queue.
847This value must not exceed the value of the parent
848.Ar queue
849and can be specified as an absolute value or a percentage of the parent
850queue's bandwidth.
851If not specified, defaults to 100% of the parent queue's bandwidth.
852The
853.Ar priq
854scheduler does not support bandwidth specification.
855.It Ar priority <level>
856Between queues a priority level can be set.
857For
858.Ar cbq
859and
860.Ar hfsc ,
861the range is 0 to 7 and for
862.Ar priq ,
863the range is 0 to 15.
864The default for all is 1.
865.Ar Priq
866queues with a higher priority are always served first.
867.Ar Cbq
868and
869.Ar Hfsc
870queues with a higher priority are preferred in the case of overload.
871.It Ar qlimit <limit>
872The maximum number of packets held in the queue.
873The default is 50.
874.El
875.Pp
876The
877.Ar scheduler
878can get additional parameters with
879.Ar <scheduler> Ns Li (\& Ar <parameters> No ) .
880Parameters are as follows:
881.Bl -tag -width Fl
882.It Ar default
883Packets not matched by another queue are assigned to this one.
884Exactly one default queue is required.
885.It Ar red
886Enable RED (Random Early Detection) on this queue.
887RED drops packets with a probability proportional to the average
888queue length.
889.It Ar rio
890Enables RIO on this queue.
891RIO is RED with IN/OUT, thus running
892RED two times more than RIO would achieve the same effect.
893RIO is currently not supported in the GENERIC kernel.
894.It Ar ecn
895Enables ECN (Explicit Congestion Notification) on this queue.
896ECN implies RED.
897.El
898.Pp
899The
900.Ar cbq
901.Ar scheduler
902supports an additional option:
903.Bl -tag -width Fl
904.It Ar borrow
905The queue can borrow bandwidth from the parent.
906.El
907.Pp
908The
909.Ar hfsc
910.Ar scheduler
911supports some additional options:
912.Bl -tag -width Fl
913.It Ar realtime <sc>
914The minimum required bandwidth for the queue.
915.It Ar upperlimit <sc>
916The maximum allowed bandwidth for the queue.
917.It Ar linkshare <sc>
918The bandwidth share of a backlogged queue.
919.El
920.Pp
921<sc> is an acronym for
922.Ar service curve .
923.Pp
924The format for service curve specifications is
925.Ar ( m1 , d , m2 ) .
926.Ar m2
927controls the bandwidth assigned to the queue.
928.Ar m1
929and
930.Ar d
931are optional and can be used to control the initial bandwidth assignment.
932For the first
933.Ar d
934milliseconds the queue gets the bandwidth given as
935.Ar m1 ,
936afterwards the value given in
937.Ar m2 .
938.Pp
939Furthermore, with
940.Ar cbq
941and
942.Ar hfsc ,
943child queues can be specified as in an
944.Ar altq
945declaration, thus building a tree of queues using a part of
946their parent's bandwidth.
947.Pp
948Packets can be assigned to queues based on filter rules by using the
949.Ar queue
950keyword.
951Normally only one
952.Ar queue
953is specified; when a second one is specified it will instead be used for
954packets which have a
955.Em TOS
956of
957.Em lowdelay
958and for TCP ACKs with no data payload.
959.Pp
960To continue the previous example, the examples below would specify the
961four referenced
962queues, plus a few child queues.
963Interactive
964.Xr ssh 1
965sessions get priority over bulk transfers like
966.Xr scp 1
967and
968.Xr sftp 1 .
969The queues may then be referenced by filtering rules (see
970.Sx PACKET FILTERING
971below).
972.Bd -literal
973queue std bandwidth 10% cbq(default)
974queue http bandwidth 60% priority 2 cbq(borrow red) \e
975 { employees, developers }
976queue developers bandwidth 75% cbq(borrow)
977queue employees bandwidth 15%
978queue mail bandwidth 10% priority 0 cbq(borrow ecn)
979queue ssh bandwidth 20% cbq(borrow) { ssh_interactive, ssh_bulk }
980queue ssh_interactive bandwidth 50% priority 7 cbq(borrow)
981queue ssh_bulk bandwidth 50% priority 0 cbq(borrow)
982
983block return out on dc0 inet all queue std
984pass out on dc0 inet proto tcp from $developerhosts to any port 80 \e
985 keep state queue developers
986pass out on dc0 inet proto tcp from $employeehosts to any port 80 \e
987 keep state queue employees
988pass out on dc0 inet proto tcp from any to any port 22 \e
989 keep state queue(ssh_bulk, ssh_interactive)
990pass out on dc0 inet proto tcp from any to any port 25 \e
991 keep state queue mail
992.Ed
993.Sh TRANSLATION
994Translation rules modify either the source or destination address of the
995packets associated with a stateful connection.
996A stateful connection is automatically created to track packets matching
997such a rule as long as they are not blocked by the filtering section of
998.Nm pf.conf .
999The translation engine modifies the specified address and/or port in the
1000packet, recalculates IP, TCP and UDP checksums as necessary, and passes it to
1001the packet filter for evaluation.
1002.Pp
1003Since translation occurs before filtering the filter
1004engine will see packets as they look after any
1005addresses and ports have been translated.
1006Filter rules will therefore have to filter based on the translated
1007address and port number.
1008Packets that match a translation rule are only automatically passed if
1009the
1010.Ar pass
1011modifier is given, otherwise they are
1012still subject to
1013.Ar block
1014and
1015.Ar pass
1016rules.
1017.Pp
1018The state entry created permits
1019.Xr pf 4
1020to keep track of the original address for traffic associated with that state
1021and correctly direct return traffic for that connection.
1022.Pp
1023Various types of translation are possible with pf:
1024.Bl -tag -width xxxx
1025.It Ar binat
1026A
1027.Ar binat
1028rule specifies a bidirectional mapping between an external IP netblock
1029and an internal IP netblock.
1030.It Ar nat
1031A
1032.Ar nat
1033rule specifies that IP addresses are to be changed as the packet
1034traverses the given interface.
1035This technique allows one or more IP addresses
1036on the translating host to support network traffic for a larger range of
1037machines on an "inside" network.
1038Although in theory any IP address can be used on the inside, it is strongly
1039recommended that one of the address ranges defined by RFC 1918 be used.
1040These netblocks are:
1041.Bd -literal
104210.0.0.0 - 10.255.255.255 (all of net 10, i.e., 10/8)
1043172.16.0.0 - 172.31.255.255 (i.e., 172.16/12)
1044192.168.0.0 - 192.168.255.255 (i.e., 192.168/16)
1045.Ed
1046.It Pa rdr
1047The packet is redirected to another destination and possibly a
1048different port.
1049.Ar rdr
1050rules can optionally specify port ranges instead of single ports.
1051rdr ... port 2000:2999 -> ... port 4000
1052redirects ports 2000 to 2999 (inclusive) to port 4000.
1053rdr ... port 2000:2999 -> ... port 4000:*
1054redirects port 2000 to 4000, 2001 to 4001, ..., 2999 to 4999.
1055.El
1056.Pp
1057In addition to modifying the address, some translation rules may modify
1058source or destination ports for
1059.Xr tcp 4
1060or
1061.Xr udp 4
1062connections; implicitly in the case of
1063.Ar nat
1064rules and explicitly in the case of
1065.Ar rdr
1066rules.
1067Port numbers are never translated with a
1068.Ar binat
1069rule.
1070.Pp
1071For each packet processed by the translator, the translation rules are
1072evaluated in sequential order, from first to last.
1073The first matching rule decides what action is taken.
1074.Pp
1075The
1076.Ar no
1077option prefixed to a translation rule causes packets to remain untranslated,
1078much in the same way as
1079.Ar drop quick
1080works in the packet filter (see below).
1081If no rule matches the packet it is passed to the filter engine unmodified.
1082.Pp
1083Translation rules apply only to packets that pass through
1084the specified interface, and if no interface is specified,
1085translation is applied to packets on all interfaces.
1086For instance, redirecting port 80 on an external interface to an internal
1087web server will only work for connections originating from the outside.
1088Connections to the address of the external interface from local hosts will
1089not be redirected, since such packets do not actually pass through the
1090external interface.
1091Redirections cannot reflect packets back through the interface they arrive
1092on, they can only be redirected to hosts connected to different interfaces
1093or to the firewall itself.
1094.Pp
1095Note that redirecting external incoming connections to the loopback
1096address, as in
1097.Bd -literal -offset indent
1098rdr on ne3 inet proto tcp to port 8025 -> 127.0.0.1 port 25
1099.Ed
1100.Pp
1101will effectively allow an external host to connect to daemons
1102bound solely to the loopback address, circumventing the traditional
1103blocking of such connections on a real interface.
1104Unless this effect is desired, any of the local non-loopback addresses
1105should be used as redirection target instead, which allows external
1106connections only to daemons bound to this address or not bound to
1107any address.
1108.Pp
1109See
1110.Sx TRANSLATION EXAMPLES
1111below.
1112.Sh PACKET FILTERING
1113.Xr pf 4
1114has the ability to
1115.Ar block
1116and
1117.Ar pass
1118packets based on attributes of their layer 3 (see
1119.Xr ip 4
1120and
1121.Xr ip6 4 )
1122and layer 4 (see
1123.Xr icmp 4 ,
1124.Xr icmp6 4 ,
1125.Xr tcp 4 ,
1126.Xr udp 4 )
1127headers.
1128In addition, packets may also be
1129assigned to queues for the purpose of bandwidth control.
1130.Pp
1131For each packet processed by the packet filter, the filter rules are
1132evaluated in sequential order, from first to last.
1133The last matching rule decides what action is taken.
1134.Pp
1135The following actions can be used in the filter:
1136.Bl -tag -width xxxx
1137.It Ar block
1138The packet is blocked.
1139There are a number of ways in which a
1140.Ar block
1141rule can behave when blocking a packet.
1142The default behaviour is to
1143.Ar drop
1144packets silently, however this can be overridden or made
1145explicit either globally, by setting the
1146.Ar block-policy
1147option, or on a per-rule basis with one of the following options:
1148.Pp
1149.Bl -tag -width xxxx -compact
1150.It Ar drop
1151The packet is silently dropped.
1152.It Ar return-rst
1153This applies only to
1154.Xr tcp 4
1155packets, and issues a TCP RST which closes the
1156connection.
1157.It Ar return-icmp
1158.It Ar return-icmp6
1159This causes ICMP messages to be returned for packets which match the rule.
1160By default this is an ICMP UNREACHABLE message, however this
1161can be overridden by specifying a message as a code or number.
1162.It Ar return
1163This causes a TCP RST to be returned for
1164.Xr tcp 4
1165packets and an ICMP UNREACHABLE for UDP and other packets.
1166.El
1167.Pp
1168Options returning ICMP packets currently have no effect if
1169.Xr pf 4
1170operates on a
1171.Xr if_bridge 4 ,
1172as the code to support this feature has not yet been implemented.
1173.It Ar pass
1174The packet is passed.
1175.El
1176.Pp
1177If no rule matches the packet, the default action is
1178.Ar pass .
1179.Pp
1180To block everything by default and only pass packets
1181that match explicit rules, one uses
1182.Bd -literal -offset indent
1183block all
1184.Ed
1185.Pp
1186as the first filter rule.
1187.Pp
1188See
1189.Sx FILTER EXAMPLES
1190below.
1191.Sh PARAMETERS
1192The rule parameters specify the packets to which a rule applies.
1193A packet always comes in on, or goes out through, one interface.
1194Most parameters are optional.
1195If a parameter is specified, the rule only applies to packets with
1196matching attributes.
1197Certain parameters can be expressed as lists, in which case
1198.Xr pfctl 8
1199generates all needed rule combinations.
1200.Bl -tag -width xxxx
1201.It Ar in No or Ar out
1202This rule applies to incoming or outgoing packets.
1203If neither
1204.Ar in
1205nor
1206.Ar out
1207are specified, the rule will match packets in both directions.
1208.It Ar log
1209In addition to the action specified, a log message is generated.
1210All packets for that connection are logged, unless the
1211.Ar keep state ,
1212.Ar modulate state
1213or
1214.Ar synproxy state
1215options are specified, in which case only the
1216packet that establishes the state is logged.
1217(See
1218.Ar keep state ,
1219.Ar modulate state
1220and
1221.Ar synproxy state
1222below).
1223The logged packets are sent to the
1224.Xr pflog 4
1225interface.
1226This interface is monitored by the
1227.Xr pflogd 8
1228logging daemon, which dumps the logged packets to the file
1229.Pa /var/log/pflog
1230in
1231.Xr pcap 3
1232binary format.
1233.It Ar log-all
1234Used with
1235.Ar keep state ,
1236.Ar modulate state
1237or
1238.Ar synproxy state
1239rules to force logging of all packets for a connection.
1240As with
1241.Ar log ,
1242packets are logged to
1243.Xr pflog 4 .
1244.It Ar quick
1245If a packet matches a rule which has the
1246.Ar quick
1247option set, this rule
1248is considered the last matching rule, and evaluation of subsequent rules
1249is skipped.
1250.It Ar on <interface>
1251This rule applies only to packets coming in on, or going out through, this
1252particular interface.
1253It is also possible to simply give the interface driver name, like ppp or fxp,
1254to make the rule match packets flowing through a group of interfaces.
1255.It Ar <af>
1256This rule applies only to packets of this address family.
1257Supported values are
1258.Ar inet
1259and
1260.Ar inet6 .
1261.It Ar proto <protocol>
1262This rule applies only to packets of this protocol.
1263Common protocols are
1264.Xr icmp 4 ,
1265.Xr icmp6 4 ,
1266.Xr tcp 4 ,
1267and
1268.Xr udp 4 .
1269For a list of all the protocol name to number mappings used by
1270.Xr pfctl 8 ,
1271see the file
1272.Em /etc/protocols .
1273.It Xo
1274.Ar from <source> port <source> os <source>
1275.Ar to <dest> port <dest>
1276.Xc
1277This rule applies only to packets with the specified source and destination
1278addresses and ports.
1279.Pp
1280Addresses can be specified in CIDR notation (matching netblocks), as
1281symbolic host names or interface names, or as any of the following keywords:
1282.Pp
1283.Bl -tag -width xxxxxxxxxxxxxx -compact
1284.It Ar any
1285Any address.
1286.It Ar route <label>
1287Any address whose associated route has label
1288.Ar <label> .
1289See
1290.Xr route 4
1291and
1292.Xr route 8 .
1293.It Ar no-route
1294Any address which is not currently routable.
1295.It Ar <table>
1296Any address that matches the given table.
1297.El
1298.Pp
1299Interface names can have modifiers appended:
1300.Pp
1301.Bl -tag -width xxxxxxxxxxxx -compact
1302.It Ar :network
1303Translates to the network(s) attached to the interface.
1304.It Ar :broadcast
1305Translates to the interface's broadcast address(es).
1306.It Ar :peer
1307Translates to the point to point interface's peer address(es).
1308.It Ar :0
1309Do not include interface aliases.
1310.El
1311.Pp
1312Host names may also have the
1313.Ar :0
1314option appended to restrict the name resolution to the first of each
1315v4 and v6 address found.
1316.Pp
1317Host name resolution and interface to address translation are done at
1318ruleset load-time.
1319When the address of an interface (or host name) changes (under DHCP or PPP,
1320for instance), the ruleset must be reloaded for the change to be reflected
1321in the kernel.
1322Surrounding the interface name (and optional modifiers) in parentheses
1323changes this behaviour.
1324When the interface name is surrounded by parentheses, the rule is
1325automatically updated whenever the interface changes its address.
1326The ruleset does not need to be reloaded.
1327This is especially useful with
1328.Ar nat .
1329.Pp
1330Ports can be specified either by number or by name.
1331For example, port 80 can be specified as
1332.Em www .
1333For a list of all port name to number mappings used by
1334.Xr pfctl 8 ,
1335see the file
1336.Pa /etc/services .
1337.Pp
1338Ports and ranges of ports are specified by using these operators:
1339.Bd -literal -offset indent
1340= (equal)
1341!= (unequal)
1342< (less than)
1343<= (less than or equal)
1344> (greater than)
1345>= (greater than or equal)
1346: (range including boundaries)
1347>< (range excluding boundaries)
1348<> (except range)
1349.Ed
1350.Pp
1351><, <> and :
1352are binary operators (they take two arguments).
1353For instance:
1354.Bl -tag -width Fl
1355.It Ar port 2000:2004
1356means
1357.Sq all ports >= 2000 and <= 2004 ,
1358hence ports 2000, 2001, 2002, 2003 and 2004.
1359.It Ar port 2000 >< 2004
1360means
1361.Sq all ports > 2000 and < 2004 ,
1362hence ports 2001, 2002 and 2003.
1363.It Ar port 2000 <> 2004
1364means
1365.Sq all ports < 2000 or > 2004 ,
1366hence ports 1-1999 and 2005-65535.
1367.El
1368.Pp
1369The operating system of the source host can be specified in the case of TCP
1370rules with the
1371.Ar OS
1372modifier.
1373See the
1374.Sx OPERATING SYSTEM FINGERPRINTING
1375section for more information.
1376.Pp
1377The host, port and OS specifications are optional, as in the following examples:
1378.Bd -literal -offset indent
1379pass in all
1380pass in from any to any
1381pass in proto tcp from any port <= 1024 to any
1382pass in proto tcp from any to any port 25
1383pass in proto tcp from 10.0.0.0/8 port > 1024 \e
1384 to ! 10.1.2.3 port != ssh
1385pass in proto tcp from any os "OpenBSD" flags S/SA
1386pass in proto tcp from route "DTAG"
1387.Ed
1388.It Ar all
1389This is equivalent to "from any to any".
1390.It Ar group <group>
1391Similar to
1392.Ar user ,
1393this rule only applies to packets of sockets owned by the specified group.
1394.Pp
1395The use of
1396.Ar group
1397or
1398.Ar user
1399in
1400.Va debug.mpsafenet Ns = Ns 1
1401environments may result in a deadlock.
1402Please see the
1403.Sx BUGS
1404section for details.
1405.It Ar user <user>
1406This rule only applies to packets of sockets owned by the specified user.
1407For outgoing connections initiated from the firewall, this is the user
1408that opened the connection.
1409For incoming connections to the firewall itself, this is the user that
1410listens on the destination port.
1411For forwarded connections, where the firewall is not a connection endpoint,
1412the user and group are
1413.Em unknown .
1414.Pp
1415All packets, both outgoing and incoming, of one connection are associated
1416with the same user and group.
1417Only TCP and UDP packets can be associated with users; for other protocols
1418these parameters are ignored.
1419.Pp
1420User and group refer to the effective (as opposed to the real) IDs, in
1421case the socket is created by a setuid/setgid process.
1422User and group IDs are stored when a socket is created;
1423when a process creates a listening socket as root (for instance, by
1424binding to a privileged port) and subsequently changes to another
1425user ID (to drop privileges), the credentials will remain root.
1426.Pp
1427User and group IDs can be specified as either numbers or names.
1428The syntax is similar to the one for ports.
1429The value
1430.Em unknown
1431matches packets of forwarded connections.
1432.Em unknown
1433can only be used with the operators
1434.Cm =
1435and
1436.Cm != .
1437Other constructs like
1438.Cm user >= unknown
1439are invalid.
1440Forwarded packets with unknown user and group ID match only rules
1441that explicitly compare against
1442.Em unknown
1443with the operators
1444.Cm =
1445or
1446.Cm != .
1447For instance
1448.Cm user >= 0
1449does not match forwarded packets.
1450The following example allows only selected users to open outgoing
1451connections:
1452.Bd -literal -offset indent
1453block out proto { tcp, udp } all
1454pass out proto { tcp, udp } all \e
1455 user { < 1000, dhartmei } keep state
1456.Ed
1457.It Ar flags <a>/<b> | /<b>
1458This rule only applies to TCP packets that have the flags
1459.Ar <a>
1460set out of set
1461.Ar <b> .
1462Flags not specified in
1463.Ar <b>
1464are ignored.
1465The flags are: (F)IN, (S)YN, (R)ST, (P)USH, (A)CK, (U)RG, (E)CE, and C(W)R.
1466.Bl -tag -width Fl
1467.It Ar flags S/S
1468Flag SYN is set.
1469The other flags are ignored.
1470.It Ar flags S/SA
1471Out of SYN and ACK, exactly SYN may be set.
1472SYN, SYN+PSH and SYN+RST match, but SYN+ACK, ACK and ACK+RST do not.
1473This is more restrictive than the previous example.
1474.It Ar flags /SFRA
1475If the first set is not specified, it defaults to none.
1476All of SYN, FIN, RST and ACK must be unset.
1477.El
1478.It Ar icmp-type <type> code <code>
1479.It Ar icmp6-type <type> code <code>
1480This rule only applies to ICMP or ICMPv6 packets with the specified type
1481and code.
1482Text names for ICMP types and codes are listed in
1483.Xr icmp 4
1484and
1485.Xr icmp6 4 .
1486This parameter is only valid for rules that cover protocols ICMP or
1487ICMP6.
1488The protocol and the ICMP type indicator
1489.Po
1490.Ar icmp-type
1491or
1492.Ar icmp6-type
1493.Pc
1494must match.
1495.It Ar allow-opts
1496By default, IPv4 packets with IP options or IPv6 packets with routing
1497extension headers are blocked.
1498When
1499.Ar allow-opts
1500is specified for a
1501.Ar pass
1502rule, packets that pass the filter based on that rule (last matching)
1503do so even if they contain IP options or routing extension headers.
1504For packets that match state, the rule that initially created the
1505state is used.
1506The implicit
1507.Ar pass
1508rule that is used when a packet does not match any rules does not
1509allow IP options.
1510.It Ar label <string>
1511Adds a label (name) to the rule, which can be used to identify the rule.
1512For instance,
1513pfctl -s labels
1514shows per-rule statistics for rules that have labels.
1515.Pp
1516The following macros can be used in labels:
1517.Pp
1518.Bl -tag -width $srcaddr -compact -offset indent
1519.It Ar $if
1520The interface.
1521.It Ar $srcaddr
1522The source IP address.
1523.It Ar $dstaddr
1524The destination IP address.
1525.It Ar $srcport
1526The source port specification.
1527.It Ar $dstport
1528The destination port specification.
1529.It Ar $proto
1530The protocol name.
1531.It Ar $nr
1532The rule number.
1533.El
1534.Pp
1535For example:
1536.Bd -literal -offset indent
1537ips = \&"{ 1.2.3.4, 1.2.3.5 }\&"
1538pass in proto tcp from any to $ips \e
1539 port > 1023 label \&"$dstaddr:$dstport\&"
1540.Ed
1541.Pp
1542expands to
1543.Bd -literal -offset indent
1544pass in inet proto tcp from any to 1.2.3.4 \e
1545 port > 1023 label \&"1.2.3.4:>1023\&"
1546pass in inet proto tcp from any to 1.2.3.5 \e
1547 port > 1023 label \&"1.2.3.5:>1023\&"
1548.Ed
1549.Pp
1550The macro expansion for the
1551.Ar label
1552directive occurs only at configuration file parse time, not during runtime.
1553.It Ar queue <queue> | ( <queue> , <queue> )
1554Packets matching this rule will be assigned to the specified queue.
1555If two queues are given, packets which have a
1556.Em tos
1557of
1558.Em lowdelay
1559and TCP ACKs with no data payload will be assigned to the second one.
1560See
1561.Sx QUEUEING/ALTQ
1562for setup details.
1563.Pp
1564For example:
1565.Bd -literal -offset indent
1566pass in proto tcp to port 25 queue mail
1567pass in proto tcp to port 22 queue(ssh_bulk, ssh_prio)
1568.Ed
1569.It Ar tag <string>
1570Packets matching this rule will be tagged with the
1571specified string.
1572The tag acts as an internal marker that can be used to
1573identify these packets later on.
1574This can be used, for example, to provide trust between
1575interfaces and to determine if packets have been
1576processed by translation rules.
1577Tags are
1578.Qq sticky ,
1579meaning that the packet will be tagged even if the rule
1580is not the last matching rule.
1581Further matching rules can replace the tag with a
1582new one but will not remove a previously applied tag.
1583A packet is only ever assigned one tag at a time.
1584.Ar pass
1585rules that use the
1586.Ar tag
1587keyword must also use
1588.Ar keep state ,
1589.Ar modulate state
1590or
1591.Ar synproxy state .
1592Packet tagging can be done during
1593.Ar nat ,
1594.Ar rdr ,
1595or
1596.Ar binat
1597rules in addition to filter rules.
1598Tags take the same macros as labels (see above).
1599.It Ar tagged <string>
1600Used with filter or translation rules to specify that packets must already
1601be tagged with the given tag in order to match the rule.
1602Inverse tag matching can also be done
1603by specifying the
1604.Cm !\&
1605operator before the
1606.Ar tagged
1607keyword.
1608.It Ar probability <number>
1609A probability attribute can be attached to a rule, with a value set between
16100 and 1, bounds not included.
1611In that case, the rule will be honoured using the given probability value
1612only.
1613For example, the following rule will drop 20% of incoming ICMP packets:
1614.Bd -literal -offset indent
1615block in proto icmp probability 20%
1616.Ed
1617.El
1618.Sh ROUTING
1619If a packet matches a rule with a route option set, the packet filter will
1620route the packet according to the type of route option.
1621When such a rule creates state, the route option is also applied to all
1622packets matching the same connection.
1623.Bl -tag -width xxxx
1624.It Ar fastroute
1625The
1626.Ar fastroute
1627option does a normal route lookup to find the next hop for the packet.
1628.It Ar route-to
1629The
1630.Ar route-to
1631option routes the packet to the specified interface with an optional address
1632for the next hop.
1633When a
1634.Ar route-to
1635rule creates state, only packets that pass in the same direction as the
1636filter rule specifies will be routed in this way.
1637Packets passing in the opposite direction (replies) are not affected
1638and are routed normally.
1639.It Ar reply-to
1640The
1641.Ar reply-to
1642option is similar to
1643.Ar route-to ,
1644but routes packets that pass in the opposite direction (replies) to the
1645specified interface.
1646Opposite direction is only defined in the context of a state entry, and
1647.Ar reply-to
1648is useful only in rules that create state.
1649It can be used on systems with multiple external connections to
1650route all outgoing packets of a connection through the interface
1651the incoming connection arrived through (symmetric routing enforcement).
1652.It Ar dup-to
1653The
1654.Ar dup-to
1655option creates a duplicate of the packet and routes it like
1656.Ar route-to .
1657The original packet gets routed as it normally would.
1658.El
1659.Sh POOL OPTIONS
1660For
1661.Ar nat
1662and
1663.Ar rdr
1664rules, (as well as for the
1665.Ar route-to ,
1666.Ar reply-to
1667and
1668.Ar dup-to
1669rule options) for which there is a single redirection address which has a
1670subnet mask smaller than 32 for IPv4 or 128 for IPv6 (more than one IP
1671address), a variety of different methods for assigning this address can be
1672used:
1673.Bl -tag -width xxxx
1674.It Ar bitmask
1675The
1676.Ar bitmask
1677option applies the network portion of the redirection address to the address
1678to be modified (source with
1679.Ar nat ,
1680destination with
1681.Ar rdr ) .
1682.It Ar random
1683The
1684.Ar random
1685option selects an address at random within the defined block of addresses.
1686.It Ar source-hash
1687The
1688.Ar source-hash
1689option uses a hash of the source address to determine the redirection address,
1690ensuring that the redirection address is always the same for a given source.
1691An optional key can be specified after this keyword either in hex or as a
1692string; by default
1693.Xr pfctl 8
1694randomly generates a key for source-hash every time the
1695ruleset is reloaded.
1696.It Ar round-robin
1697The
1698.Ar round-robin
1699option loops through the redirection address(es).
1700.Pp
1701When more than one redirection address is specified,
1702.Ar round-robin
1703is the only permitted pool type.
1704.It Ar static-port
1705With
1706.Ar nat
1707rules, the
1708.Ar static-port
1709option prevents
1710.Xr pf 4
1711from modifying the source port on TCP and UDP packets.
1712.El
1713.Pp
1714Additionally, the
1715.Ar sticky-address
1716option can be specified to help ensure that multiple connections from the
1717same source are mapped to the same redirection address.
1718This option can be used with the
1719.Ar random
1720and
1721.Ar round-robin
1722pool options.
1723Note that by default these associations are destroyed as soon as there are
1724no longer states which refer to them; in order to make the mappings last
1725beyond the lifetime of the states, increase the global options with
1726.Ar set timeout source-track
1727See
1728.Sx STATEFUL TRACKING OPTIONS
1729for more ways to control the source tracking.
1730.Sh STATEFUL INSPECTION
1731.Xr pf 4
1732is a stateful packet filter, which means it can track the state of
1733a connection.
1734Instead of passing all traffic to port 25, for instance, it is possible
1735to pass only the initial packet, and then begin to keep state.
1736Subsequent traffic will flow because the filter is aware of the connection.
1737.Pp
1738If a packet matches a
1739.Ar pass ... keep state
1740rule, the filter creates a state for this connection and automatically
1741lets pass all subsequent packets of that connection.
1742.Pp
1743Before any rules are evaluated, the filter checks whether the packet
1744matches any state.
1745If it does, the packet is passed without evaluation of any rules.
1746.Pp
1747States are removed after the connection is closed or has timed out.
1748.Pp
1749This has several advantages.
1750Comparing a packet to a state involves checking its sequence numbers.
1751If the sequence numbers are outside the narrow windows of expected
1752values, the packet is dropped.
1753This prevents spoofing attacks, such as when an attacker sends packets with
1754a fake source address/port but does not know the connection's sequence
1755numbers.
1756.Pp
1757Also, looking up states is usually faster than evaluating rules.
1758If there are 50 rules, all of them are evaluated sequentially in O(n).
1759Even with 50000 states, only 16 comparisons are needed to match a
1760state, since states are stored in a binary search tree that allows
1761searches in O(log2 n).
1762.Pp
1763For instance:
1764.Bd -literal -offset indent
1765block all
1766pass out proto tcp from any to any flags S/SA keep state
1767pass in proto tcp from any to any port 25 flags S/SA keep state
1768.Ed
1769.Pp
1770This ruleset blocks everything by default.
1771Only outgoing connections and incoming connections to port 25 are allowed.
1772The initial packet of each connection has the SYN
1773flag set, will be passed and creates state.
1774All further packets of these connections are passed if they match a state.
1775.Pp
1776By default, packets coming in and out of any interface can match a state,
1777but it is also possible to change that behaviour by assigning states to a
1778single interface or a group of interfaces.
1779.Pp
1780The default policy is specified by the
1781.Ar state-policy
1782global option, but this can be adjusted on a per-rule basis by adding one
1783of the
1784.Ar if-bound ,
1785.Ar group-bound
1786or
1787.Ar floating
1788keywords to the
1789.Ar keep state
1790option.
1791For example, if a rule is defined as:
1792.Bd -literal -offset indent
1793pass out on ppp from any to 10.12/16 keep state (group-bound)
1794.Ed
1795.Pp
1796A state created on ppp0 would match packets an all PPP interfaces,
1797but not packets flowing through fxp0 or any other interface.
1798.Pp
1799Keeping rules
1800.Ar floating
1801is the more flexible option when the firewall is in a dynamic routing
1802environment.
1803However, this has some security implications since a state created by one
1804trusted network could allow potentially hostile packets coming in from other
1805interfaces.
1806.Pp
1807Specifying
1808.Ar flags S/SA
1809restricts state creation to the initial SYN
1810packet of the TCP handshake.
1811One can also be less restrictive, and allow state creation from
1812intermediate
1813.Pq non-SYN
1814packets.
1815This will cause
1816.Xr pf 4
1817to synchronize to existing connections, for instance
1818if one flushes the state table.
1819.Pp
1820For UDP, which is stateless by nature,
1821.Ar keep state
1822will create state as well.
1823UDP packets are matched to states using only host addresses and ports.
1824.Pp
1825ICMP messages fall into two categories: ICMP error messages, which always
1826refer to a TCP or UDP packet, are matched against the referred to connection.
1827If one keeps state on a TCP connection, and an ICMP source quench message
1828referring to this TCP connection arrives, it will be matched to the right
1829state and get passed.
1830.Pp
1831For ICMP queries,
1832.Ar keep state
1833creates an ICMP state, and
1834.Xr pf 4
1835knows how to match ICMP replies to states.
1836For example,
1837.Bd -literal -offset indent
1838pass out inet proto icmp all icmp-type echoreq keep state
1839.Ed
1840.Pp
1841allows echo requests (such as those created by
1842.Xr ping 8 )
1843out, creates state, and matches incoming echo replies correctly to states.
1844.Pp
1845Note:
1846.Ar nat , binat No and Ar rdr
1847rules implicitly create state for connections.
1848.Sh STATE MODULATION
1849Much of the security derived from TCP is attributable to how well the
1850initial sequence numbers (ISNs) are chosen.
1851Some popular stack implementations choose
1852.Em very
1853poor ISNs and thus are normally susceptible to ISN prediction exploits.
1854By applying a
1855.Ar modulate state
1856rule to a TCP connection,
1857.Xr pf 4
1858will create a high quality random sequence number for each connection
1859endpoint.
1860.Pp
1861The
1862.Ar modulate state
1863directive implicitly keeps state on the rule and is
1864only applicable to TCP connections.
1865.Pp
1866For instance:
1867.Bd -literal -offset indent
1868block all
1869pass out proto tcp from any to any modulate state
1870pass in proto tcp from any to any port 25 flags S/SA modulate state
1871.Ed
1872.Pp
1873There are two caveats associated with state modulation:
1874A
1875.Ar modulate state
1876rule can not be applied to a pre-existing but unmodulated connection.
1877Such an application would desynchronize TCP's strict
1878sequencing between the two endpoints.
1879Instead,
1880.Xr pf 4
1881will treat the
1882.Ar modulate state
1883modifier as a
1884.Ar keep state
1885modifier and the pre-existing connection will be inferred without
1886the protection conferred by modulation.
1887.Pp
1888The other caveat affects currently modulated states when the state table
1889is lost (firewall reboot, flushing the state table, etc...).
1890.Xr pf 4
1891will not be able to infer a connection again after the state table flushes
1892the connection's modulator.
1893When the state is lost, the connection may be left dangling until the
1894respective endpoints time out the connection.
1895It is possible on a fast local network for the endpoints to start an ACK
1896storm while trying to resynchronize after the loss of the modulator.
1897Using a
1898.Ar flags S/SA
1899modifier on
1900.Ar modulate state
1901rules between fast networks is suggested to prevent ACK storms.
1902.Sh SYN PROXY
1903By default,
1904.Xr pf 4
1905passes packets that are part of a
1906.Xr tcp 4
1907handshake between the endpoints.
1908The
1909.Ar synproxy state
1910option can be used to cause
1911.Xr pf 4
1912itself to complete the handshake with the active endpoint, perform a handshake
1913with the passive endpoint, and then forward packets between the endpoints.
1914.Pp
1915No packets are sent to the passive endpoint before the active endpoint has
1916completed the handshake, hence so-called SYN floods with spoofed source
1917addresses will not reach the passive endpoint, as the sender can't complete the
1918handshake.
1919.Pp
1920The proxy is transparent to both endpoints, they each see a single
1921connection from/to the other endpoint.
1922.Xr pf 4
1923chooses random initial sequence numbers for both handshakes.
1924Once the handshakes are completed, the sequence number modulators
1925(see previous section) are used to translate further packets of the
1926connection.
1927Hence,
1928.Ar synproxy state
1929includes
1930.Ar modulate state
1931and
1932.Ar keep state .
1933.Pp
1934Rules with
1935.Ar synproxy
1936will not work if
1937.Xr pf 4
1938operates on a
1939.Xr if_bridge 4 .
1940.Pp
1941Example:
1942.Bd -literal -offset indent
1943pass in proto tcp from any to any port www flags S/SA synproxy state
1944.Ed
1945.Sh STATEFUL TRACKING OPTIONS
1946All three of
1947.Ar keep state ,
1948.Ar modulate state
1949and
1950.Ar synproxy state
1951support the following options:
1952.Pp
1953.Bl -tag -width xxxx -compact
1954.It Ar max <number>
1955Limits the number of concurrent states the rule may create.
1956When this limit is reached, further packets matching the rule that would
1957create state are dropped, until existing states time out.
1958.It Ar no-sync
1959Prevent state changes for states created by this rule from appearing on the
1960.Xr pfsync 4
1961interface.
1962.It Ar <timeout> <seconds>
1963Changes the timeout values used for states created by this rule.
1964For a list of all valid timeout names, see
1965.Sx OPTIONS
1966above.
1967.El
1968.Pp
1969Multiple options can be specified, separated by commas:
1970.Bd -literal -offset indent
1971pass in proto tcp from any to any \e
1972 port www flags S/SA keep state \e
1973 (max 100, source-track rule, max-src-nodes 75, \e
1974 max-src-states 3, tcp.established 60, tcp.closing 5)
1975.Ed
1976.Pp
1977When the
1978.Ar source-track
1979keyword is specified, the number of states per source IP is tracked.
1980.Pp
1981.Bl -tag -width xxxx -compact
1982.It Ar source-track rule
1983The maximum number of states created by this rule is limited by the rule's
1984.Ar max-src-nodes
1985and
1986.Ar max-src-state
1987options.
1988Only state entries created by this particular rule count toward the rule's
1989limits.
1990.It Ar source-track global
1991The number of states created by all rules that use this option is limited.
1992Each rule can specify different
1993.Ar max-src-nodes
1994and
1995.Ar max-src-states
1996options, however state entries created by any participating rule count towards
1997each individual rule's limits.
1998.El
1999.Pp
2000The following limits can be set:
2001.Pp
2002.Bl -tag -width xxxx -compact
2003.It Ar max-src-nodes <number>
2004Limits the maximum number of source addresses which can simultaneously
2005have state table entries.
2006.It Ar max-src-states <number>
2007Limits the maximum number of simultaneous state entries that a single
2008source address can create with this rule.
2009.El
2010.Pp
2011For stateful TCP connections, limits on established connections (connections
2012which have completed the TCP 3-way handshake) can also be enforced
2013per source IP.
2014.Pp
2015.Bl -tag -width xxxx -compact
2016.It Ar max-src-conn <number>
2017Limits the maximum number of simultaneous TCP connections which have
2018completed the 3-way handshake that a single host can make.
2019.It Ar max-src-conn-rate <number> / <seconds>
2020Limit the rate of new connections over a time interval.
2021The connection rate is an approximation calculated as a moving average.
2022.El
2023.Pp
2024Because the 3-way handshake ensures that the source address is not being
2025spoofed, more aggressive action can be taken based on these limits.
2026With the
2027.Ar overload <table>
2028state option, source IP addresses which hit either of the limits on
2029established connections will be added to the named table.
2030This table can be used in the ruleset to block further activity from
2031the offending host, redirect it to a tarpit process, or restrict its
2032bandwidth.
2033.Pp
2034The optional
2035.Ar flush
2036keyword kills all states created by the matching rule which originate
2037from the host which exceeds these limits.
2038The
2039.Ar global
2040modifier to the flush command kills all states originating from the
2041offending host, regardless of which rule created the state.
2042.Pp
2043For example, the following rules will protect the webserver against
2044hosts making more than 100 connections in 10 seconds.
2045Any host which connects faster than this rate will have its address added
2046to the <bad_hosts> table and have all states originating from it flushed.
2047Any new packets arriving from this host will be dropped unconditionally
2048by the block rule.
2049.Bd -literal -offset indent
2050block quick from <bad_hosts>
2051pass in on $ext_if proto tcp to $webserver port www flags S/SA keep state \e
2052 (max-src-conn-rate 100/10, overload <bad_hosts> flush global)
2053.Ed
2054.Sh OPERATING SYSTEM FINGERPRINTING
2055Passive OS Fingerprinting is a mechanism to inspect nuances of a TCP
2056connection's initial SYN packet and guess at the host's operating system.
2057Unfortunately these nuances are easily spoofed by an attacker so the
2058fingerprint is not useful in making security decisions.
2059But the fingerprint is typically accurate enough to make policy decisions
2060upon.
2061.Pp
2062The fingerprints may be specified by operating system class, by
2063version, or by subtype/patchlevel.
2064The class of an operating system is typically the vendor or genre
2065and would be OpenBSD for the
2066.Xr pf 4
2067firewall itself.
2068The version of the oldest available OpenBSD release on the main ftp site
2069would be 2.6 and the fingerprint would be written
2070.Pp
2071.Dl \&"OpenBSD 2.6\&"
2072.Pp
2073The subtype of an operating system is typically used to describe the
2074patchlevel if that patch led to changes in the TCP stack behavior.
2075In the case of OpenBSD, the only subtype is for a fingerprint that was
2076normalized by the
2077.Ar no-df
2078scrub option and would be specified as
2079.Pp
2080.Dl \&"OpenBSD 3.3 no-df\&"
2081.Pp
2082Fingerprints for most popular operating systems are provided by
2083.Xr pf.os 5 .
2084Once
2085.Xr pf 4
2086is running, a complete list of known operating system fingerprints may
2087be listed by running:
2088.Pp
2089.Dl # pfctl -so
2090.Pp
2091Filter rules can enforce policy at any level of operating system specification
2092assuming a fingerprint is present.
2093Policy could limit traffic to approved operating systems or even ban traffic
2094from hosts that aren't at the latest service pack.
2095.Pp
2096The
2097.Ar unknown
2098class can also be used as the fingerprint which will match packets for
2099which no operating system fingerprint is known.
2100.Pp
2101Examples:
2102.Bd -literal -offset indent
2103pass out proto tcp from any os OpenBSD keep state
2104block out proto tcp from any os Doors
2105block out proto tcp from any os "Doors PT"
2106block out proto tcp from any os "Doors PT SP3"
2107block out from any os "unknown"
2108pass on lo0 proto tcp from any os "OpenBSD 3.3 lo0" keep state
2109.Ed
2110.Pp
2111Operating system fingerprinting is limited only to the TCP SYN packet.
2112This means that it will not work on other protocols and will not match
2113a currently established connection.
2114.Pp
2115Caveat: operating system fingerprints are occasionally wrong.
2116There are three problems: an attacker can trivially craft his packets to
2117appear as any operating system he chooses;
2118an operating system patch could change the stack behavior and no fingerprints
2119will match it until the database is updated;
2120and multiple operating systems may have the same fingerprint.
2121.Sh BLOCKING SPOOFED TRAFFIC
2122"Spoofing" is the faking of IP addresses, typically for malicious
2123purposes.
2124The
2125.Ar antispoof
2126directive expands to a set of filter rules which will block all
2127traffic with a source IP from the network(s) directly connected
2128to the specified interface(s) from entering the system through
2129any other interface.
2130.Pp
2131For example, the line
2132.Bd -literal -offset indent
2133antispoof for lo0
2134.Ed
2135.Pp
2136expands to
2137.Bd -literal -offset indent
2138block drop in on ! lo0 inet from 127.0.0.1/8 to any
2139block drop in on ! lo0 inet6 from ::1 to any
2140.Ed
2141.Pp
2142For non-loopback interfaces, there are additional rules to block incoming
2143packets with a source IP address identical to the interface's IP(s).
2144For example, assuming the interface wi0 had an IP address of 10.0.0.1 and a
2145netmask of 255.255.255.0,
2146the line
2147.Bd -literal -offset indent
2148antispoof for wi0 inet
2149.Ed
2150.Pp
2151expands to
2152.Bd -literal -offset indent
2153block drop in on ! wi0 inet from 10.0.0.0/24 to any
2154block drop in inet from 10.0.0.1 to any
2155.Ed
2156.Pp
2157Caveat: Rules created by the
2158.Ar antispoof
2159directive interfere with packets sent over loopback interfaces
2160to local addresses.
2161One should pass these explicitly.
2162.Sh FRAGMENT HANDLING
2163The size of IP datagrams (packets) can be significantly larger than the
2164maximum transmission unit (MTU) of the network.
2165In cases when it is necessary or more efficient to send such large packets,
2166the large packet will be fragmented into many smaller packets that will each
2167fit onto the wire.
2168Unfortunately for a firewalling device, only the first logical fragment will
2169contain the necessary header information for the subprotocol that allows
2170.Xr pf 4
2171to filter on things such as TCP ports or to perform NAT.
2172.Pp
2173Besides the use of
2174.Ar scrub
2175rules as described in
2176.Sx TRAFFIC NORMALIZATION
2177above, there are three options for handling fragments in the packet filter.
2178.Pp
2179One alternative is to filter individual fragments with filter rules.
2180If no
2181.Ar scrub
2182rule applies to a fragment, it is passed to the filter.
2183Filter rules with matching IP header parameters decide whether the
2184fragment is passed or blocked, in the same way as complete packets
2185are filtered.
2186Without reassembly, fragments can only be filtered based on IP header
2187fields (source/destination address, protocol), since subprotocol header
2188fields are not available (TCP/UDP port numbers, ICMP code/type).
2189The
2190.Ar fragment
2191option can be used to restrict filter rules to apply only to
2192fragments, but not complete packets.
2193Filter rules without the
2194.Ar fragment
2195option still apply to fragments, if they only specify IP header fields.
2196For instance, the rule
2197.Bd -literal -offset indent
2198pass in proto tcp from any to any port 80
2199.Ed
2200.Pp
2201never applies to a fragment, even if the fragment is part of a TCP
2202packet with destination port 80, because without reassembly this information
2203is not available for each fragment.
2204This also means that fragments cannot create new or match existing
2205state table entries, which makes stateful filtering and address
2206translation (NAT, redirection) for fragments impossible.
2207.Pp
2208It's also possible to reassemble only certain fragments by specifying
2209source or destination addresses or protocols as parameters in
2210.Ar scrub
2211rules.
2212.Pp
2213In most cases, the benefits of reassembly outweigh the additional
2214memory cost, and it's recommended to use
2215.Ar scrub
2216rules to reassemble
2217all fragments via the
2218.Ar fragment reassemble
2219modifier.
2220.Pp
2221The memory allocated for fragment caching can be limited using
2222.Xr pfctl 8 .
2223Once this limit is reached, fragments that would have to be cached
2224are dropped until other entries time out.
2225The timeout value can also be adjusted.
2226.Pp
2227Currently, only IPv4 fragments are supported and IPv6 fragments
2228are blocked unconditionally.
2229.Sh ANCHORS
2230Besides the main ruleset,
2231.Xr pfctl 8
2232can load rulesets into
2233.Ar anchor
2234attachment points.
2235An
2236.Ar anchor
2237is a container that can hold rules, address tables, and other anchors.
2238.Pp
2239An
2240.Ar anchor
2241has a name which specifies the path where
2242.Xr pfctl 8
2243can be used to access the anchor to perform operations on it, such as
2244attaching child anchors to it or loading rules into it.
2245Anchors may be nested, with components separated by
2246.Sq /
2247characters, similar to how file system hierarchies are laid out.
2248The main ruleset is actually the default anchor, so filter and
2249translation rules, for example, may also be contained in any anchor.
2250.Pp
2251An anchor can reference another
2252.Ar anchor
2253attachment point
2254using the following kinds
2255of rules:
2256.Bl -tag -width xxxx
2257.It Ar nat-anchor <name>
2258Evaluates the
2259.Ar nat
2260rules in the specified
2261.Ar anchor .
2262.It Ar rdr-anchor <name>
2263Evaluates the
2264.Ar rdr
2265rules in the specified
2266.Ar anchor .
2267.It Ar binat-anchor <name>
2268Evaluates the
2269.Ar binat
2270rules in the specified
2271.Ar anchor .
2272.It Ar anchor <name>
2273Evaluates the filter rules in the specified
2274.Ar anchor .
2275.It Ar load anchor <name> from <file>
2276Loads the rules from the specified file into the
2277anchor
2278.Ar name .
2279.El
2280.Pp
2281When evaluation of the main ruleset reaches an
2282.Ar anchor
2283rule,
2284.Xr pf 4
2285will proceed to evaluate all rules specified in that anchor.
2286.Pp
2287Matching filter and translation rules in anchors with the
2288.Ar quick
2289option are final and abort the evaluation of the rules in other
2290anchors
2291and the main ruleset.
2292.Pp
2293.Ar anchor
2294rules are evaluated relative to the anchor in which they are contained.
2295For example, all
2296.Ar anchor
2297rules specified in the main ruleset will reference anchor
2298attachment points underneath the main ruleset, and
2299.Ar anchor
2300rules specified in a file loaded from a
2301.Ar load anchor
2302rule will be attached under that anchor point.
2303.Pp
2304Rules may be contained in
2305.Ar anchor
2306attachment points which do not contain any rules when the main ruleset
2307is loaded, and later such anchors can be manipulated through
2308.Xr pfctl 8
2309without reloading the main ruleset or other anchors.
2310For example,
2311.Bd -literal -offset indent
2312ext_if = \&"kue0\&"
2313block on $ext_if all
2314anchor spam
2315pass out on $ext_if all keep state
2316pass in on $ext_if proto tcp from any \e
2317 to $ext_if port smtp keep state
2318.Ed
2319.Pp
2320blocks all packets on the external interface by default, then evaluates
2321all rules in the
2322.Ar anchor
2323named "spam", and finally passes all outgoing connections and
2324incoming connections to port 25.
2325.Bd -literal -offset indent
2326# echo \&"block in quick from 1.2.3.4 to any\&" \&| \e
2327 pfctl -a spam -f -
2328.Ed
2329.Pp
2330This loads a single rule into the
2331.Ar anchor ,
2332which blocks all packets from a specific address.
2333.Pp
2334The anchor can also be populated by adding a
2335.Ar load anchor
2336rule after the
2337.Ar anchor
2338rule:
2339.Bd -literal -offset indent
2340anchor spam
2341load anchor spam from "/etc/pf-spam.conf"
2342.Ed
2343.Pp
2344When
2345.Xr pfctl 8
2346loads
2347.Nm pf.conf ,
2348it will also load all the rules from the file
2349.Pa /etc/pf-spam.conf
2350into the anchor.
2351.Pp
2352Optionally,
2353.Ar anchor
2354rules can specify the parameter's
2355direction, interface, address family, protocol and source/destination
2356address/port
2357using the same syntax as filter rules.
2358When parameters are used, the
2359.Ar anchor
2360rule is only evaluated for matching packets.
2361This allows conditional evaluation of anchors, like:
2362.Bd -literal -offset indent
2363block on $ext_if all
2364anchor spam proto tcp from any to any port smtp
2365pass out on $ext_if all keep state
2366pass in on $ext_if proto tcp from any to $ext_if port smtp keep state
2367.Ed
2368.Pp
2369The rules inside
2370.Ar anchor
2371spam are only evaluated for
2372.Ar tcp
2373packets with destination port 25.
2374Hence,
2375.Bd -literal -offset indent
2376# echo \&"block in quick from 1.2.3.4 to any" \&| \e
2377 pfctl -a spam -f -
2378.Ed
2379.Pp
2380will only block connections from 1.2.3.4 to port 25.
2381.Pp
2382Anchors may end with the asterisk
2383.Pq Sq *
2384character, which signifies that all anchors attached at that point
2385should be evaluated in the alphabetical ordering of their anchor name.
2386For example,
2387.Bd -literal -offset indent
2388anchor "spam/*"
2389.Ed
2390.Pp
2391will evaluate each rule in each anchor attached to the
2392.Li spam
2393anchor.
2394Note that it will only evaluate anchors that are directly attached to the
2395.Li spam
2396anchor, and will not descend to evaluate anchors recursively.
2397.Pp
2398Since anchors are evaluated relative to the anchor in which they are
2399contained, there is a mechanism for accessing the parent and ancestor
2400anchors of a given anchor.
2401Similar to file system path name resolution, if the sequence
2402.Dq ..
2403appears as an anchor path component, the parent anchor of the current
2404anchor in the path evaluation at that point will become the new current
2405anchor.
2406As an example, consider the following:
2407.Bd -literal -offset indent
2408# echo ' anchor "spam/allowed" ' | pfctl -f -
2409# echo -e ' anchor "../banned" \en pass' | \e
2410 pfctl -a spam/allowed -f -
2411.Ed
2412.Pp
2413Evaluation of the main ruleset will lead into the
2414.Li spam/allowed
2415anchor, which will evaluate the rules in the
2416.Li spam/banned
2417anchor, if any, before finally evaluating the
2418.Ar pass
2419rule.
2420.Pp
2421Since the parser specification for anchor names is a string, any
2422reference to an anchor name containing solidus
2423.Pq Sq /
2424characters will require double quote
2425.Pq Sq \&"
2426characters around the anchor name.
2427.Sh TRANSLATION EXAMPLES
2428This example maps incoming requests on port 80 to port 8080, on
2429which a daemon is running (because, for example, it is not run as root,
2430and therefore lacks permission to bind to port 80).
2431.Bd -literal
2432# use a macro for the interface name, so it can be changed easily
2433ext_if = \&"ne3\&"
2434
2435# map daemon on 8080 to appear to be on 80
2436rdr on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 port 8080
2437.Ed
2438.Pp
2439If the
2440.Ar pass
2441modifier is given, packets matching the translation rule are passed without
2442inspecting the filter rules:
2443.Bd -literal
2444rdr pass on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 \e
2445 port 8080
2446.Ed
2447.Pp
2448In the example below, vlan12 is configured as 192.168.168.1;
2449the machine translates all packets coming from 192.168.168.0/24 to 204.92.77.111
2450when they are going out any interface except vlan12.
2451This has the net effect of making traffic from the 192.168.168.0/24
2452network appear as though it is the Internet routable address
2453204.92.77.111 to nodes behind any interface on the router except
2454for the nodes on vlan12.
2455(Thus, 192.168.168.1 can talk to the 192.168.168.0/24 nodes.)
2456.Bd -literal
2457nat on ! vlan12 from 192.168.168.0/24 to any -> 204.92.77.111
2458.Ed
2459.Pp
2460In the example below, the machine sits between a fake internal 144.19.74.*
2461network, and a routable external IP of 204.92.77.100.
2462The
2463.Ar no nat
2464rule excludes protocol AH from being translated.
2465.Bd -literal
2466# NO NAT
2467no nat on $ext_if proto ah from 144.19.74.0/24 to any
2468nat on $ext_if from 144.19.74.0/24 to any -> 204.92.77.100
2469.Ed
2470.Pp
2471In the example below, packets bound for one specific server, as well as those
2472generated by the sysadmins are not proxied; all other connections are.
2473.Bd -literal
2474# NO RDR
2475no rdr on $int_if proto { tcp, udp } from any to $server port 80
2476no rdr on $int_if proto { tcp, udp } from $sysadmins to any port 80
2477rdr on $int_if proto { tcp, udp } from any to any port 80 -> 127.0.0.1 \e
2478 port 80
2479.Ed
2480.Pp
2481This longer example uses both a NAT and a redirection.
2482The external interface has the address 157.161.48.183.
2483On the internal interface, we are running
2484.Xr ftp-proxy 8 ,
2485listening for outbound ftp sessions captured to port 8021.
2486.Bd -literal
2487# NAT
2488# Translate outgoing packets' source addresses (any protocol).
2489# In this case, any address but the gateway's external address is mapped.
2490nat on $ext_if inet from ! ($ext_if) to any -> ($ext_if)
2491
2492# NAT PROXYING
2493# Map outgoing packets' source port to an assigned proxy port instead of
2494# an arbitrary port.
2495# In this case, proxy outgoing isakmp with port 500 on the gateway.
2496nat on $ext_if inet proto udp from any port = isakmp to any -> ($ext_if) \e
2497 port 500
2498
2499# BINAT
2500# Translate outgoing packets' source address (any protocol).
2501# Translate incoming packets' destination address to an internal machine
2502# (bidirectional).
2503binat on $ext_if from 10.1.2.150 to any -> $ext_if
2504
2505# RDR
2506# Translate incoming packets' destination addresses.
2507# As an example, redirect a TCP and UDP port to an internal machine.
2508rdr on $ext_if inet proto tcp from any to ($ext_if) port 8080 \e
2509 -> 10.1.2.151 port 22
2510rdr on $ext_if inet proto udp from any to ($ext_if) port 8080 \e
2511 -> 10.1.2.151 port 53
2512
2513# RDR
2514# Translate outgoing ftp control connections to send them to localhost
2515# for proxying with ftp-proxy(8) running on port 8021.
2516rdr on $int_if proto tcp from any to any port 21 -> 127.0.0.1 port 8021
2517.Ed
2518.Pp
2519In this example, a NAT gateway is set up to translate internal addresses
2520using a pool of public addresses (192.0.2.16/28) and to redirect
2521incoming web server connections to a group of web servers on the internal
2522network.
2523.Bd -literal
2524# NAT LOAD BALANCE
2525# Translate outgoing packets' source addresses using an address pool.
2526# A given source address is always translated to the same pool address by
2527# using the source-hash keyword.
2528nat on $ext_if inet from any to any -> 192.0.2.16/28 source-hash
2529
2530# RDR ROUND ROBIN
2531# Translate incoming web server connections to a group of web servers on
2532# the internal network.
2533rdr on $ext_if proto tcp from any to any port 80 \e
2534 -> { 10.1.2.155, 10.1.2.160, 10.1.2.161 } round-robin
2535.Ed
2536.Sh FILTER EXAMPLES
2537.Bd -literal
2538# The external interface is kue0
2539# (157.161.48.183, the only routable address)
2540# and the private network is 10.0.0.0/8, for which we are doing NAT.
2541
2542# use a macro for the interface name, so it can be changed easily
2543ext_if = \&"kue0\&"
2544
2545# normalize all incoming traffic
2546scrub in on $ext_if all fragment reassemble
2547
2548# block and log everything by default
2549block return log on $ext_if all
2550
2551# block anything coming from source we have no back routes for
2552block in from no-route to any
2553
2554# block and log outgoing packets that do not have our address as source,
2555# they are either spoofed or something is misconfigured (NAT disabled,
2556# for instance), we want to be nice and do not send out garbage.
2557block out log quick on $ext_if from ! 157.161.48.183 to any
2558
2559# silently drop broadcasts (cable modem noise)
2560block in quick on $ext_if from any to 255.255.255.255
2561
2562# block and log incoming packets from reserved address space and invalid
2563# addresses, they are either spoofed or misconfigured, we cannot reply to
2564# them anyway (hence, no return-rst).
2565block in log quick on $ext_if from { 10.0.0.0/8, 172.16.0.0/12, \e
2566 192.168.0.0/16, 255.255.255.255/32 } to any
2567
2568# ICMP
2569
2570# pass out/in certain ICMP queries and keep state (ping)
2571# state matching is done on host addresses and ICMP id (not type/code),
2572# so replies (like 0/0 for 8/0) will match queries
2573# ICMP error messages (which always refer to a TCP/UDP packet) are
2574# handled by the TCP/UDP states
2575pass on $ext_if inet proto icmp all icmp-type 8 code 0 keep state
2576
2577# UDP
2578
2579# pass out all UDP connections and keep state
2580pass out on $ext_if proto udp all keep state
2581
2582# pass in certain UDP connections and keep state (DNS)
2583pass in on $ext_if proto udp from any to any port domain keep state
2584
2585# TCP
2586
2587# pass out all TCP connections and modulate state
2588pass out on $ext_if proto tcp all modulate state
2589
2590# pass in certain TCP connections and keep state (SSH, SMTP, DNS, IDENT)
2591pass in on $ext_if proto tcp from any to any port { ssh, smtp, domain, \e
2592 auth } flags S/SA keep state
2593
2594# pass in data mode connections for ftp-proxy running on this host.
2595# (see ftp-proxy(8) for details)
2596pass in on $ext_if proto tcp from any to 157.161.48.183 port >= 49152 \e
2597 flags S/SA keep state
2598
2599# Do not allow Windows 9x SMTP connections since they are typically
2600# a viral worm. Alternately we could limit these OSes to 1 connection each.
2601block in on $ext_if proto tcp from any os {"Windows 95", "Windows 98"} \e
2602 to any port smtp
2603
2604# Packet Tagging
2605
2606# three interfaces: $int_if, $ext_if, and $wifi_if (wireless). NAT is
2607# being done on $ext_if for all outgoing packets. tag packets in on
2608# $int_if and pass those tagged packets out on $ext_if. all other
2609# outgoing packets (i.e., packets from the wireless network) are only
2610# permitted to access port 80.
2611
2612pass in on $int_if from any to any tag INTNET keep state
2613pass in on $wifi_if from any to any keep state
2614
2615block out on $ext_if from any to any
2616pass out quick on $ext_if tagged INTNET keep state
2617pass out on $ext_if proto tcp from any to any port 80 keep state
2618
2619# tag incoming packets as they are redirected to spamd(8). use the tag
2620# to pass those packets through the packet filter.
2621
2622rdr on $ext_if inet proto tcp from <spammers> to port smtp \e
2623 tag SPAMD -> 127.0.0.1 port spamd
2624
2625block in on $ext_if
2626pass in on $ext_if inet proto tcp tagged SPAMD keep state
2627.Ed
2628.Sh GRAMMAR
2629Syntax for
2630.Nm
2631in BNF:
2632.Bd -literal
2633line = ( option | pf-rule | nat-rule | binat-rule | rdr-rule |
2634 antispoof-rule | altq-rule | queue-rule | anchor-rule |
2635 trans-anchors | load-anchors | table-rule )
2636
2637option = "set" ( [ "timeout" ( timeout | "{" timeout-list "}" ) ] |
2638 [ "optimization" [ "default" | "normal" |
2639 "high-latency" | "satellite" |
2640 "aggressive" | "conservative" ] ]
2641 [ "limit" ( limit-item | "{" limit-list "}" ) ] |
2642 [ "loginterface" ( interface-name | "none" ) ] |
2643 [ "block-policy" ( "drop" | "return" ) ] |
2644 [ "state-policy" ( "if-bound" | "group-bound" |
2645 "floating" ) ]
2646 [ "require-order" ( "yes" | "no" ) ]
2647 [ "fingerprints" filename ] |
2648 [ "debug" ( "none" | "urgent" | "misc" | "loud" ) ] )
2649
2650pf-rule = action [ ( "in" | "out" ) ]
2651 [ "log" | "log-all" ] [ "quick" ]
2652 [ "on" ifspec ] [ route ] [ af ] [ protospec ]
2653 hosts [ filteropt-list ]
2654
2655filteropt-list = filteropt-list filteropt | filteropt
2656filteropt = user | group | flags | icmp-type | icmp6-type | tos |
2657 ( "keep" | "modulate" | "synproxy" ) "state"
2658 [ "(" state-opts ")" ] |
2659 "fragment" | "no-df" | "min-ttl" number |
2660 "max-mss" number | "random-id" | "reassemble tcp" |
2661 fragmentation | "allow-opts" |
2662 "label" string | "tag" string | [ ! ] "tagged" string
2663 "queue" ( string | "(" string [ [ "," ] string ] ")" ) |
2664 "probability" number"%"
2665
2666nat-rule = [ "no" ] "nat" [ "pass" ] [ "on" ifspec ] [ af ]
2667 [ protospec ] hosts [ "tag" string ] [ "tagged" string ]
2668 [ "->" ( redirhost | "{" redirhost-list "}" )
2669 [ portspec ] [ pooltype ] [ "static-port" ] ]
2670
2671binat-rule = [ "no" ] "binat" [ "pass" ] [ "on" interface-name ]
2672 [ af ] [ "proto" ( proto-name | proto-number ) ]
2673 "from" address [ "/" mask-bits ] "to" ipspec
2674 [ "tag" string ] [ "tagged" string ]
2675 [ "->" address [ "/" mask-bits ] ]
2676
2677rdr-rule = [ "no" ] "rdr" [ "pass" ] [ "on" ifspec ] [ af ]
2678 [ protospec ] hosts [ "tag" string ] [ "tagged" string ]
2679 [ "->" ( redirhost | "{" redirhost-list "}" )
2680 [ portspec ] [ pooltype ] ]
2681
2682antispoof-rule = "antispoof" [ "log" ] [ "quick" ]
2683 "for" ( interface-name | "{" interface-list "}" )
2684 [ af ] [ "label" string ]
2685
2686table-rule = "table" "<" string ">" [ tableopts-list ]
2687tableopts-list = tableopts-list tableopts | tableopts
2688tableopts = "persist" | "const" | "file" string |
2689 "{" [ tableaddr-list ] "}"
2690tableaddr-list = tableaddr-list [ "," ] tableaddr-spec | tableaddr-spec
2691tableaddr-spec = [ "!" ] tableaddr [ "/" mask-bits ]
2692tableaddr = hostname | ipv4-dotted-quad | ipv6-coloned-hex |
2693 interface-name | "self"
2694
2695altq-rule = "altq on" interface-name queueopts-list
2696 "queue" subqueue
2697queue-rule = "queue" string [ "on" interface-name ] queueopts-list
2698 subqueue
2699
2700anchor-rule = "anchor" string [ ( "in" | "out" ) ] [ "on" ifspec ]
2701 [ af ] [ "proto" ] [ protospec ] [ hosts ]
2702
2703trans-anchors = ( "nat-anchor" | "rdr-anchor" | "binat-anchor" ) string
2704 [ "on" ifspec ] [ af ] [ "proto" ] [ protospec ] [ hosts ]
2705
2706load-anchor = "load anchor" string "from" filename
2707
2708queueopts-list = queueopts-list queueopts | queueopts
2709queueopts = [ "bandwidth" bandwidth-spec ] |
2710 [ "qlimit" number ] | [ "tbrsize" number ] |
2711 [ "priority" number ] | [ schedulers ]
2712schedulers = ( cbq-def | priq-def | hfsc-def )
2713bandwidth-spec = "number" ( "b" | "Kb" | "Mb" | "Gb" | "%" )
2714
2715action = "pass" | "block" [ return ] | [ "no" ] "scrub"
2716return = "drop" | "return" | "return-rst" [ "( ttl" number ")" ] |
2717 "return-icmp" [ "(" icmpcode ["," icmp6code ] ")" ] |
2718 "return-icmp6" [ "(" icmp6code ")" ]
2719icmpcode = ( icmp-code-name | icmp-code-number )
2720icmp6code = ( icmp6-code-name | icmp6-code-number )
2721
2722ifspec = ( [ "!" ] interface-name ) | "{" interface-list "}"
2723interface-list = [ "!" ] interface-name [ [ "," ] interface-list ]
2724route = "fastroute" |
2725 ( "route-to" | "reply-to" | "dup-to" )
2726 ( routehost | "{" routehost-list "}" )
2727 [ pooltype ]
2728af = "inet" | "inet6"
2729
2730protospec = "proto" ( proto-name | proto-number |
2731 "{" proto-list "}" )
2732proto-list = ( proto-name | proto-number ) [ [ "," ] proto-list ]
2733
2734hosts = "all" |
2735 "from" ( "any" | "no-route" | "self" | host |
2736 "{" host-list "}" | "route" string ) [ port ] [ os ]
2737 "to" ( "any" | "no-route" | "self" | host |
2738 "{" host-list "}" | "route" string ) [ port ]
2739
2740ipspec = "any" | host | "{" host-list "}"
2741host = [ "!" ] ( address [ "/" mask-bits ] | "<" string ">" )
2742redirhost = address [ "/" mask-bits ]
2743routehost = ( interface-name [ address [ "/" mask-bits ] ] )
2744address = ( interface-name | "(" interface-name ")" | hostname |
2745 ipv4-dotted-quad | ipv6-coloned-hex )
2746host-list = host [ [ "," ] host-list ]
2747redirhost-list = redirhost [ [ "," ] redirhost-list ]
2748routehost-list = routehost [ [ "," ] routehost-list ]
2749
2750port = "port" ( unary-op | binary-op | "{" op-list "}" )
2751portspec = "port" ( number | name ) [ ":" ( "*" | number | name ) ]
2752os = "os" ( os-name | "{" os-list "}" )
2753user = "user" ( unary-op | binary-op | "{" op-list "}" )
2754group = "group" ( unary-op | binary-op | "{" op-list "}" )
2755
2756unary-op = [ "=" | "!=" | "<" | "<=" | ">" | ">=" ]
2757 ( name | number )
2758binary-op = number ( "<>" | "><" | ":" ) number
2759op-list = ( unary-op | binary-op ) [ [ "," ] op-list ]
2760
2761os-name = operating-system-name
2762os-list = os-name [ [ "," ] os-list ]
2763
2764flags = "flags" [ flag-set ] "/" flag-set
2765flag-set = [ "F" ] [ "S" ] [ "R" ] [ "P" ] [ "A" ] [ "U" ] [ "E" ]
2766 [ "W" ]
2767
2768icmp-type = "icmp-type" ( icmp-type-code | "{" icmp-list "}" )
2769icmp6-type = "icmp6-type" ( icmp-type-code | "{" icmp-list "}" )
2770icmp-type-code = ( icmp-type-name | icmp-type-number )
2771 [ "code" ( icmp-code-name | icmp-code-number ) ]
2772icmp-list = icmp-type-code [ [ "," ] icmp-list ]
2773
2774tos = "tos" ( "lowdelay" | "throughput" | "reliability" |
2775 [ "0x" ] number )
2776
2777state-opts = state-opt [ [ "," ] state-opts ]
2778state-opt = ( "max" number | "no-sync" | timeout |
2779 "source-track" [ ( "rule" | "global" ) ] |
2780 "max-src-nodes" number | "max-src-states" number |
2781 "max-src-conn" number |
2782 "max-src-conn-rate" number "/" number |
2783 "overload" "<" string ">" [ "flush" ] |
2784 "if-bound" | "group-bound" | "floating" )
2785
2786fragmentation = [ "fragment reassemble" | "fragment crop" |
2787 "fragment drop-ovl" ]
2788
2789timeout-list = timeout [ [ "," ] timeout-list ]
2790timeout = ( "tcp.first" | "tcp.opening" | "tcp.established" |
2791 "tcp.closing" | "tcp.finwait" | "tcp.closed" |
2792 "udp.first" | "udp.single" | "udp.multiple" |
2793 "icmp.first" | "icmp.error" |
2794 "other.first" | "other.single" | "other.multiple" |
2795 "frag" | "interval" | "src.track" |
2796 "adaptive.start" | "adaptive.end" ) number
2797
2798limit-list = limit-item [ [ "," ] limit-list ]
2799limit-item = ( "states" | "frags" | "src-nodes" ) number
2800
2801pooltype = ( "bitmask" | "random" |
2802 "source-hash" [ ( hex-key | string-key ) ] |
2803 "round-robin" ) [ sticky-address ]
2804
2805subqueue = string | "{" queue-list "}"
2806queue-list = string [ [ "," ] string ]
2807cbq-def = "cbq" [ "(" cbq-opt [ [ "," ] cbq-opt ] ")" ]
2808priq-def = "priq" [ "(" priq-opt [ [ "," ] priq-opt ] ")" ]
2809hfsc-def = "hfsc" [ "(" hfsc-opt [ [ "," ] hfsc-opt ] ")" ]
2810cbq-opt = ( "default" | "borrow" | "red" | "ecn" | "rio" )
2811priq-opt = ( "default" | "red" | "ecn" | "rio" )
2812hfsc-opt = ( "default" | "red" | "ecn" | "rio" |
2813 linkshare-sc | realtime-sc | upperlimit-sc )
2814linkshare-sc = "linkshare" sc-spec
2815realtime-sc = "realtime" sc-spec
2816upperlimit-sc = "upperlimit" sc-spec
2817sc-spec = ( bandwidth-spec |
2818 "(" bandwidth-spec number bandwidth-spec ")" )
2819.Ed
2820.Sh FILES
2821.Bl -tag -width "/usr/share/examples/pf" -compact
2822.It Pa /etc/hosts
2823Host name database.
2824.It Pa /etc/pf.conf
2825Default location of the ruleset file.
2826.It Pa /etc/pf.os
2827Default location of OS fingerprints.
2828.It Pa /etc/protocols
2829Protocol name database.
2830.It Pa /etc/services
2831Service name database.
2832.It Pa /usr/share/examples/pf
2833Example rulesets.
2834.El
2835.Sh BUGS
2836Due to a lock order reversal (LOR) with the socket layer, the use of the
2837.Ar group
2838and
2839.Ar user
2840filter parameter in conjuction with a Giant-free netstack
2841can result in a deadlock.
2842If you have to use
2843.Ar group
2844or
2845.Ar user
2846you must set
2847.Va debug.mpsafenet
2848to
2849.Dq 0
2850from the
2851.Xr loader 8 ,
2852for the moment.
2853This workaround will still produce the LOR, but Giant will protect from the
2854deadlock.
2855.Pp
2856Route labels are not supported by the
2857.Fx
2858.Xr route 4
2859system.
2860Rules with a route label do not match any traffic.
2861.Sh SEE ALSO
2862.Xr altq 4 ,
2863.Xr icmp 4 ,
2864.Xr icmp6 4 ,
2865.Xr ip 4 ,
2866.Xr ip6 4 ,
2867.Xr pf 4 ,
2868.Xr pfsync 4 ,
2869.Xr route 4 ,
2870.Xr tcp 4 ,
2871.Xr udp 4 ,
2872.Xr hosts 5 ,
2873.Xr pf.os 5 ,
2874.Xr protocols 5 ,
2875.Xr services 5 ,
2876.Xr ftp-proxy 8 ,
2877.Xr pfctl 8 ,
2878.Xr pflogd 8 ,
2879.Xr route 8
2880.Sh HISTORY
2881The
2882.Nm
2883file format first appeared in
2884.Ox 3.0 .