PFCTL(8)                OpenBSD System Manager's Manual               PFCTL(8)

NAME
     pfctl - control the packet filter and NAT subsystems

SYNOPSIS
     pfctl [-dehnqv] [-F modifier] [-l interface] [-N file] [-O level] [-R
           file] [-s modifier] [-t modifier] [-x level]

DESCRIPTION
     The pfctl utility communicates with the packet filter system using the
     ioctl interface described in pf(4).

     Packet filtering lets you restrict packets entering or leaving your host;
     packets can be specified in a variety of ways including by protocol, by
     port number, and by address.  Network Address Translation lets you map a
     series of internal host IP numbers to a single external address.  The NAT
     code also has provisions for redirecting a range of connections to a dif-
     ferent host and/or port number.  Taken together this provides a powerful
     basic firewall mechanism.

     The pfctl command is normally invoked automatically at system initializa-
     tion time to start and load the packet filter, but can also be used when
     the filter or translation rules change.

     pfctl requires the pf(4) pseudo-device driver.  Forwarding packets, by
     using NAT, also requires specifying net.inet.ip.forwarding=1 in the file
     /etc/sysctl.conf.

     The pfctl utility provides several commands.  The options are as follows:

     -d      Disable the packet filter.

     -e      Enable the packet filter.

     -F modifier
             Flush one of the following.  Modifier name may be abbreviated:
             -F nat    Flush the NAT rules.
             -F rules  Flush the filter rules.
             -F state  Flush the state table (NAT and filter).
             -F info   Flush the filter information (statistics and counters).
             -F all    Flush all of the above.

     -h      Help.

     -l interface
             Enable collection of packet and byte count statistics for inter-
             face named interface. These statistics can be viewed with the -s
             info option.

     -n      Do not actually load rules.

     -N file
             Load a NAT rules file.

     -O modifier
             Optimize the engine to one of the following network topographies
             or environments:
             -O default       A normal network environment.  Suitable for al-
                              most all networks.
             -O normal        Alias for default
             -O high-latency  A high-latency environment (such as a satellite
                              connection)


             -O satellite     Alias for high-latency
             -O aggressive    Aggressively expire connections when they are
                              likely no longer valid.  This can greatly reduce
                              the memory usage of the firewall at the cost of
                              dropping idle connections early.
             -O conservative  Extremely conservative settings.  Pains will be
                              taken to avoid dropping legitimate connections
                              at the expense of greater memory utilization
                              (possibly much greater on a busy network) and
                              slightly increased processor utilization.
             Currently the optimizations only encompass the state table time-
             outs but much more is planned in future revisions of the finite
             state machines (FSMs).

     -q      Only print errors and warnings.

     -R file
             Load a filter rules file into the filter.

     -s modifier
             Show filter parameters. Modifier names may be abbreviated:
             -s nat    Show the currently loaded NAT rules.
             -s rules  Show the currently loaded packet filter rules.  When
                       used together with -v, the per-rule statistics (number
                       of evaluations, packets and bytes) are also shown. Note
                       that the 'skip step' optimization done automatically by
                       the kernel will skip evaluation of rules where redun-
                       dant. Packets passed statefully are counted in the rule
                       that created the state (even though the rule isn't
                       evaluated more than once for the entire connection).
             -s state  Show the contents of the state table.
             -s info   Show filter information (statistics and counters).
             -s all    Show all of the above.

     -t modifier
             Get a timeout or interval value.  Any of the modifiers may be
             set, with the exception of all, by appending =<seconds> to the
             modifier without any whitespace seperating the modifier, the
             equals and the number of seconds.
             -t all       Display all timeouts and intervals.
             -t interval  Interval between purging expired states and frag-
                          ments.
             -t frag      Seconds before an unassembled fragment is expired.

             When a packet matches a stateful connection, the seconds to live
             of the connection will be updated to that of the proto.modifier
             which corresponds to the connection state.  Each packet which
             matches this state will increase the TTL.  It is permissible to
             set the TTL for a particular state to zero if you do not want
             packets matching a particular state to prolong the life of the
             state.  Tuning these values may improve the performance of the
             firewall at the risk of dropping valid idled connections.

             -t tcp.first        The state after the first packet.
             -t tcp.opening      The state before the destination host ever
                                 sends a packet.
             -t tcp.established  The fully established state.
             -t tcp.closing      The state after the first FIN has been sent.
             -t tcp.finwait      The state after both FINs have been exchanged
                                 and the connection is closed.  If you see
                                 lots of blocked packets coming back from web
                                 servers (notably Solaris), increase this val-
                                 ue and possibly tcp.closing.
             -t tcp.closed       The state after one endpoint sends a RST.

             ICMP and UDP are handled in a similar fashion to TCP but with a

             much more limited set of states.
             -t udp.first     The state after the first packet.
             -t udp.single    The state if the source host sends more than one
                              packet but the destination host has never sent
                              one back.
             -t udp.multiple  The state if both hosts have sent packets.
             -t icmp.first    The state after the first packet.
             -t icmp.error    The state after an icmp error came back in re-
                              sponse to an icmp packet.

             Example:
                 # Timeout established connections after an hour of inactivity
                 pfctl -t tcp.established=3600

                 # Display the current established idle timeout
                 pfctl -t tcp.established


     -v      Produce more verbose output.

     -x level
             Set the debug level to one of the following.  Level names may be
             abbreviated:
             -x none    Don't generate debug messages.
             -x urgent  Generate debug messages only for serious errors.
             -x misc    Generate debug messages for various errors.

FILES
     /etc/pf.conf   Packet filter rules file.
     /etc/nat.conf  Rules for Network Address Translation.

SEE ALSO
     pf(4), nat.conf(5), pf.conf(5), ftp-proxy(8), rc(8)

AUTHORS
     Daniel Hartmeier wrote the program and the underlying mechanism.

HISTORY
     The pfctl program and the pf(4) filter mechanism first appeared in OpenB-
     SD 3.0.

BUGS
     Probably.

OpenBSD 3.0                      June 24, 2001                               3
