IPFILTER(4)

πŸ“¦
version 15.1 Β· 2 versions
, in freebsd 15.1

Bestie's Guide to the ipfilter Manual πŸ’–βœ¨

okay so you want to get into IP Filter? say less. this is the ipfilter manual page, and i'm gonna walk you through it like we're texting about it at 2am. no gatekeeping, no boring manpage energy. just vibes and facts. periodt. 🫢


✨ DESCRIPTION ✨

So ipfilter is literally a TCP/IP packet filter β€” like, it's the bouncer for your network, deciding which packets get in and which ones get told to leave. It's built for firewall duty, bestie. πŸ”₯

The way you use it? Two options, and i'm gonna tell you the right one: you can either load it as a loadable kernel module (which is highly recommended, no cap) or bake it right into your UNIX kernel. The module route is the move. Also there are scripts provided to install and patch your system files as needed, so you don't have to do it all by hand. iconic behavior. πŸ’…


πŸŽ€ FEATURES πŸŽ€

The IP packet filter can do all of this, and yes, it's giving main character energy:

  • explicitly deny/permit any packet from passing through
  • distinguish between various interfaces
  • filter by IP networks or hosts
  • selectively filter any IP protocol
  • selectively filter fragmented IP packets
  • selectively filter packets with IP options
  • send back an ICMP error/TCP reset for blocked packets
  • keep packet state information for TCP, UDP and ICMP packet flows
  • keep fragment state information for any IP packet, applying the same rule to all fragments.
  • act as a Network Address Translator (NAT)
  • use redirection to setup true transparent proxy connections
  • provide packet header details to a user program for authentication
  • in addition, supports temporary storage of pre-authenticated rules for passing packets through

Special provision is made for the three most common Internet protocols, TCP, UDP and ICMP. The IP Packet filter allows filtering of:

  • Inverted host/net matchingTCP/UDP packets by port number or a port number range
  • ICMP packets by type/code
  • "established" TCP packets
  • On any arbitrary combination of TCP flags
  • "short" (fragmented) IP packets with incomplete headers can be filtered
  • any of the 19 IP options or 8 registered IP security classes TOS (Type of Service) field in packets

So to keep track of how the IP packet filter is performing, there's a logging device involved. It supports logging of:

  • the TCP/UDP/ICMP and IP packet headers
  • the first 128 bytes of the packet (including headers)

A packet can be logged when:

  • it is successfully passed through
  • it is blocked from passing through
  • it matches a rule setup to look for suspicious packets

And IP Filter keeps its own set of statistics on:

  • packets blocked
  • packets (and bytes!) used for accounting
  • packets passed
  • packets logged
  • attempts to log which failed (buffer full)
  • and much more, for packets going in and out.

πŸ› οΈ Tools πŸ› οΈ

The current implementation provides a small set of tools, which can easily be used and integrated with regular unix shells and tools. Let me introduce you to the squad, with a brief description of the tools provided:

ipf(8) reads in a set of rules, from either stdin or a file, and adds them to the kernels current list (appending them). It can also be used to flush the current filter set or delete individual filter rules. The file format is described in ipf(5).

ipfs(8) is a utility to temporarily lock the IP Filter kernel tables (state tables and NAT mappings) and write them to disk. After that the system can be rebooted, and ipfs can be used to read these tables from disk and restore them into the kernel. This way the system can be rebooted without the connections being terminated. lowkey genius. 🧠

ipfstat(8) interrogates the kernel for statistics on packet filtering, so far, and retrieves the list of filters in operation for inbound and outbound packets.

ipftest(1) reads in a filter rule file and then applies sample IP packets to the rule file. This allows for testing of filter list and examination of how a packet is passed along through it.

ipmon(8) reads buffered data from the logging device (default is /dev/ipl) for output to either:

  • screen (standard output)
  • file
  • syslog

ipsend(1) generates arbitrary IP packets for ethernet connected machines.

ipresend(1) reads in a data file of saved IP packets (ie snoop/tcpdump/etherfind output) and sends it back across the network.

iptest(1) contains a set of test "programs" which send out a series of IP packets, aimed at testing the strength of the TCP/IP stack at which it is aimed at. WARNING: this may crash machine(s) targeted! πŸ’€ like, fr fr, be careful with this one.

ipnat(8) reads in a set of rules, from either stdin or a file and adds them to the kernels current list of active NAT rules. NAT rules can also be deleted using ipnat. The format of the configuration file to be used with ipnat is described in ipnat(5).

For use in your own programs (e.g. for writing of transparent application proxies), the programming interface and the associated ioctl's are documented in ipf(4).

Documentation on ioctl's and the format of data saved to the logging character device is provided in ipl(4) so that you may develop your own applications to work with or in place of any of the above.

Similar, the interface to the NAT code is documented in ipnat(4).


🌈 PACKET PROCESSING FLOW 🌈

okay bestie, this next part is a diagram. it shows the flow of TCP/IP packets through the various stages introduced by IP Filter. i'm gonna drop it here exactly as it is, because it's kind of iconic and also i don't want to mess with the vibes:

                                     IN
                                      |
                                      V
            +-------------------------+--------------------------+
            |                         |                          |
            |                         V                          |
            |            Network Address Translation             |
            |                         |                          |
            |         authenticated   |                          |
            |       +-------<---------+                          |
            |       |                 |                          |
            |       |                 V                          |
            |       V           IP Accounting                    |
            |       |                 |                          |
            |       |                 V                          |
            |       |        Fragment Cache Check--+             |
            |       |                 |            |             |
            |       V                 V            V             |
            |       |         Packet State Check-->+             |
            |       |                 |            |             |
            |       |       +->--+    |            |             |
            |       |       |    |    V            |             |
            |       V   groups   IP Filtering      V             |
            |       |       |    |    |            |             |
            |       |       +--<-+    |            |             |
            |       |                 |            |             |
            |       +---------------->|<-----------+             |
            |                         |                          |
            |                         V                          |
            |                +---<----+                          |
            |                |        |                          |
            |            function     |                          |
            |                |        V                          |
            |                +--->----+                          |
            |                         |                          |
            |                         V                          |
         +--|---<--- fast-route ---<--+                          |
         |  |                         |                          |
         |  |                         V                          |
         |  +-------------------------+--------------------------+
         |                            |
         |                        pass only
         |                            |
         |                            V
         V               [KERNEL TCP/IP Processing]
         |                            |
         |  +-------------------------+--------------------------+
         |  |                         |                          |
         |  |                         V                          |
         |  |                Fragment Cache Check--+             |
         |  |                         |            |             |
         |  |                         V            V             |
         |  |                 Packet State Check-->+             |
         |  |                         |            |             |
         |  |                         V            |             |
         V  |                    IP Filtering      |             |
         |  |                         |            V             |
         |  |                         |<-----------+             |
         |  |                         V                          |
         |  |                   IP Accounting                    |
         |  |                         |                          |
         |  |                         V                          |
         |  |            Network Address Translation             |
         |  |                         |                          |
         |  |                         V                          |
         |  +-------------------------+--------------------------+
         |                            |
         |                        pass only
         V                            |
         +--------------------------->|
                                      V
                                     OUT

like, just follow the arrows, it'll make sense. promise. πŸ’–


πŸ” MORE INFORMATION πŸ”

The IP Filter FAQ can be found at https://www.phildev.net/ipf/ β€” go check it out if you need more.


πŸ‘€ SEE ALSO πŸ‘€

ipf(4), ipf(5), ipf(8), ipfilter(5), ipfs(8), ipfstat(8), ipftest(1), ipl(4), ipmon(8), ipnat(8), ipnat(4)


okay that's the whole page, bestie. you're now officially caught up on ipfilter. go forth and filter those packets. πŸ’…βœ¨

this has been the IP FILTER(4) kernel interfaces manual, and this version is from the same source/version and date as the original β€” mwah. πŸ«ΆπŸŽ€

πŸ“¦ where this page comes from