The Book of PF, 2nd Edition

Book description

This second edition of The Book of PF is an up-to-date, no-nonsense guide to harnessing the power of PF. Author Peter Hansteen covers NAT (network address translation) and redirection, wireless networking, spam fighting, failover provisioning, logging, and more. New additions include coverage of CARP load balancing, and expanded coverage of traffic shaping (including ALTQ queue disciplines such as HFSC), and logging and monitoring. Written for anyone who has felt lost in PF's manual pages or baffled by its massive feature set, The Book of PF, 2nd Edition will help you build the high-performance, secure, low maintenance network you need.

Table of contents

  1. The Book of PF
    1. PRAISE FOR THE FIRST EDITION OF THE BOOK OF PF
    2. Foreword
    3. Acknowledgments
    4. Introduction
      1. This Is Not a HOWTO
      2. What This Book Covers
    5. 1. Building the Network You Need
      1. Your Network: High Performance, Low Maintenance, and Secure
      2. Where the Packet Filter Fits In
      3. The Rise of PF
      4. If You Came from Elsewhere
        1. Pointers for Linux Users
        2. Frequently Answered Questions About PF
          1. Can I run PF on my Linux machine?
          2. Can you recommend a GUI tool for managing my PF rule set?
          3. Is there a tool I can use to convert my OtherProduct ® setup to a PF configuration?
          4. Why did the PF rules syntax change all of a sudden?
          5. Where can I find out more?
      5. A Little Encouragement: A PF Haiku
    6. 2. PF Configuration Basics
      1. The First Step: Enabling PF
        1. Setting Up PF on OpenBSD
        2. Setting Up PF on FreeBSD
        3. Setting Up PF on NetBSD
      2. A Simple PF Rule Set: A Single, Stand-Alone Machine
        1. A Minimal Rule Set
        2. Testing the Rule Set
      3. Slightly Stricter: Using Lists and Macros for Readability
        1. A Stricter Baseline Rule Set
        2. Reloading the Rule Set and Looking for Errors
        3. Checking Your Rules
        4. Testing the Changed Rule Set
      4. Displaying Information About Your System
      5. Looking Ahead
    7. 3. Into the Real World
      1. A Simple Gateway
        1. Keep It Simple: Avoid the Pitfalls of in, out, and on
        2. Network Address Translation vs. IPv6
        3. Final Preparations: Defining Your Local Network
        4. Setting Up a Gateway
        5. Testing Your Rule Set
      2. That Sad Old FTP Thing
        1. If We Must: ftp-proxy with Redirection
      3. Making Your Network Troubleshooting Friendly
        1. Do We Let It All Through?
        2. The Easy Way Out: The Buck Stops Here
        3. Letting ping Through
        4. Helping traceroute
        5. Path MTU Discovery
      4. Tables Make Your Life Easier
    8. 4. Wireless Networks Made Easy
      1. A Little IEEE 802.11 Background
        1. MAC Address Filtering
        2. WEP
        3. WPA
        4. The Right Hardware for the Task
      2. Setting Up a Simple Wireless Network
        1. An OpenBSD WPA Access Point
        2. A FreeBSD WPA Access Point
        3. The Access Point's PF Rule Set
        4. Access Points with Three or More Interfaces
        5. Handling IPSec, VPN Solutions
        6. The Client Side
          1. OpenBSD Setup
          2. FreeBSD Setup
      3. Guarding Your Wireless Network with authpf
        1. A Basic Authenticating Gateway
        2. Wide Open but Actually Shut
    9. 5. Bigger or Trickier Networks
      1. A Web Server and Mail Server on the Inside—Routable Addresses
        1. A Degree of Separation: Introducing the DMZ
        2. Sharing the Load: Redirecting to a Pool of Addresses
        3. Getting Load Balancing Right with relayd
      2. A Web Server and Mail Server on the Inside—the NAT Version
        1. DMZ with NAT
        2. Redirection for Load Balancing
        3. Back to the Single NATed Network
      3. Filtering on Interface Groups
      4. The Power of Tags
      5. The Bridging Firewall
        1. Basic Bridge Setup on OpenBSD
        2. Basic Bridge Setup on FreeBSD
        3. Basic Bridge Setup on NetBSD
        4. The Bridge Rule Set
      6. Handling Nonroutable Addresses from Elsewhere
    10. 6. Turning the Tables for Proactive Defense
      1. Turning Away the Brutes
        1. SSH Brute-Force Attacks
        2. Setting Up an Adaptive Firewall
        3. Tidying Your Tables with pfctl
      2. Giving Spammers a Hard Time with spamd
        1. Network-Level Behavior Analysis and Blacklisting
          1. Setting Up spamd in Blacklisting Mode
          2. spamd Logging
        2. Greylisting: My Admin Told Me Not to Talk to Strangers
          1. Setting Up spamd in Greylisting Mode
          2. Greylisting in Practice
        3. Tracking Your Real Mail Connections: spamlogd
        4. Greytrapping
          1. Setting Up a Traplist
        5. Managing Lists with spamdb
          1. Updating Lists
          2. Keeping spamd Greylists in Sync
        6. Detecting Out-of-Order MX Use
        7. Handling Sites That Do Not Play Well with Greylisting
      3. Spam-Fighting Tips
    11. 7. Queues, Shaping, and Redundancy
      1. Directing Traffic with ALTQ
        1. Basic ALTQ Concepts
        2. Queue Schedulers, aka Queue Disciplines
          1. priq
          2. cbq
          3. hfsc
        3. Setting Up ALTQ
          1. ALTQ on OpenBSD
          2. ALTQ on FreeBSD
          3. ALTQ on NetBSD
      2. Setting Up Queues
        1. Priority-Based Queues
          1. A Real-World Example
          2. Using a match Rule for Queue Assignment
        2. Class-Based Bandwidth Allocation for Small Networks
          1. Queue Definition
          2. Rule Set
        3. A Basic HFSC Traffic Shaper
          1. Queue Definition
          2. Rule Set
        4. Queueing for Servers in a DMZ
        5. Using ALTQ to Handle Unwanted Traffic
          1. Overloading to a Tiny Queue
          2. Queue Assignments Based on Operating System Fingerprint
      3. Redundancy and Failover: CARP and pfsync
        1. The Project Specification: A Redundant Pair of Gateways
        2. Setting Up CARP
          1. Checking Kernel Options
          2. Setting sysctl Values
          3. Setting Up Network Interfaces with ifconfig
        3. Keeping States Synchronized: Adding pfsync
        4. Putting Together a Rule Set
        5. CARP for Load Balancing
    12. 8. Logging, Monitoring, and Statistics
      1. PF Logs: The Basics
        1. Logging All Packets: log (all)
        2. Logging to Several pflog Interfaces
        3. Logging to Syslog, Local or Remote
        4. Tracking Statistics for Each Rule with Labels
      2. Additional Tools for PF Logs and Statistics
        1. Keeping an Eye on Things with systat
        2. Keeping an Eye on Things with pftop
        3. Graphing Your Traffic with pfstat
        4. Collecting NetFlow Data with pflow(4)
          1. Setting Up the NetFlow Sensor
          2. NetFlow Data Collecting, Reporting, and Analysis
        5. Collecting NetFlow Data with pfflowd
        6. SNMP Tools and PF-Related SNMP MIBs
      3. Log Data as the Basis for Effective Debugging
    13. 9. Getting Your Setup Just Right
      1. Things You Can Tweak and What You Probably Should Leave Alone
        1. Block Policy
        2. Skip Interfaces
        3. State Policy
        4. State Defaults
        5. Timeouts
        6. Limits
        7. Debug
        8. Rule Set Optimization
        9. Optimization
        10. Fragment Reassembly
      2. Cleaning Up Your Traffic
        1. Packet Normalization with scrub
        2. Protecting Against Spoofing with antispoof
      3. Testing Your Setup
      4. Debugging Your Rule Set
      5. Know Your Network and Stay in Control
    14. A. Resources
      1. General Networking and BSD Resources on the Internet
      2. Sample Configurations and Related Musings
      3. PF on Other BSD Systems
      4. BSD and Networking Books
      5. Wireless Networking Resources
      6. spamd and Greylisting-Related Resources
      7. Book-Related Web Resources
      8. Buy OpenBSD CDs and Donate!
    15. B. A Note on Hardware Support
      1. Getting the Right Hardware
      2. Issues Facing Hardware Support Developers
      3. How to Help the Hardware Support Efforts
    16. Index
    17. About the Author
    18. Colophon
    19. C. Updates

Product information

  • Title: The Book of PF, 2nd Edition
  • Author(s): Peter N.M. Hansteen
  • Release date: November 2010
  • Publisher(s): No Starch Press
  • ISBN: 9781593272746