1 .\" $OpenBSD: pf.conf.5,v 1.291 2004/02/04 19:38:30 jmc Exp $
2 .\" $DragonFly: src/usr.sbin/pfctl/pf.conf.5,v 1.14 2008/04/15 23:00:52 swildner Exp $
4 .\" Copyright (c) 2002, Daniel Hartmeier
5 .\" All rights reserved.
7 .\" Redistribution and use in source and binary forms, with or without
8 .\" modification, are permitted provided that the following conditions
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.
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.
36 .Nd packet filter configuration file
40 packet filter modifies, drops or passes packets according to rules or
41 definitions specified in
44 There are seven types of statements in
48 User-defined variables may be defined and used later, simplifying
49 the configuration file.
50 Macros must be defined before they are referenced in
53 Tables provide a mechanism for increasing the performance and flexibility of
54 rules with large numbers of source or destination addresses.
56 Options tune the behaviour of the packet filtering engine.
57 .It Cm Traffic Normalization Li (e.g.\& Em scrub )
58 Traffic normalization protects internal machines against inconsistencies
59 in Internet protocols and implementations.
61 Queueing provides rule-based bandwidth control.
62 .It Cm Translation Li (Various forms of NAT)
63 Translation rules specify how addresses are to be mapped or redirected to
65 .It Cm Packet Filtering
66 Stateful and stateless packet filtering provides rule-based blocking or
74 the types of statements should be grouped and appear in
76 in the order shown above, as this matches the operation of the underlying
77 packet filtering engine.
80 enforces this order (see
88 macros can be defined that will later be expanded in context.
89 Macro names must start with a letter, and may contain letters, digits
91 Macro names may not be reserved words (for example
95 Macros are not expanded inside quotes.
98 .Bd -literal -offset indent
100 all_ifs = \&"{\&" $ext_if lo0 \&"}\&"
101 pass out on $ext_if from any to any keep state
102 pass in on $ext_if proto tcp from any to any port 25 keep state
105 Tables are named structures which can hold a collection of addresses and
107 Lookups against tables in
109 are relatively fast, making a single rule with tables much more efficient,
111 processor usage and memory consumption, than a large number of rules which
112 differ only in IP address (either created explicitly or automatically by rule
115 Tables can be used as the source or destination of filter rules,
119 translation rules such as
123 (see below for details on the various rule types).
124 Tables can also be used for the redirect address of
128 rules and in the routing options of filter rules, but only for
132 Tables can be defined with any of the following
135 As with macros, reserved words may not be used as table names.
136 .Bl -tag -width "manually"
138 Persistent tables can be manually created with the
144 before or after the ruleset has been loaded.
146 Table definitions can be placed directly in this file, and loaded at the
147 same time as other rules are loaded, atomically.
148 Table definitions inside
152 statement, and are especially useful to define non-persistent tables.
153 The contents of a pre-existing table defined without a list of addresses
154 to initialize it is not altered when
157 A table initialized with the empty list,
159 will be cleared on load.
162 Tables may be defined with the following two attributes:
163 .Bl -tag -width persist
167 flag forces the kernel to keep the table even when no rules refer to it.
168 If the flag is not set, the kernel will automatically remove the table
169 when the last rule referring to it is flushed.
173 flag prevents the user from altering the contents of the table once it
177 can be used to add or remove addresses from the table at any time, even
184 .Bd -literal -offset indent
185 table <private> const { 10/8, 172.16/12, 192.168/16 }
186 table <badhosts> persist
187 block on fxp0 from { <private>, <badhosts> } to any
190 creates a table called private, to hold RFC 1918 private network
191 blocks, and a table called badhosts, which is initially empty.
192 A filter rule is set up to block all traffic coming from addresses listed in
194 The private table cannot have its contents changed and the badhosts table
195 will exist even when no active filter rules reference it.
196 Addresses may later be added to the badhosts table, so that traffic from
197 these hosts can be blocked by using
198 .Bd -literal -offset indent
199 # pfctl -t badhosts -Tadd 204.92.77.111
202 A table can also be initialized with an address list specified in one or more
203 external files, using the following syntax:
204 .Bd -literal -offset indent
205 table <spam> persist file \&"/etc/spammers\&" file \&"/etc/openrelays\&"
206 block on fxp0 from <spam> to any
213 list IP addresses, one per line.
214 Any lines beginning with a # are treated as comments and ignored.
215 In addition to being specified by IP address, hosts may also be
216 specified by their hostname.
217 When the resolver is called to add a hostname to a table,
219 resulting IPv4 and IPv6 addresses are placed into the table.
220 IP addresses can also be entered in a table by specifying a valid interface
223 keyword, in which case all addresses assigned to the interface(s) will be
227 may be tuned for various situations using the
233 .Bl -tag -width interval -compact
235 Interval between purging expired states and fragments.
237 Seconds before an unassembled fragment is expired.
239 Length of time to retain a source tracking entry after the last state
243 When a packet matches a stateful connection, the seconds to live for the
244 connection will be updated to that of the
246 which corresponds to the connection state.
247 Each packet which matches this state will reset the TTL.
248 Tuning these values may improve the performance of the
249 firewall at the risk of dropping valid idle connections.
251 .Bl -tag -width xxxx -compact
253 The state after the first packet.
255 The state before the destination host ever sends a packet.
256 .It Ar tcp.established
257 The fully established state.
259 The state after the first FIN has been sent.
261 The state after both FINs have been exchanged and the connection is closed.
262 Some hosts (notably web servers on Solaris) send TCP packets even after closing
268 can prevent blocking of such packets.
270 The state after one endpoint sends an RST.
273 ICMP and UDP are handled in a fashion similar to TCP, but with a much more
274 limited set of states:
276 .Bl -tag -width xxxx -compact
278 The state after the first packet.
280 The state if the source host sends more than one packet but the destination
281 host has never sent one back.
283 The state if both hosts have sent packets.
285 The state after the first packet.
287 The state after an ICMP error came back in response to an ICMP packet.
290 Other protocols are handled similarly to UDP:
292 .Bl -tag -width xxxx -compact
295 .It Ar other.multiple
298 Timeout values can be reduced adaptively as the number of state table
301 .Bl -tag -width xxxx -compact
302 .It Ar adaptive.start
303 When the number of state entries exceeds this value, adaptive scaling
305 All timeout values are scaled linearly with factor
306 (adaptive.end - number of states) / (adaptive.end - adaptive.start).
308 When reaching this number of state entries, all timeout values become
309 zero, effectively purging all state entries immediately.
310 This value is used to define the scale factor, it should not actually
311 be reached (set a lower state limit, see below).
314 These values can be defined both globally and for each rule.
315 When used on a per-rule basis, the values relate to the number of
316 states created by the rule, otherwise to the total number of
320 .Bd -literal -offset indent
321 set timeout tcp.first 120
322 set timeout tcp.established 86400
323 set timeout { adaptive.start 6000, adaptive.end 12000 }
324 set limit states 10000
327 With 9000 state table entries, the timeout values are scaled to 50%
328 (tcp.first 60, tcp.established 43200).
330 .It Ar set loginterface
331 Enable collection of packet and byte count statistics for the given interface.
332 These statistics can be viewed using
333 .Bd -literal -offset indent
339 collects statistics on the interface named dc0:
340 .Bd -literal -offset indent
344 One can disable the loginterface using:
345 .Bd -literal -offset indent
346 set loginterface none
350 Sets hard limits on the memory zones used by the packet filter.
353 for an explanation of memory zones.
356 .Bd -literal -offset indent
357 set limit states 20000
360 sets the maximum number of entries in the memory pool used by state table
361 entries (generated by
365 .Bd -literal -offset indent
366 set limit frags 20000
369 sets the maximum number of entries in the memory pool used for fragment
370 reassembly (generated by
374 .Bd -literal -offset indent
375 set limit src-nodes 2000
378 sets the maximum number of entries in the memory pool used for tracking
379 source IP addresses (generated by the
385 These can be combined:
386 .Bd -literal -offset indent
387 set limit { states 20000, frags 20000, src-nodes 2000 }
390 .It Ar set optimization
391 Optimize the engine for one of the following network environments:
393 .Bl -tag -width xxxx -compact
395 A normal network environment.
396 Suitable for almost all networks.
398 A high-latency environment (such as a satellite connection).
403 Aggressively expire connections.
404 This can greatly reduce the memory usage of the firewall at the cost of
405 dropping idle connections early.
407 Extremely conservative settings.
408 Avoid dropping legitimate connections at the
409 expense of greater memory utilization (possibly much greater on a busy
410 network) and slightly increased processor utilization.
414 .Bd -literal -offset indent
415 set optimization aggressive
418 .It Ar set keep-policy keep_rule
421 option sets the default state retention policy for all pass rules.
422 Any keep/modulate/synproxy state directives in a pass rule will overriide
425 .Bd -literal -offset indent
426 set keep-policy keep state (pickups)
429 .It Ar set block-policy
432 option sets the default behaviour for the packet
436 .Bl -tag -width xxxxxxxx -compact
438 Packet is silently dropped.
440 A TCP RST is returned for blocked TCP packets,
441 an ICMP UNREACHABLE is returned for blocked UDP packets,
442 and all other packets are silently dropped.
446 .Bd -literal -offset indent
447 set block-policy return
449 .It Ar set state-policy
452 option sets the default behaviour for states:
454 .Bl -tag -width group-bound -compact
456 States are bound to interface.
458 States are bound to interface group (i.e., ppp)
460 States can match packets on any interfaces (the default).
464 .Bd -literal -offset indent
465 set state-policy if-bound
467 .It Ar set require-order
470 enforces an ordering of the statement types in the ruleset to:
476 Setting this option to
478 disables this enforcement.
479 There may be non-trivial and non-obvious implications to an out of
481 Consider carefully before disabling the order enforcement.
482 .It Ar set fingerprints
483 Load fingerprints of known operating systems from the given filename.
484 By default fingerprints of known operating systems are automatically
489 but can be overridden via this option.
490 Setting this option may leave a small period of time where the fingerprints
491 referenced by the currently active ruleset are inconsistent until the new
492 ruleset finishes loading.
496 .Dl set fingerprints \&"/etc/pf.os.devel\&"
501 to one of the following:
503 .Bl -tag -width xxxxxxxxxxxx -compact
505 Don't generate debug messages.
507 Generate debug messages only for serious errors.
509 Generate debug messages for various errors.
511 Generate debug messages for common conditions.
514 .Sh TRAFFIC NORMALIZATION
515 Traffic normalization is used to sanitize packet content in such
516 a way that there are no ambiguities in packet interpretation on
518 The normalizer does IP fragment reassembly to prevent attacks
519 that confuse intrusion detection systems by sending overlapping
521 Packet normalization is invoked with the
526 has the following options:
531 bit from a matching IP packet.
532 Some operating systems are known to generate fragmented packets with the
535 This is particularly true with NFS.
537 will drop such fragmented
543 Unfortunately some operating systems also generate their
545 packets with a zero IP identification field.
548 bit on packets with a zero IP ID may cause deleterious results if an
549 upstream router later fragments the packet.
552 modifier (see below) is recommended in combination with the
554 modifier to ensure unique IP identifiers.
555 .It Ar min-ttl <number>
556 Enforces a minimum TTL for matching IP packets.
557 .It Ar max-mss <number>
558 Enforces a maximum MSS for matching TCP packets.
560 Replaces the IP identification field with random values to compensate
561 for predictable values generated by many hosts.
562 This option only applies to outgoing packets that are not fragmented
563 after the optional fragment reassembly.
564 .It Ar fragment reassemble
567 rules, fragments can be reassembled by normalization.
568 In this case, fragments are buffered until they form a complete
569 packet, and only the completed packet is passed on to the filter.
570 The advantage is that filter rules have to deal only with complete
571 packets, and can ignore fragments.
572 The drawback of caching fragments is the additional memory cost.
573 But the full reassembly method is the only method that currently works
575 This is the default behavior of a
577 rule if no fragmentation modifier is supplied.
579 The default fragment reassembly method is expensive, hence the option
583 will track the fragments and cache a small range descriptor.
584 Duplicate fragments are dropped and overlaps are cropped.
585 Thus data will only occur once on the wire with ambiguities resolving to
586 the first occurrence.
588 .Ar fragment reassemble
589 modifier, fragments are not buffered, they are passed as soon as they
593 reassembly mechanism does not yet work with NAT.
595 .It Ar fragment drop-ovl
596 This option is similar to the
598 modifier except that all overlapping or duplicate fragments will be
599 dropped, and all further corresponding fragments will be
601 .It Ar reassemble tcp
602 Statefully normalizes TCP connections.
603 .Ar scrub reassemble tcp
604 rules may not have the direction (in/out) specified.
606 performs the following normalizations:
608 .Bl -tag -width timeout -compact
610 Neither side of the connection is allowed to reduce their IP TTL.
611 An attacker may send a packet such that it reaches the firewall, affects
612 the firewall state, and expires before reaching the destination host.
614 will raise the TTL of all packets back up to the highest value seen on
616 .It timeout modulation
617 Modern TCP stacks will send a timestamp on every TCP packet and echo
618 the other endpoint's timestamp back to them.
619 Many operating systems will merely start the timestamp at zero when
620 first booted, and increment it several times a second.
621 The uptime of the host can be deduced by reading the timestamp and multiplying
623 Also observing several different timestamps can be used to count hosts
625 And spoofing TCP packets into a connection requires knowing or guessing
627 Timestamps merely need to be monotonically increasing and not derived off a
632 to modulate the TCP timestamps with a random number.
637 .Bd -literal -offset indent
638 scrub in on $ext_if all fragment reassemble
641 Packets can be assigned to queues for the purpose of bandwidth
643 At least two declarations are required to configure queues, and later
644 any packet filtering rule can reference the defined queues by name.
645 During the filtering component of
649 name is where any packets from
651 rules will be queued, while for
653 rules it specifies where any resulting ICMP or TCP RST
654 packets should be queued.
657 defines the algorithm used to decide which packets get delayed, dropped, or
658 sent out immediately.
664 Class Based Queueing.
666 attached to an interface build a tree, thus each
668 can have further child
670 Each queue can have a
676 mainly controls the time packets take to get sent out, while
678 has primarily effects on throughput.
682 are flat attached to the interface, thus,
684 cannot have further child
690 assigned, ranging from 0 to 15.
697 Hierarchical Fair Service Curve.
699 attached to an interface build a tree, thus each
701 can have further child
703 Each queue can have a
709 mainly controls the time packets take to get sent out, while
711 has primarily effects on throughput.
715 are flat attached to the interface, thus,
717 cannot have further child
719 Each queue must be given a unique priority and one must be marked
720 as the default queue.
721 Each queue implements a number of buckets (default 256) which sorts the
722 traffic based on a hash key generated by the
724 facility in your pass rules.
725 Each bucket contains a list of packets controlled by
729 to function properly,
731 must be enabled on most of the rule sets that route packets to the queue.
732 Any rules for which keep state is not enabled are added to the end of the
733 queue. If you do not wish keep state to do TCP sequence space checks use
734 .Ar keep state ( no-pickups )
736 .Ar keep state ( hash-only ) .
738 Packet selection operates as follows:
739 The queues are scanned from highest priority to lowest priority.
740 If a queue has pending packets and has not reached its bandwidth limit the
741 scan stops and a packet is selected from that queue.
742 If a queue has reached its bandwidth limit the scan continues searching for
743 other, lower priority queues which have not.
744 If no queue is found to be
745 suitable then the highest priority queue with pending packets is used
746 regardless of whether it has reached its bandwidth limit or not.
750 round robins between its buckets, extracting one packet from each bucket.
751 This essentially prevents large backlogs of packets from high volume
752 connections from destroying the interactive response of other connections.
758 is guaranteed minimum and more will be used if no higher priority traffic is
760 Creating a queue with one bucket as a catch-all for pass rules
764 Such a queue serves as a basic priority queue with a bandwidth
768 The interfaces on which queueing should be activated are declared using
773 has the following keywords:
776 Queueing is enabled on the named interface.
778 Specifies which queueing scheduler to use.
779 Currently supported values
782 for Class Based Queueing,
784 for Priority Queueing,
786 for the Hierarchical Fair Service Curve scheduler, and
788 for the Fair Queueing.
789 .It Ar bandwidth <bw>
790 The maximum bitrate for all queues on an
791 interface may be specified using the
794 The value can be specified as an absolute value or as a
795 percentage of the interface bandwidth.
796 When using an absolute value, the suffixes
802 are used to represent bits, kilobits, megabits, and
803 gigabits per second, respectively.
804 The value must not exceed the interface bandwidth.
807 is not specified, the interface bandwidth is used.
812 specifies a guaranteed minimum but the fairq is allowed to exceed it.
813 .It Ar qlimit <limit>
814 The maximum number of packets held in the queue.
816 .It Ar tbrsize <size>
817 Adjusts the size, in bytes, of the token bucket regulator.
818 If not specified, heuristics based on the
819 interface bandwidth are used to determine the size.
821 Defines a list of subqueues to create on an interface.
824 In the following example, the interface dc0
825 should queue up to 5 Mbit/s in four second-level queues using
826 Class Based Queueing.
827 Those four queues will be shown in a later example.
828 .Bd -literal -offset indent
829 altq on dc0 cbq bandwidth 5Mb queue { std, http, mail, ssh }
832 Once interfaces are activated for queueing using the
834 directive, a sequence of
836 directives may be defined.
837 The name associated with a
839 must match a queue defined in the
841 directive (e.g.\& mail), or, except for the
847 The following keywords can be used:
849 .It Ar on <interface>
850 Specifies the interface the queue operates on.
851 If not given, it operates on all matching interfaces.
852 .It Ar bandwidth <bw>
853 Specifies the maximum bitrate to be processed by the queue.
854 This value must not exceed the value of the parent
856 and can be specified as an absolute value or a percentage of the parent
860 scheduler does not support bandwidth specification.
863 scheduler uses the bandwidth specification as a guaranteed minimum and
865 .It Ar priority <level>
866 Between queues a priority level can be set.
872 the range is 0 to 7 and for
874 the range is 0 to 15.
875 The default for all is 1.
877 queues with a higher priority are always served first.
879 queues with a higher priority are served first unless they exceed their
880 bandwidth specification.
884 queues with a higher priority are preferred in the case of overload.
885 .It Ar qlimit <limit>
886 The maximum number of packets held in the queue.
890 this specified the maximum number of packets held per bucket.
895 can get additional parameters with
896 .Ar <scheduler> Ns Li (\& Ar <parameters> No ) .
897 Parameters are as follows:
900 Packets not matched by another queue are assigned to this one.
901 Exactly one default queue is required.
903 Enable RED (Random Early Detection) on this queue.
904 RED drops packets with a probability proportional to the average
907 Enables RIO on this queue.
908 RIO is RED with IN/OUT, thus running
909 RED two times more than RIO would achieve the same effect.
910 RIO is currently not supported in the GENERIC kernel.
912 Enables ECN (Explicit Congestion Notification) on this queue.
919 supports the following additional options:
921 .It Ar buckets <number>
922 Specify the number of buckets, from 1 to 2048 in powers of 2.
923 A bucket size of 1 causes a
925 to essentially degenerate into a priority queue.
926 .It Ar linkshare <sc>
927 The bandwidth share of a backlogged queue.
928 This option is parsed but not yet supported.
929 .It Ar hogs <bandwidth>
930 This option allows low bandwidth connections to burst up to the specified
931 bandwidth by not advancing the round robin when taking packets out of
933 When using this option a small value no greater then 1/20 available interface
934 bandwidth is recommended.
940 supports an additional option:
943 The queue can borrow bandwidth from the parent.
949 supports some additional options:
952 The minimum required bandwidth for the queue.
953 .It Ar upperlimit <sc>
954 The maximum allowed bandwidth for the queue.
955 .It Ar linkshare <sc>
956 The bandwidth share of a backlogged queue.
959 <sc> is an acronym for
962 The format for service curve specifications is
963 .Ar ( m1 , d , m2 ) .
965 controls the bandwidth assigned to the queue.
969 are optional and can be used to control the initial bandwidth assignment.
972 milliseconds the queue gets the bandwidth given as
974 afterwards the value given in
981 child queues can be specified as in an
983 declaration, thus building a tree of queues using a part of
984 their parent's bandwidth.
986 Packets can be assigned to queues based on filter rules by using the
991 is specified; when a second one is specified it will instead be used for
996 and for TCP ACKs with no data payload.
998 To continue the previous example, the examples below would specify the
1000 queues, plus a few child queues.
1003 sessions get priority over bulk transfers like
1007 The queues may then be referenced by filtering rules (see
1008 .Sx PACKET FILTERING
1011 queue std bandwidth 10% cbq(default)
1012 queue http bandwidth 60% priority 2 cbq(borrow red) \e
1013 { employees, developers }
1014 queue developers bandwidth 75% cbq(borrow)
1015 queue employees bandwidth 15%
1016 queue mail bandwidth 10% priority 0 cbq(borrow ecn)
1017 queue ssh bandwidth 20% cbq(borrow) { ssh_interactive, ssh_bulk }
1018 queue ssh_interactive priority 7
1019 queue ssh_bulk priority 0
1021 block return out on dc0 inet all queue std
1022 pass out on dc0 inet proto tcp from $developerhosts to any port 80 \e
1023 keep state queue developers
1024 pass out on dc0 inet proto tcp from $employeehosts to any port 80 \e
1025 keep state queue employees
1026 pass out on dc0 inet proto tcp from any to any port 22 \e
1027 keep state queue(ssh_bulk, ssh_interactive)
1028 pass out on dc0 inet proto tcp from any to any port 25 \e
1029 keep state queue mail
1032 Translation rules modify either the source or destination address of the
1033 packets associated with a stateful connection.
1034 A stateful connection is automatically created to track packets matching
1035 such a rule as long as they are not blocked by the filtering section of
1037 The translation engine modifies the specified address and/or port in the
1038 packet, recalculates IP, TCP and UDP checksums as necessary, and passes it to
1039 the packet filter for evaluation.
1041 Since translation occurs before filtering the filter
1042 engine will see packets as they look after any
1043 addresses and ports have been translated.
1044 Filter rules will therefore have to filter based on the translated
1045 address and port number.
1046 Packets that match a translation rule are only automatically passed if
1049 modifier is given, otherwise they are
1056 The state entry created permits
1058 to keep track of the original address for traffic associated with that state
1059 and correctly direct return traffic for that connection.
1061 Various types of translation are possible with pf:
1062 .Bl -tag -width xxxx
1066 rule specifies a bidirectional mapping between an external IP netblock
1067 and an internal IP netblock.
1071 rule specifies that IP addresses are to be changed as the packet
1072 traverses the given interface.
1073 This technique allows one or more IP addresses
1074 on the translating host to support network traffic for a larger range of
1075 machines on an "inside" network.
1076 Although in theory any IP address can be used on the inside, it is strongly
1077 recommended that one of the address ranges defined by RFC 1918 be used.
1078 These netblocks are:
1080 10.0.0.0 - 10.255.255.255 (all of net 10, i.e., 10/8)
1081 172.16.0.0 - 172.31.255.255 (i.e., 172.16/12)
1082 192.168.0.0 - 192.168.255.255 (i.e., 192.168/16)
1085 The packet is redirected to another destination and possibly a
1088 rules can optionally specify port ranges instead of single ports.
1089 rdr ... port 2000:2999 -> ... port 4000
1090 redirects ports 2000 to 2999 (inclusive) to port 4000.
1091 rdr ... port 2000:2999 -> ... port 4000:*
1092 redirects port 2000 to 4000, 2001 to 4001, ..., 2999 to 4999.
1095 In addition to modifying the address, some translation rules may modify
1096 source or destination ports for
1100 connections; implicitly in the case of
1102 rules and explicitly in the case of
1105 Port numbers are never translated with a
1109 For each packet processed by the translator, the translation rules are
1110 evaluated in sequential order, from first to last.
1111 The first matching rule decides what action is taken.
1115 option prefixed to a translation rule causes packets to remain untranslated,
1116 much in the same way as
1118 works in the packet filter (see below).
1119 If no rule matches the packet it is passed to the filter engine unmodified.
1121 Translation rules apply only to packets that pass through
1122 the specified interface, and if no interface is specified,
1123 translation is applied to packets on all interfaces.
1124 For instance, redirecting port 80 on an external interface to an internal
1125 web server will only work for connections originating from the outside.
1126 Connections to the address of the external interface from local hosts will
1127 not be redirected, since such packets do not actually pass through the
1129 Redirections cannot reflect packets back through the interface they arrive
1130 on, they can only be redirected to hosts connected to different interfaces
1131 or to the firewall itself.
1133 Note that redirecting external incoming connections to the loopback
1135 .Bd -literal -offset indent
1136 rdr on ne3 inet proto tcp to port 8025 -> 127.0.0.1 port 25
1139 will effectively allow an external host to connect to daemons
1140 bound solely to the loopback address, circumventing the traditional
1141 blocking of such connections on a real interface.
1142 Unless this effect is desired, any of the local non-loopback addresses
1143 should be used as redirection target instead, which allows external
1144 connections only to daemons bound to this address or not bound to
1148 .Sx TRANSLATION EXAMPLES
1150 .Sh PACKET FILTERING
1156 packets based on attributes of their layer 3 (see
1166 In addition, packets may also be
1167 assigned to queues for the purpose of bandwidth control.
1169 For each packet processed by the packet filter, the filter rules are
1170 evaluated in sequential order, from first to last.
1171 The last matching rule decides what action is taken.
1173 The following actions can be used in the filter:
1174 .Bl -tag -width xxxx
1176 The packet is blocked.
1177 There are a number of ways in which a
1179 rule can behave when blocking a packet.
1180 The default behaviour is to
1182 packets silently, however this can be overridden or made
1183 explicit either globally, by setting the
1185 option, or on a per-rule basis with one of the following options:
1187 .Bl -tag -width xxxx -compact
1189 The packet is silently dropped.
1191 This applies only to
1193 packets, and issues a TCP RST which closes the
1197 This causes ICMP messages to be returned for packets which match the rule.
1198 By default this is an ICMP UNREACHABLE message, however this
1199 can be overridden by specifying a message as a code or number.
1201 This causes a TCP RST to be returned for
1203 packets and an ICMP UNREACHABLE for UDP and other packets.
1206 Options returning packets have no effect if
1211 The packet is passed.
1214 If no rule matches the packet, the default action is
1217 To block everything by default and only pass packets
1218 that match explicit rules, one uses
1219 .Bd -literal -offset indent
1223 as the first filter rule.
1229 The rule parameters specify the packets to which a rule applies.
1230 A packet always comes in on, or goes out through, one interface.
1231 Most parameters are optional.
1232 If a parameter is specified, the rule only applies to packets with
1233 matching attributes.
1234 Certain parameters can be expressed as lists, in which case
1236 generates all needed rule combinations.
1237 .Bl -tag -width xxxx
1238 .It Ar in No or Ar out
1239 This rule applies to incoming or outgoing packets.
1244 are specified, the rule will match packets in both directions.
1246 In addition to the action specified, a log message is generated.
1247 All packets for that connection are logged, unless the
1252 options are specified, in which case only the
1253 packet that establishes the state is logged.
1260 The logged packets are sent to the
1263 This interface is monitored by the
1265 logging daemon, which dumps the logged packets to the file
1276 rules to force logging of all packets for a connection.
1279 packets are logged to
1282 If a packet matches a rule which has the
1284 option set, this rule
1285 is considered the last matching rule, and evaluation of subsequent rules
1287 .It Ar on <interface>
1288 This rule applies only to packets coming in on, or going out through, this
1289 particular interface.
1290 It is also possible to simply give the interface driver name, like ppp or fxp,
1291 to make the rule match packets flowing through a group of interfaces.
1293 This rule applies only to packets of this address family.
1294 Supported values are
1298 .It Ar proto <protocol>
1299 This rule applies only to packets of this protocol.
1300 Common protocols are
1306 For a list of all the protocol name to number mappings used by
1309 .Pa /etc/protocols .
1311 .Ar from <source> port <source> os <source>
1312 .Ar to <dest> port <dest>
1314 This rule applies only to packets with the specified source and destination
1315 addresses and ports.
1317 Addresses can be specified in CIDR notation (matching netblocks), as
1318 symbolic host names or interface names, or as any of the following keywords:
1320 .Bl -tag -width xxxxxxxxxxxx -compact
1324 Any address which is not currently routable.
1326 Any address that matches the given table.
1329 Interface names can have modifiers appended:
1331 .Bl -tag -width xxxxxxxxxxxx -compact
1333 Translates to the network(s) attached to the interface.
1335 Translates to the interface's broadcast address(es).
1337 Translates to the point to point interface's peer address(es).
1339 Do not include interface aliases.
1342 Host names may also have the
1344 option appended to restrict the name resolution to the first of each
1345 v4 and v6 address found.
1347 Host name resolution and interface to address translation are done at
1349 When the address of an interface (or host name) changes (under DHCP or PPP,
1350 for instance), the ruleset must be reloaded for the change to be reflected
1352 Surrounding the interface name (and optional modifiers) in parentheses
1353 changes this behaviour.
1354 When the interface name is surrounded by parentheses, the rule is
1355 automatically updated whenever the interface changes its address.
1356 The ruleset does not need to be reloaded.
1357 This is especially useful with
1360 Ports can be specified either by number or by name.
1361 For example, port 80 can be specified as
1363 For a list of all port name to number mappings used by
1368 Ports and ranges of ports are specified by using these operators:
1369 .Bd -literal -offset indent
1373 <= (less than or equal)
1375 >= (greater than or equal)
1376 : (range including boundaries)
1377 >< (range excluding boundaries)
1382 are binary operators (they take two arguments).
1385 .It Ar port 2000:2004
1387 .Sq all ports \(>= 2000 and \(<= 2004 ,
1388 hence ports 2000, 2001, 2002, 2003 and 2004.
1389 .It Ar port 2000 >< 2004
1391 .Sq all ports > 2000 and < 2004 ,
1392 hence ports 2001, 2002 and 2003.
1393 .It Ar port 2000 <> 2004
1395 .Sq all ports < 2000 or > 2004 ,
1396 hence ports 1-1999 and 2005-65535.
1399 The operating system of the source host can be specified in the case of TCP
1404 .Sx OPERATING SYSTEM FINGERPRINTING
1405 section for more information.
1407 The host, port and OS specifications are optional, as in the following examples:
1408 .Bd -literal -offset indent
1410 pass in from any to any
1411 pass in proto tcp from any port <= 1024 to any
1412 pass in proto tcp from any to any port 25
1413 pass in proto tcp from 10.0.0.0/8 port > 1024 \e
1414 to ! 10.1.2.3 port != ssh
1415 pass in proto tcp from any os "OpenBSD" flags S/SA
1418 This is equivalent to "from any to any".
1419 .It Ar group <group>
1422 this rule only applies to packets of sockets owned by the specified group.
1424 This rule only applies to packets of sockets owned by the specified user.
1425 For outgoing connections initiated from the firewall, this is the user
1426 that opened the connection.
1427 For incoming connections to the firewall itself, this is the user that
1428 listens on the destination port.
1429 For forwarded connections, where the firewall is not a connection endpoint,
1430 the user and group are
1433 All packets, both outgoing and incoming, of one connection are associated
1434 with the same user and group.
1435 Only TCP and UDP packets can be associated with users; for other protocols
1436 these parameters are ignored.
1438 User and group refer to the effective (as opposed to the real) IDs, in
1439 case the socket is created by a setuid/setgid process.
1440 User and group IDs are stored when a socket is created;
1441 when a process creates a listening socket as root (for instance, by
1442 binding to a privileged port) and subsequently changes to another
1443 user ID (to drop privileges), the credentials will remain root.
1445 User and group IDs can be specified as either numbers or names.
1446 The syntax is similar to the one for ports.
1449 matches packets of forwarded connections.
1451 can only be used with the operators
1455 Other constructs like
1458 Forwarded packets with unknown user and group ID match only rules
1459 that explicitly compare against
1467 does not match forwarded packets.
1468 The following example allows only selected users to open outgoing
1470 .Bd -literal -offset indent
1471 block out proto { tcp, udp } all
1472 pass out proto { tcp, udp } all \e
1473 user { < 1000, dhartmei } keep state
1475 .It Ar flags <a>/<b> | /<b>
1476 This rule only applies to TCP packets that have the flags
1480 Flags not specified in
1483 The flags are: (F)IN, (S)YN, (R)ST, (P)USH, (A)CK, (U)RG, (E)CE, and C(W)R.
1487 The other flags are ignored.
1489 Out of SYN and ACK, exactly SYN may be set.
1490 SYN, SYN+PSH and SYN+RST match, but SYN+ACK, ACK and ACK+RST do not.
1491 This is more restrictive than the previous example.
1493 If the first set is not specified, it defaults to none.
1494 All of SYN, FIN, RST and ACK must be unset.
1496 .It Ar icmp-type <type> code <code>
1497 .It Ar icmp6-type <type> code <code>
1498 This rule only applies to ICMP or ICMPv6 packets with the specified type
1500 This parameter is only valid for rules that cover protocols ICMP or
1502 The protocol and the ICMP type indicator (icmp-type or icmp6-type)
1505 By default, packets which contain IP options are blocked.
1510 rule, packets that pass the filter based on that rule (last matching)
1511 do so even if they contain IP options.
1512 For packets that match state, the rule that initially created the
1516 rule that is used when a packet does not match any rules does not
1518 .It Ar label <string>
1519 Adds a label (name) to the rule, which can be used to identify the rule.
1522 shows per-rule statistics for rules that have labels.
1524 The following macros can be used in labels:
1526 .Bl -tag -width $srcaddr -compact -offset indent
1530 The source IP address.
1532 The destination IP address.
1534 The source port specification.
1536 The destination port specification.
1544 .Bd -literal -offset indent
1545 ips = \&"{ 1.2.3.4, 1.2.3.5 }\&"
1546 pass in proto tcp from any to $ips \e
1547 port > 1023 label \&"$dstaddr:$dstport\&"
1551 .Bd -literal -offset indent
1552 pass in inet proto tcp from any to 1.2.3.4 \e
1553 port > 1023 label \&"1.2.3.4:>1023\&"
1554 pass in inet proto tcp from any to 1.2.3.5 \e
1555 port > 1023 label \&"1.2.3.5:>1023\&"
1558 The macro expansion for the
1560 directive occurs only at configuration file parse time, not during runtime.
1561 .It Ar queue <queue> | ( <queue> , <queue> )
1562 Packets matching this rule will be assigned to the specified queue.
1563 If two queues are given, packets which have a
1567 and TCP ACKs with no data payload will be assigned to the second one.
1573 .Bd -literal -offset indent
1574 pass in proto tcp to port 25 queue mail
1575 pass in proto tcp to port 22 queue(ssh_bulk, ssh_prio)
1578 Packets matching this rule will be tagged with the
1580 The tag acts as an internal marker that can be used to
1581 identify these packets later on.
1582 This can be used, for example, to provide trust between
1583 interfaces and to determine if packets have been
1584 processed by translation rules.
1587 meaning that the packet will be tagged even if the rule
1588 is not the last matching rule.
1589 Further matching rules can replace the tag with a
1590 new one but will not remove a previously applied tag.
1591 A packet is only ever assigned one tag at a time.
1595 keyword must also use
1599 .Ar synproxy state .
1600 Packet tagging can be done during
1605 rules in addition to filter rules.
1606 Tags take the same macros as labels (see above).
1607 .It Ar tagged <string>
1608 Used with filter rules to specify that packets must already
1609 be tagged with the given tag in order to match the rule.
1610 Inverse tag matching can also be done
1616 .It Ar probability <number>
1617 A probability attribute can be attached to a rule, with a value set between
1618 0 and 1, bounds not included.
1619 In that case, the rule will be honoured using the given probability value
1621 For example, the following rule will drop 20% of incoming ICMP packets:
1622 .Bd -literal -offset indent
1623 block in proto icmp probability 20%
1627 If a packet matches a rule with a route option set, the packet filter will
1628 route the packet according to the type of route option.
1629 When such a rule creates state, the route option is also applied to all
1630 packets matching the same connection.
1631 .Bl -tag -width xxxx
1635 option does a normal route lookup to find the next hop for the packet.
1639 option routes the packet to the specified interface with an optional address
1643 rule creates state, only packets that pass in the same direction as the
1644 filter rule specifies will be routed in this way.
1645 Packets passing in the opposite direction (replies) are not affected
1646 and are routed normally.
1650 option is similar to
1652 but routes packets that pass in the opposite direction (replies) to the
1653 specified interface.
1654 Opposite direction is only defined in the context of a state entry, and
1656 is useful only in rules that create state.
1657 It can be used on systems with multiple external connections to
1658 route all outgoing packets of a connection through the interface
1659 the incoming connection arrived through (symmetric routing enforcement).
1663 option creates a duplicate of the packet and routes it like
1665 The original packet gets routed as it normally would.
1672 rules, (as well as for the
1677 rule options) for which there is a single redirection address which has a
1678 subnet mask smaller than 32 for IPv4 or 128 for IPv6 (more than one IP
1679 address), a variety of different methods for assigning this address can be
1681 .Bl -tag -width xxxx
1685 option applies the network portion of the redirection address to the address
1686 to be modified (source with
1693 option selects an address at random within the defined block of addresses.
1697 option uses a hash of the source address to determine the redirection address,
1698 ensuring that the redirection address is always the same for a given source.
1699 An optional key can be specified after this keyword either in hex or as a
1702 randomly generates a key for source-hash every time the
1703 ruleset is reloaded.
1707 option loops through the redirection address(es).
1709 When more than one redirection address is specified,
1711 is the only permitted pool type.
1719 from modifying the source port on TCP and UDP packets.
1724 option can be specified to help ensure that multiple connections from the
1725 same source are mapped to the same redirection address.
1726 This option can be used with the
1731 Note that by default these associations are destroyed as soon as there are
1732 no longer states which refer to them; in order to make the mappings last
1733 beyond the lifetime of the states, increase the global options with
1734 .Ar set timeout source-track
1736 .Sx STATEFUL TRACKING OPTIONS
1737 for more ways to control the source tracking.
1738 .Sh STATEFUL INSPECTION
1740 is a stateful packet filter, which means it can track the state of
1742 Instead of passing all traffic to port 25, for instance, it is possible
1743 to pass only the initial packet, and then begin to keep state.
1744 Subsequent traffic will flow because the filter is aware of the connection.
1746 You can turn on stateful inspection on all pass rules by default using
1749 directive. Any pass rule may specify or override the stateful inspection
1750 default, including turning it off by specifying
1753 If a packet matches a
1754 .Ar pass ... keep state
1755 rule, the filter creates a state for this connection and automatically
1756 lets pass all subsequent packets of that connection.
1758 Before any rules are evaluated, the filter checks whether the packet
1760 If it does, the packet is passed without evaluation of any rules.
1762 States are removed after the connection is closed or has timed out.
1764 This has several advantages.
1765 Comparing a packet to a state involves checking its sequence numbers.
1766 If the sequence numbers are outside the narrow windows of expected
1767 values, the packet is dropped.
1768 This prevents spoofing attacks, such as when an attacker sends packets with
1769 a fake source address/port but does not know the connection's sequence
1772 Also, looking up states is usually faster than evaluating rules.
1773 If there are 50 rules, all of them are evaluated sequentially in O(n).
1774 Even with 50000 states, only 16 comparisons are needed to match a
1775 state, since states are stored in a binary search tree that allows
1776 searches in O(log2 n).
1779 .Bd -literal -offset indent
1781 pass out proto tcp from any to any flags S/SA keep state
1782 pass in proto tcp from any to any port 25 flags S/SA keep state
1785 This ruleset blocks everything by default.
1786 Only outgoing connections and incoming connections to port 25 are allowed.
1787 The initial packet of each connection has the SYN
1788 flag set, will be passed and creates state.
1789 All further packets of these connections are passed if they match a state.
1791 By default, packets coming in and out of any interface can match a state,
1792 but it is also possible to change that behaviour by assigning states to a
1793 single interface or a group of interfaces.
1795 The default policy is specified by the
1797 global option, but this can be adjusted on a per-rule basis by adding one
1806 For example, if a rule is defined as:
1807 .Bd -literal -offset indent
1808 pass out on ppp from any to 10.12/16 keep state (group-bound)
1811 A state created on ppp0 would match packets an all PPP interfaces,
1812 but not packets flowing through fxp0 or any other interface.
1816 is the more flexible option when the firewall is in a dynamic routing
1818 However, this has some security implications since a state created by one
1819 trusted network could allow potentially hostile packets coming in from other
1824 restricts state creation to the initial SYN
1825 packet of the TCP handshake.
1826 One can also be less restrictive, and allow state creation from
1832 to synchronize to existing connections, for instance
1833 if one flushes the state table. If you do this you must use the
1837 will blow up on TCP connections with window scaling turned on. The
1839 option tells keep state to skip sequence space checks on connections
1840 for which no window scaling information is known (meaning it didn't see
1841 the SYN from both directions).
1843 For UDP, which is stateless by nature,
1845 will create state as well.
1846 UDP packets are matched to states using only host addresses and ports.
1848 ICMP messages fall into two categories: ICMP error messages, which always
1849 refer to a TCP or UDP packet, are matched against the referred to connection.
1850 If one keeps state on a TCP connection, and an ICMP source quench message
1851 referring to this TCP connection arrives, it will be matched to the right
1852 state and get passed.
1856 creates an ICMP state, and
1858 knows how to match ICMP replies to states.
1860 .Bd -literal -offset indent
1861 pass out inet proto icmp all icmp-type echoreq keep state
1864 allows echo requests (such as those created by
1866 out, creates state, and matches incoming echo replies correctly to states.
1869 .Ar nat , binat No and Ar rdr
1870 rules implicitly create state for connections.
1871 .Sh STATE MODULATION
1872 Much of the security derived from TCP is attributable to how well the
1873 initial sequence numbers (ISNs) are chosen.
1874 Some popular stack implementations choose
1876 poor ISNs and thus are normally susceptible to ISN prediction exploits.
1879 rule to a TCP connection,
1881 will create a high quality random sequence number for each connection
1886 directive implicitly keeps state on the rule and is
1887 only applicable to TCP connections.
1890 .Bd -literal -offset indent
1892 pass out proto tcp from any to any modulate state
1893 pass in proto tcp from any to any port 25 flags S/SA modulate state
1896 There are two caveats associated with state modulation:
1899 rule can not be applied to a pre-existing but unmodulated connection.
1900 Such an application would desynchronize TCP's strict
1901 sequencing between the two endpoints.
1908 modifier and the pre-existing connection will be inferred without
1909 the protection conferred by modulation.
1911 The other caveat affects currently modulated states when the state table
1912 is lost (firewall reboot, flushing the state table, etc...).
1914 will not be able to infer a connection again after the state table flushes
1915 the connection's modulator.
1916 When the state is lost, the connection may be left dangling until the
1917 respective endpoints time out the connection.
1918 It is possible on a fast local network for the endpoints to start an ACK
1919 storm while trying to resynchronize after the loss of the modulator.
1924 rules between fast networks is suggested to prevent ACK storms.
1928 passes packets that are part of a
1930 handshake between the endpoints.
1933 option can be used to cause
1935 itself to complete the handshake with the active endpoint, perform a handshake
1936 with the passive endpoint, and then forward packets between the endpoints.
1938 No packets are sent to the passive endpoint before the active endpoint has
1939 completed the handshake, hence so-called SYN floods with spoofed source
1940 addresses will not reach the passive endpoint, as the sender can't complete the
1943 The proxy is transparent to both endpoints, they each see a single
1944 connection from/to the other endpoint.
1946 chooses random initial sequence numbers for both handshakes.
1947 Once the handshakes are completed, the sequence number modulators
1948 (see previous section) are used to translate further packets of the
1965 .Bd -literal -offset indent
1966 pass in proto tcp from any to any port www flags S/SA synproxy state
1968 .Sh STATEFUL TRACKING OPTIONS
1974 support the following options:
1976 .Bl -tag -width xxxx -compact
1978 Limits the number of concurrent states the rule may create.
1979 When this limit is reached, further packets matching the rule that would
1980 create state are dropped, until existing states time out.
1982 Prevent state changes for states created by this rule from appearing on the
1985 .It Ar <timeout> <seconds>
1986 Changes the timeout values used for states created by this rule.
1990 keyword is specified, the number of states per source IP is tracked.
1991 The following limits can be set:
1993 .Bl -tag -width xxxx -compact
1994 .It Ar max-src-nodes
1995 Limits the maximum number of source addresses which can simultaneously
1996 have state table entries.
1997 .It Ar max-src-states
1998 Limits the maximum number of simultaneous state entries that a single
1999 source address can create with this rule.
2001 Specify that mid-stream pickups are to be allowed. The default
2002 is to NOT allow mid-stream pickups and implies flags S/SA for TCP
2003 connections. If pickups are enabled, flags S/SA are not implied
2004 for TCP connections and state can be created for any packet.
2006 The implied flags parameters need not be specified in either case
2007 unless you explicitly wish to override them, which also allows
2008 you to roll-up several protocols into a single rule.
2010 Certain validations are disabled when mid-stream pickups occur.
2011 For example, the window scaling options are not known for
2012 TCP pickups and sequence space comparisons must be disabled.
2014 This does not effect state representing fully quantified
2015 connections (for which the SYN/SYN-ACK passed through the routing
2016 engine). Those connections continue to be fully validated.
2018 Specify that mid-stream pickups are to be allowed, but unconditionally
2019 disables sequence space checks even if full state is available.
2021 Specify that mid-stream pickups are not to be allowed. This is the
2022 default and this keyword does not normally need to be specified.
2023 However, if you are concerned about rule set portability then
2024 specifying this keyword will at least result in an error from pfctl
2025 if it doesn't understand the feature. TCP flags of S/SA are implied
2026 and do not need to explicitly specified.
2029 For a list of all valid timeout names, see
2033 Multiple options can be specified, separated by commas:
2035 pass in proto tcp from any to any \e
2036 port www flags S/SA keep state \e
2037 (max 100, source-track rule, max-src-nodes 75, \e
2038 max-src-states 3, tcp.established 60, tcp.closing 5)
2041 .Sh OPERATING SYSTEM FINGERPRINTING
2042 Passive OS Fingerprinting is a mechanism to inspect nuances of a TCP
2043 connection's initial SYN packet and guess at the host's operating system.
2044 Unfortunately these nuances are easily spoofed by an attacker so the
2045 fingerprint is not useful in making security decisions.
2046 But the fingerprint is typically accurate enough to make policy decisions
2049 The fingerprints may be specified by operating system class, by
2050 version, or by subtype/patchlevel.
2051 The class of an operating system is typically the vendor or genre
2057 The version of the oldest available
2059 release on the main ftp site
2060 would be 2.6 and the fingerprint would be written
2062 .Dl \&"OpenBSD 2.6\&"
2064 The subtype of an operating system is typically used to describe the
2065 patchlevel if that patch led to changes in the TCP stack behavior.
2068 the only subtype is for a fingerprint that was
2071 scrub option and would be specified as
2073 .Dl \&"OpenBSD 3.3 no-df\&"
2075 Fingerprints for most popular operating systems are provided by
2079 is running, a complete list of known operating system fingerprints may
2080 be listed by running:
2084 Filter rules can enforce policy at any level of operating system specification
2085 assuming a fingerprint is present.
2086 Policy could limit traffic to approved operating systems or even ban traffic
2087 from hosts that aren't at the latest service pack.
2091 class can also be used as the fingerprint which will match packets for
2092 which no operating system fingerprint is known.
2095 .Bd -literal -offset indent
2096 pass out proto tcp from any os OpenBSD keep state
2097 block out proto tcp from any os Doors
2098 block out proto tcp from any os "Doors PT"
2099 block out proto tcp from any os "Doors PT SP3"
2100 block out from any os "unknown"
2101 pass on lo0 proto tcp from any os "OpenBSD 3.3 lo0" keep state
2104 Operating system fingerprinting is limited only to the TCP SYN packet.
2105 This means that it will not work on other protocols and will not match
2106 a currently established connection.
2108 Caveat: operating system fingerprints are occasionally wrong.
2109 There are three problems: an attacker can trivially craft his packets to
2110 appear as any operating system he chooses;
2111 an operating system patch could change the stack behavior and no fingerprints
2112 will match it until the database is updated;
2113 and multiple operating systems may have the same fingerprint.
2114 .Sh BLOCKING SPOOFED TRAFFIC
2115 "Spoofing" is the faking of IP addresses, typically for malicious
2119 directive expands to a set of filter rules which will block all
2120 traffic with a source IP from the network(s) directly connected
2121 to the specified interface(s) from entering the system through
2122 any other interface.
2124 For example, the line
2125 .Bd -literal -offset indent
2130 .Bd -literal -offset indent
2131 block drop in on ! lo0 inet from 127.0.0.1/8 to any
2132 block drop in on ! lo0 inet6 from ::1 to any
2135 For non-loopback interfaces, there are additional rules to block incoming
2136 packets with a source IP address identical to the interface's IP(s).
2137 For example, assuming the interface wi0 had an IP address of 10.0.0.1 and a
2138 netmask of 255.255.255.0,
2140 .Bd -literal -offset indent
2141 antispoof for wi0 inet
2145 .Bd -literal -offset indent
2146 block drop in on ! wi0 inet from 10.0.0.0/24 to any
2147 block drop in inet from 10.0.0.1 to any
2150 Caveat: Rules created by the
2152 directive interfere with packets sent over loopback interfaces
2154 One should pass these explicitly.
2155 .Sh FRAGMENT HANDLING
2156 The size of IP datagrams (packets) can be significantly larger than the
2157 maximum transmission unit (MTU) of the network.
2158 In cases when it is necessary or more efficient to send such large packets,
2159 the large packet will be fragmented into many smaller packets that will each
2161 Unfortunately for a firewalling device, only the first logical fragment will
2162 contain the necessary header information for the subprotocol that allows
2164 to filter on things such as TCP ports or to perform NAT.
2168 rules as described in
2169 .Sx TRAFFIC NORMALIZATION
2170 above, there are three options for handling fragments in the packet filter.
2172 One alternative is to filter individual fragments with filter rules.
2175 rule applies to a fragment, it is passed to the filter.
2176 Filter rules with matching IP header parameters decide whether the
2177 fragment is passed or blocked, in the same way as complete packets
2179 Without reassembly, fragments can only be filtered based on IP header
2180 fields (source/destination address, protocol), since subprotocol header
2181 fields are not available (TCP/UDP port numbers, ICMP code/type).
2184 option can be used to restrict filter rules to apply only to
2185 fragments, but not complete packets.
2186 Filter rules without the
2188 option still apply to fragments, if they only specify IP header fields.
2189 For instance, the rule
2190 .Bd -literal -offset indent
2191 pass in proto tcp from any to any port 80
2194 never applies to a fragment, even if the fragment is part of a TCP
2195 packet with destination port 80, because without reassembly this information
2196 is not available for each fragment.
2197 This also means that fragments cannot create new or match existing
2198 state table entries, which makes stateful filtering and address
2199 translation (NAT, redirection) for fragments impossible.
2201 It's also possible to reassemble only certain fragments by specifying
2202 source or destination addresses or protocols as parameters in
2206 In most cases, the benefits of reassembly outweigh the additional
2207 memory cost, and it's recommended to use
2210 all fragments via the
2211 .Ar fragment reassemble
2214 The memory allocated for fragment caching can be limited using
2216 Once this limit is reached, fragments that would have to be cached
2217 are dropped until other entries time out.
2218 The timeout value can also be adjusted.
2220 Currently, only IPv4 fragments are supported and IPv6 fragments
2221 are blocked unconditionally.
2222 .Sh ANCHORS AND NAMED RULESETS
2223 Besides the main ruleset,
2225 can load named rulesets into
2230 contains a list of named rulesets.
2233 has a name which specifies where
2235 can be used to attach sub-rulesets.
2236 A named ruleset contains filter and translation rules, like the
2238 The main ruleset can reference
2241 using the following kinds
2243 .Bl -tag -width xxxx
2244 .It Ar nat-anchor <name>
2247 rules of all named rulesets in the specified
2249 .It Ar rdr-anchor <name>
2252 rules of all named rulesets in the specified
2254 .It Ar binat-anchor <name>
2257 rules of all named rulesets in the specified
2259 .It Ar anchor <name>
2260 Evaluates the filter rules of all named rulesets in the specified
2262 .It Ar load anchor <name>:<ruleset> from <file>
2263 Loads the rules from the specified file into the named
2266 attached to the anchor
2270 When evaluation of the main ruleset reaches an
2274 will proceed to evaluate all rules specified in the
2275 named rulesets attached to that
2278 Matching filter rules in named rulesets with the
2280 option and matching translation rules are final and abort the
2281 evaluation of both the rules in the
2283 and the main ruleset.
2285 Only the main ruleset can contain
2291 contains more than one named ruleset, they are evaluated
2292 in the alphabetical order of their names.
2296 attachment points which do not contain any rules when the main ruleset
2297 is loaded, and later such named rulesets can be manipulated through
2299 without reloading the main ruleset.
2301 .Bd -literal -offset indent
2303 block on $ext_if all
2305 pass out on $ext_if all keep state
2306 pass in on $ext_if proto tcp from any \e
2307 to $ext_if port smtp keep state
2310 blocks all packets on the external interface by default, then evaluates
2313 named "spam", and finally passes all outgoing connections and
2314 incoming connections to port 25.
2315 .Bd -literal -offset indent
2316 # echo \&"block in quick from 1.2.3.4 to any\&" \&| \e
2317 pfctl -a spam:manual -f -
2320 loads a single ruleset containing a single rule into the
2322 which blocks all packets from a specific address.
2324 The named ruleset can also be populated by adding a
2329 .Bd -literal -offset indent
2331 load anchor spam:manual from "/etc/pf-spam.conf"
2338 it will also load all the rules from the file
2339 .Pa /etc/pf-spam.conf
2340 into the named ruleset.
2344 rules can specify the parameter's
2345 direction, interface, address family, protocol and source/destination
2347 using the same syntax as filter rules.
2348 When parameters are used, the
2350 rule is only evaluated for matching packets.
2351 This allows conditional evaluation of named rulesets, like:
2352 .Bd -literal -offset indent
2353 block on $ext_if all
2354 anchor spam proto tcp from any to any port smtp
2355 pass out on $ext_if all keep state
2356 pass in on $ext_if proto tcp from any to $ext_if port smtp keep state
2361 spam are only evaluated for
2363 packets with destination port 25.
2365 .Bd -literal -offset indent
2366 # echo \&"block in quick from 1.2.3.4 to any" \&| \e
2367 pfctl -a spam:manual -f -
2370 will only block connections from 1.2.3.4 to port 25.
2372 .Bl -tag -width "/etc/protocols" -compact
2376 Default location of the ruleset file.
2378 Default location of OS fingerprints.
2379 .It Pa /etc/protocols
2380 Protocol name database.
2381 .It Pa /etc/services
2382 Service name database.
2383 .It Pa /usr/share/examples/pf
2386 .Sh TRANSLATION EXAMPLES
2387 This example maps incoming requests on port 80 to port 8080, on
2388 which a daemon is running (because, for example, it is not run as root,
2389 and therefore lacks permission to bind to port 80).
2391 # use a macro for the interface name, so it can be changed easily
2394 # map daemon on 8080 to appear to be on 80
2395 rdr on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 port 8080
2400 modifier is given, packets matching the translation rule are passed without
2401 inspecting the filter rules:
2403 rdr pass on $ext_if proto tcp from any to any port 80 -> 127.0.0.1 \e
2407 In the example below, vlan12 is configured as 192.168.168.1;
2408 the machine translates all packets coming from 192.168.168.0/24 to 204.92.77.111
2409 when they are going out any interface except vlan12.
2410 This has the net effect of making traffic from the 192.168.168.0/24
2411 network appear as though it is the Internet routable address
2412 204.92.77.111 to nodes behind any interface on the router except
2413 for the nodes on vlan12.
2414 (Thus, 192.168.168.1 can talk to the 192.168.168.0/24 nodes.)
2416 nat on ! vlan12 from 192.168.168.0/24 to any -> 204.92.77.111
2419 In the example below, the machine sits between a fake internal 144.19.74.*
2420 network, and a routable external IP of 204.92.77.100.
2423 rule excludes protocol AH from being translated.
2426 no nat on $ext_if proto ah from 144.19.74.0/24 to any
2427 nat on $ext_if from 144.19.74.0/24 to any -> 204.92.77.100
2430 In the example below, packets bound for one specific server, as well as those
2431 generated by the sysadmins are not proxied; all other connections are.
2434 no rdr on $int_if proto { tcp, udp } from any to $server port 80
2435 no rdr on $int_if proto { tcp, udp } from $sysadmins to any port 80
2436 rdr on $int_if proto { tcp, udp } from any to any port 80 -> 127.0.0.1 \e
2440 This longer example uses both a NAT and a redirection.
2441 The external interface has the address 157.161.48.183.
2442 On the internal interface, we are running
2444 listening for outbound ftp sessions captured to port 8021.
2447 # Translate outgoing packets' source addresses (any protocol).
2448 # In this case, any address but the gateway's external address is mapped.
2449 nat on $ext_if inet from ! ($ext_if) to any -> ($ext_if)
2452 # Map outgoing packets' source port to an assigned proxy port instead of
2453 # an arbitrary port.
2454 # In this case, proxy outgoing isakmp with port 500 on the gateway.
2455 nat on $ext_if inet proto udp from any port = isakmp to any -> ($ext_if) \e
2459 # Translate outgoing packets' source address (any protocol).
2460 # Translate incoming packets' destination address to an internal machine
2462 binat on $ext_if from 10.1.2.150 to any -> ($ext_if)
2465 # Translate incoming packets' destination addresses.
2466 # As an example, redirect a TCP and UDP port to an internal machine.
2467 rdr on $ext_if inet proto tcp from any to ($ext_if) port 8080 \e
2468 -> 10.1.2.151 port 22
2469 rdr on $ext_if inet proto udp from any to ($ext_if) port 8080 \e
2470 -> 10.1.2.151 port 53
2473 # Translate outgoing ftp control connections to send them to localhost
2474 # for proxying with ftp-proxy(8) running on port 8021.
2475 rdr on $int_if proto tcp from any to any port 21 -> 127.0.0.1 port 8021
2478 In this example, a NAT gateway is set up to translate internal addresses
2479 using a pool of public addresses (192.0.2.16/28) and to redirect
2480 incoming web server connections to a group of web servers on the internal
2484 # Translate outgoing packets' source addresses using an address pool.
2485 # A given source address is always translated to the same pool address by
2486 # using the source-hash keyword.
2487 nat on $ext_if inet from any to any -> 192.0.2.16/28 source-hash
2490 # Translate incoming web server connections to a group of web servers on
2491 # the internal network.
2492 rdr on $ext_if proto tcp from any to any port 80 \e
2493 -> { 10.1.2.155, 10.1.2.160, 10.1.2.161 } round-robin
2497 # The external interface is kue0
2498 # (157.161.48.183, the only routable address)
2499 # and the private network is 10.0.0.0/8, for which we are doing NAT.
2501 # use a macro for the interface name, so it can be changed easily
2504 # normalize all incoming traffic
2505 scrub in on $ext_if all fragment reassemble
2507 # block and log everything by default
2508 block return log on $ext_if all
2510 # block anything coming from source we have no back routes for
2511 block in from no-route to any
2513 # block and log outgoing packets that do not have our address as source,
2514 # they are either spoofed or something is misconfigured (NAT disabled,
2515 # for instance), we want to be nice and do not send out garbage.
2516 block out log quick on $ext_if from ! 157.161.48.183 to any
2518 # silently drop broadcasts (cable modem noise)
2519 block in quick on $ext_if from any to 255.255.255.255
2521 # block and log incoming packets from reserved address space and invalid
2522 # addresses, they are either spoofed or misconfigured, we cannot reply to
2523 # them anyway (hence, no return-rst).
2524 block in log quick on $ext_if from { 10.0.0.0/8, 172.16.0.0/12, \e
2525 192.168.0.0/16, 255.255.255.255/32 } to any
2529 # pass out/in certain ICMP queries and keep state (ping)
2530 # state matching is done on host addresses and ICMP id (not type/code),
2531 # so replies (like 0/0 for 8/0) will match queries
2532 # ICMP error messages (which always refer to a TCP/UDP packet) are
2533 # handled by the TCP/UDP states
2534 pass on $ext_if inet proto icmp all icmp-type 8 code 0 keep state
2538 # pass out all UDP connections and keep state
2539 pass out on $ext_if proto udp all keep state
2541 # pass in certain UDP connections and keep state (DNS)
2542 pass in on $ext_if proto udp from any to any port domain keep state
2546 # pass out all TCP connections and modulate state
2547 pass out on $ext_if proto tcp all modulate state
2549 # pass in certain TCP connections and keep state (SSH, SMTP, DNS, IDENT)
2550 pass in on $ext_if proto tcp from any to any port { ssh, smtp, domain, \e
2551 auth } flags S/SA keep state
2553 # pass in data mode connections for ftp-proxy running on this host.
2554 # (see ftp-proxy(8) for details)
2555 pass in on $ext_if proto tcp from any to 157.161.48.183 port >= 49152 \e
2556 flags S/SA keep state
2558 # Do not allow Windows 9x SMTP connections since they are typically
2559 # a viral worm. Alternately we could limit these OSes to 1 connection each.
2560 block in on $ext_if proto tcp from any os {"Windows 95", "Windows 98"} \e
2563 # Using the pickup options to keep/modulate/synproxy state
2565 # no-pickups (default) Do not allow connections to be picked up in the
2566 # middle. Implies flags S/SA (the 'no-pickups' option need
2567 # not be specified, it is the default).
2569 # pickups Allow connections to be picked up in the middle, even if
2570 # no window scaling information is known. Such connections
2571 # will disable sequence space checks. Implies no flag
2574 # hash-only Do not fail packets on sequence space checks. Implies no
2575 # flag restrictions.
2577 pass in on $ext_if proto tcp ... keep state (no-pickups)
2578 pass in on $ext_if proto tcp ... keep state (pickups)
2579 pass in on $ext_if proto tcp ... keep state (hash-only)
2583 # three interfaces: $int_if, $ext_if, and $wifi_if (wireless). NAT is
2584 # being done on $ext_if for all outgoing packets. tag packets in on
2585 # $int_if and pass those tagged packets out on $ext_if. all other
2586 # outgoing packets (i.e., packets from the wireless network) are only
2587 # permitted to access port 80.
2589 pass in on $int_if from any to any tag INTNET keep state
2590 pass in on $wifi_if from any to any keep state
2592 block out on $ext_if from any to any
2593 pass out quick on $ext_if tagged INTNET keep state
2594 pass out on $ext_if from any to any port 80 keep state
2596 # tag incoming packets as they are redirected to spamd(8). use the tag
2597 # to pass those packets through the packet filter.
2599 rdr on $ext_if inet proto tcp from <spammers> to port smtp \e
2600 tag SPAMD -> 127.0.0.1 port spamd
2603 pass in on $ext_if inet proto tcp tagged SPAMD keep state
2610 line = ( option | pf-rule | nat-rule | binat-rule | rdr-rule |
2611 antispoof-rule | altq-rule | queue-rule | anchor-rule |
2612 trans-anchors | load-anchors | table-rule )
2614 option = "set" ( [ "timeout" ( timeout | "{" timeout-list "}" ) ] |
2615 [ "optimization" [ "default" | "normal" |
2616 "high-latency" | "satellite" |
2617 "aggressive" | "conservative" ] ]
2618 [ "limit" ( limit-item | "{" limit-list "}" ) ] |
2619 [ "loginterface" ( interface-name | "none" ) ] |
2620 [ "block-policy" ( "drop" | "return" ) ] |
2621 [ "state-policy" ( "if-bound" | "group-bound" |
2623 [ "require-order" ( "yes" | "no" ) ]
2624 [ "fingerprints" filename ] |
2625 [ "debug" ( "none" | "urgent" | "misc" | "loud" ) ] )
2627 pf-rule = action [ ( "in" | "out" ) ]
2628 [ "log" | "log-all" ] [ "quick" ]
2629 [ "on" ifspec ] [ route ] [ af ] [ protospec ]
2630 hosts [ filteropt-list ]
2632 filteropt-list = filteropt-list filteropt | filteropt
2633 filteropt = user | group | flags | icmp-type | icmp6-type | tos |
2634 ( "keep" | "modulate" | "synproxy" ) "state"
2635 [ "(" state-opts ")" ] |
2636 "fragment" | "no-df" | "min-ttl" number |
2637 "max-mss" number | "random-id" | "reassemble tcp" |
2638 fragmentation | "allow-opts" |
2639 "label" string | "tag" string | [ ! ] "tagged" string
2640 "queue" ( string | "(" string [ [ "," ] string ] ")" ) |
2641 "probability" number"%"
2643 nat-rule = [ "no" ] "nat" [ "pass" ] [ "on" ifspec ] [ af ]
2644 [ protospec ] hosts [ "tag" string ]
2645 [ "->" ( redirhost | "{" redirhost-list "}" )
2646 [ portspec ] [ pooltype ] [ "static-port" ] ]
2648 binat-rule = [ "no" ] "binat" [ "pass" ] [ "on" interface-name ]
2649 [ af ] [ "proto" ( proto-name | proto-number ) ]
2650 "from" address [ "/" mask-bits ] "to" ipspec
2652 [ "->" address [ "/" mask-bits ] ]
2654 rdr-rule = [ "no" ] "rdr" [ "pass" ] [ "on" ifspec ] [ af ]
2655 [ protospec ] hosts [ "tag" string ]
2656 [ "->" ( redirhost | "{" redirhost-list "}" )
2657 [ portspec ] [ pooltype ] ]
2659 antispoof-rule = "antispoof" [ "log" ] [ "quick" ]
2660 "for" ( interface-name | "{" interface-list "}" )
2661 [ af ] [ "label" string ]
2663 table-rule = "table" "<" string ">" [ tableopts-list ]
2664 tableopts-list = tableopts-list tableopts | tableopts
2665 tableopts = "persist" | "const" | "file" string |
2666 "{" [ tableaddr-list ] "}"
2667 tableaddr-list = tableaddr-list [ "," ] tableaddr-spec | tableaddr-spec
2668 tableaddr-spec = [ "!" ] tableaddr [ "/" mask-bits ]
2669 tableaddr = hostname | ipv4-dotted-quad | ipv6-coloned-hex |
2670 interface-name | "self"
2672 altq-rule = "altq on" interface-name queueopts-list
2674 queue-rule = "queue" string [ "on" interface-name ] queueopts-list
2677 anchor-rule = "anchor" string [ ( "in" | "out" ) ] [ "on" ifspec ]
2678 [ af ] [ "proto" ] [ protospec ] [ hosts ]
2680 trans-anchors = ( "nat-anchor" | "rdr-anchor" | "binat-anchor" ) string
2681 [ "on" ifspec ] [ af ] [ "proto" ] [ protospec ] [ hosts ]
2683 load-anchor = "load anchor" anchorname:rulesetname "from" filename
2685 queueopts-list = queueopts-list queueopts | queueopts
2686 queueopts = [ "bandwidth" bandwidth-spec ] |
2687 [ "qlimit" number ] | [ "tbrsize" number ] |
2688 [ "priority" number ] | [ schedulers ]
2689 schedulers = ( cbq-def | priq-def | hfsc-def )
2690 bandwidth-spec = "number" ( "b" | "Kb" | "Mb" | "Gb" | "%" )
2692 action = "pass" | "block" [ return ] | "scrub"
2693 return = "drop" | "return" | "return-rst" [ "( ttl" number ")" ] |
2694 "return-icmp" [ "(" icmpcode ["," icmp6code ] ")" ] |
2695 "return-icmp6" [ "(" icmp6code ")" ]
2696 icmpcode = ( icmp-code-name | icmp-code-number )
2697 icmp6code = ( icmp6-code-name | icmp6-code-number )
2699 ifspec = ( [ "!" ] interface-name ) | "{" interface-list "}"
2700 interface-list = [ "!" ] interface-name [ [ "," ] interface-list ]
2701 route = "fastroute" |
2702 ( "route-to" | "reply-to" | "dup-to" )
2703 ( routehost | "{" routehost-list "}" )
2705 af = "inet" | "inet6"
2707 protospec = "proto" ( proto-name | proto-number |
2708 "{" proto-list "}" )
2709 proto-list = ( proto-name | proto-number ) [ [ "," ] proto-list ]
2712 "from" ( "any" | "no-route" | "self" | host |
2713 "{" host-list "}" ) [ port ] [ os ]
2714 "to" ( "any" | "no-route" | "self" | host |
2715 "{" host-list "}" ) [ port ]
2717 ipspec = "any" | host | "{" host-list "}"
2718 host = [ "!" ] ( address [ "/" mask-bits ] | "<" string ">" )
2719 redirhost = address [ "/" mask-bits ]
2720 routehost = ( interface-name [ address [ "/" mask-bits ] ] )
2721 address = ( interface-name | "(" interface-name ")" | hostname |
2722 ipv4-dotted-quad | ipv6-coloned-hex )
2723 host-list = host [ [ "," ] host-list ]
2724 redirhost-list = redirhost [ [ "," ] redirhost-list ]
2725 routehost-list = routehost [ [ "," ] routehost-list ]
2727 port = "port" ( unary-op | binary-op | "{" op-list "}" )
2728 portspec = "port" ( number | name ) [ ":" ( "*" | number | name ) ]
2729 os = "os" ( os-name | "{" os-list "}" )
2730 user = "user" ( unary-op | binary-op | "{" op-list "}" )
2731 group = "group" ( unary-op | binary-op | "{" op-list "}" )
2733 unary-op = [ "=" | "!=" | "<" | "<=" | ">" | ">=" ]
2735 binary-op = number ( "<>" | "><" | ":" ) number
2736 op-list = ( unary-op | binary-op ) [ [ "," ] op-list ]
2738 os-name = operating-system-name
2739 os-list = os-name [ [ "," ] os-list ]
2741 flags = "flags" [ flag-set ] "/" flag-set
2742 flag-set = [ "F" ] [ "S" ] [ "R" ] [ "P" ] [ "A" ] [ "U" ] [ "E" ]
2745 icmp-type = "icmp-type" ( icmp-type-code | "{" icmp-list "}" )
2746 icmp6-type = "icmp6-type" ( icmp-type-code | "{" icmp-list "}" )
2747 icmp-type-code = ( icmp-type-name | icmp-type-number )
2748 [ "code" ( icmp-code-name | icmp-code-number ) ]
2749 icmp-list = icmp-type-code [ [ "," ] icmp-list ]
2751 tos = "tos" ( "lowdelay" | "throughput" | "reliability" |
2754 state-opts = state-opt [ [ "," ] state-opts ]
2755 state-opt = ( "max" number | "no-sync" | timeout |
2756 "source-track" [ ( "rule" | "global" ) ] |
2757 "max-src-nodes" number | "max-src-states" number |
2758 "if-bound" | "group-bound" | "floating" |
2759 "pickups" | "no-pickups" | "hash-only" )
2761 fragmentation = [ "fragment reassemble" | "fragment crop" |
2762 "fragment drop-ovl" ]
2764 timeout-list = timeout [ [ "," ] timeout-list ]
2765 timeout = ( "tcp.first" | "tcp.opening" | "tcp.established" |
2766 "tcp.closing" | "tcp.finwait" | "tcp.closed" |
2767 "udp.first" | "udp.single" | "udp.multiple" |
2768 "icmp.first" | "icmp.error" |
2769 "other.first" | "other.single" | "other.multiple" |
2770 "frag" | "interval" | "src.track" |
2771 "adaptive.start" | "adaptive.end" ) number
2773 limit-list = limit-item [ [ "," ] limit-list ]
2774 limit-item = ( "states" | "frags" | "src-nodes" ) number
2776 pooltype = ( "bitmask" | "random" |
2777 "source-hash" [ ( hex-key | string-key ) ] |
2778 "round-robin" ) [ sticky-address ]
2780 subqueue = string | "{" queue-list "}"
2781 queue-list = string [ [ "," ] string ]
2782 cbq-def = "cbq" [ "(" cbq-opt [ [ "," ] cbq-opt ] ")" ]
2783 priq-def = "priq" [ "(" priq-opt [ [ "," ] priq-opt ] ")" ]
2784 hfsc-def = "hfsc" [ "(" hfsc-opt [ [ "," ] hfsc-opt ] ")" ]
2785 cbq-opt = ( "default" | "borrow" | "red" | "ecn" | "rio" )
2786 priq-opt = ( "default" | "red" | "ecn" | "rio" )
2787 hfsc-opt = ( "default" | "red" | "ecn" | "rio" |
2788 linkshare-sc | realtime-sc | upperlimit-sc )
2789 linkshare-sc = "linkshare" sc-spec
2790 realtime-sc = "realtime" sc-spec
2791 upperlimit-sc = "upperlimit" sc-spec
2792 sc-spec = ( bandwidth-spec |
2793 "(" bandwidth-spec number bandwidth-spec ")" )
2814 file format first appeared in