IP Filter FAQ

Welcome to the IP Filter Frequently Asked Questions. This FAQ contains a lot of useful information and if you use, or plan to use IPF, you should read it. Here is some information about the FAQ:
  1. The latest version can be found at http://www.phildev.net/ipf/
  2. You may copy it, mirror it, distribute it at will as long as you do so IN IT'S ENTIRETY
  3. The FAQ was written, and currently maintained by Phil Dibowitz so please direct any updates, or questions there.
  4. The FAQ doesn't address bugs in versions prior to 3.4.20 (other than how to upgrade to that level). If you find a bug not on here, and you don't have a recent version, you should try upgrading.
The following is the entire FAQ in one page. I did this mostly for those who want to print it out (I wrote a script that combined all the pages), so some links may not work as expected. Please make sure to visit the main page if you haven't already for more information on this FAQ. Enjoy.


I. GENERAL

  1. Who wrote IP Filter?
  2. What is the website for IP Filter?
  3. Is there a tutorial?
  4. What OS's does it run on?
  5. I want to distribute IPF with my product XYZ. Is that allowed, and what do I need to do?
  6. I want to use IPF code in a product I'm working on that I intend to sell. Is that allowed, and what do I need to do?
  7. I want to use IPF code in a product I'm planning on giving away for free. Is that allowed, and what do I need to do?
  8. How does the release process for IPF work?

II. MAILING LIST

  1. What mailing list(s) is/are available for IP Filter?
  2. What do I need to know before sending stuff to the list?
  3. What should I ALWAYS do when sending stuff to the list?
  4. What should I NEVER do when sending stuff to the list?
  5. Are there archives for the mailing list?

III. COMMON QUESTIONS ABOUT IP FILTER

  1. What does keep state actually do? Is it useful?
  2. What is with this last match stuff?
  3. What is "in" and what is "out"?
  4. Does IP Filter actually work on BSD/OS? What do I need to make it work?
  5. I'm using PPPoE (or some other virtual interface/tunnel), how should I write my rulesets?
  6. So, if 'map a.b.c.d/M -> w.x.y.z/32' does NAT for all protocols, why do I need a 'map a.b.c.d/M -> w.x.y.z/32 portmap'
  7. Well, after reading the answer to III-6, do I have to have the first rule if I have the second rule?
  8. How do I upgrade IPF?
  9. I have a dynamic IP address, how can I do NAT?
  10. What's the difference between RDR, MAP, and BIMAP?
  11. When does NAT happen in relation to filtering?
  12. Are there any GUI's or other aids?
  13. Are there any log analyzers?
  14. How do you clear accounting stats?
  15. What do I handle DNS if I have a NAT'ed LAN?
  16. I don't run DNS, but see a lot of tcp/53 packets with the SA flags set in my logs. Is this an attack on my machine?
  17. Can you filter the loopback interface (lo0)?
  18. I'm seeing port scans in my logs, what should I do?
  19. How do I use archie from machines behind IP Filter?
  20. How does quick affect head rules?
  21. How do I get the FTP Proxy to work for my firewall if I have a dynamic IP address?
  22. I've written a patch for XYZ feature/bug. Where do I send it?
  23. How do I use MRTG to display ip-filter statistics? Is there a MIB for ip-filter?
  24. What do the states ("ST") in statetop mean?
  25. How do I enlarge the state table? What else should be tweaked for high-stress installs?
  26. Is there a way to remove a specific live NAT mapping or IPF state?
  27. How many rules can IPF handle without noticeable performance loss?
  28. How can I configure IPF so that laptops can connect to services on the firewall from the internal LAN and from the outside world using the external addresses, so they don't have to be reconfigured all the time?
  29. How do you use the IPSec Proxy?
  30. How do you use the H.323 Proxy?
  31. How do you use the RAudio Proxy?
  32. Is it possible to have multipe head statements for a group?
  33. Can you use ipnat/proxies on a bridge?
  34. How do I make ping and traceroute work?
  35. Is it possible to delete selected states from the state table?
  36. In IPF 4.x, it's supposedly possible to "simple matching of content for TCP session startup" - how does that work?
  37. Can I have variables in my ipf.conf/ipnat.conf?

IV. COMMON PROBLEMS WITH IP FILTER (NON-OS SPECIFIC)

  1. I have file transfer (FTP or HTTP) and if download speed is more then 100 KB/sec, connection breaks.
  2. I have to keep clearing the state table or IPF dies, why?
  3. The default ipfboot script flushes the state table. Is this necessary every time you change some rule or just when that rule has a 'keep state' in it and there are existing state table entries that would be affected?
  4. Sending mail is horribly slow!
  5. I can't connect to IRC.
  6. When I try to load the LKM (if_ipl.o), I get "fr_checkp" (or other) unresolved symbols. (FreBSD, OpenBSD, SunOS)
  7. When I do a make, it complains about -I(TOP).
  8. I'm using rdr for a webserver behind IPF and the world can see it just fine, but the internal machines can't surf to it via the external IP address.
  9. Long ftp transfers and some other long single-connection sessions fail.
  10. I've set up to use the ftp-proxy in my ipnat.conf file, and it works fine from NAT'ed machines, but I can't ftp from the firewall machine unless I put a rule in ipf.conf to pass port 20/tcp in from remote machines. How do I get the ftp proxy to work from the firewall machine too?
  11. I'm using NAT and I can't ping the same machine on the internet from two different machines on my LAN at the same time.
  12. Keep state stops working - it won't make new states.
  13. I'm using log body in my rules but the body of the packet isn't getting logged.
  14. I have an FTP server behind an IPF firewall, and I'm having problems serving passive FTP.
  15. I can't seem to use round-robin load balancing with more than two hosts!
  16. I'm having problems with ipnat (e.g. can't get proxies to work with bimap, or some other problem).
  17. I'm using interface/32, 0/0 or 0/32, and it doesn't work!
  18. I stop/unload IPF, but it magically reloads itself!
  19. I'm having problems connecting to Cisco VPNs through IPF NAT.
  20. I'm trying to remove entries from a pool and getting errors

V. IP FILTER AND VPN

  1. I can only initiate x number of VPN connections to/from my NAT'd boxes! Why?
  2. I'm having more VPN problems... ESP packets and UDP packets are not being mapped to the same IP ddress.

VI. IPMON

  1. I have IPMon logging to syslog, but syslog doesn't log anything, why not?
  2. I have IPMon logging to syslog, and I can't use ipmon -oI, why not?
  3. When I start ipmon, it fails to start with an error.
  4. I'm getting wierd ipmon log entries, why?
  5. Can I make IPF log straight to a file instead of to syslog?

VII. IP FILTER AND SOLARIS

  1. Why don't my return-rst's work?
  2. It won't compile, something about /usr/ucb/cc.
  3. I'm using a 64-bit kernel, and when it tries to load ipf, it gets an error.
  4. How can I tell if I'm using a 32-bit or 64-bit kernel?
  5. Can I use gcc to make 64-bit Sparc kernel modules?
  6. What do I need to make a 64 bit Sparc kernel module?
  7. Wait, my Sparc host is running in 64 bit mode, but I don't want to buy Sun's Forte compiler, nor do I want to install the try-and-buy. What can I do to get IPF up?
  8. When I try to pkgadd the precompiled IPF package I downloaded, there are two sub-packages. What do I do?
  9. Can I use IPF on Solaris as a Layer 2 bridge?
  10. How can I tweak some of IPF's internal values at boot time?
  11. How can I build a transparent proxy using Squid on Solaris 8?
  12. Why can't I filter on the loopback interface, or virtual interfaces?
  13. How do I make StateTop work on Solaris?
  14. I'm using sppp, IPSec, or some other IP Tunnel and I'm seeing random system crashes or CPU "thrash," what do I do?
  15. I'm using a Sun system with an eri or bge interface, and after setting up NAT, ICMP passes through fine, but TCP doesn't. Why?
  16. Aren't there any 64-bit IP Filter binaries for Solaris out there already?
  17. Since upgrading to Solaris 9, I've been having wierd crashes. Is this IPF related? What can be done?
  18. Where are the instructions for installing on Solaris 7/8/9/etc.?
  19. I'm getting /usr/include/ia32/sys/reg.h:300: error: parse error before "upad128_t" when I compile IPF, why?
  20. In IPF 4.x, you can supposedly compile the rules into an LKM. How do you do this in Solaris?
  21. In IPF 4.x, what is the performance gain in compiling your rulset into an LKM?
  22. In IPF 4.x, I'm trying to build with gcc3 but it's not working!
  23. How do I compile IPF 4.x with gcc?
  24. How do I remove the IPF that comes with Solaris 10 and replace it with Darren's public-domain release?
  25. I installed IP Filter with Solaris 10, but there's no init scripts!

VIII. IP FILTER AND SUNOS

IX. IP FILTER AND HP-UX

  1. Does IPF Support HP-UX?

X. IP FILTER AND FREEBSD

  1. How can I set up bridging on FreeBSD?
  2. How can I get IP Filter to block by default?
  3. What version of IPF is included in FreeBSD?
  4. Where do I find the sources?
  5. How do I (re)compile IPF on FreeBSD?
  6. How do I start ipfilter on a running system?
  7. Don't I need to compile IPF into my kernel?
  8. How do I configure FreeBSD to enable ipfilter at startup?
  9. Forget the loadable kernel module stuff, how do I do compile IPF into my kernel?
  10. How do I start ipnat on a running system?
  11. How do I configure FreeBSD to enable ipnat at startup?
  12. How do I use the FreeBSD traffic shaper dummynet(4) with IPF?
  13. Which is better/faster/cool/etc., IPF of IPFW?
  14. IPF and IPFW both have features I want to use, must I choose between them?
  15. Won't this slow down processing packets? By how much?
  16. How can I tweak some of IPF's internal values?
  17. Occasionally a server resends a TCP packet I've already sent an ACK to, and it causes the connection to die, why?
  18. I just upgraded IPF and I'm getting errors on boot - but everything works fine.
  19. How do I get IPF working with IPv6 in FreeBSD?

XI. IP FILTER AND NETBSD

  1. How do I upgrade IP Filter on NetBSD?
  2. How do I get IPF working with IPv6 in NetBSD?
  3. I'm getting messages about "no more space for rules" -- and I have a large ruleset. What do I do?

XII. IP FILTER AND OPENBSD

  1. How can I get IP Filter to block by default?
  2. How can I upgrade IP Filter on OpenBSD?
  3. So I've upgraded IP Filter, why isn't it working?
  4. I just installed OpenBSD 3.x, where's IP Filter?
  5. I've heard that there's problems with filtering on OpenBSD bridges. What's the deal?

XIII. IP FILTER AND LINUX

  1. Is there a linux port?
  2. So how do I get it running on my favorite distro?

XIII. IP FILTER FAQ ADMINISTRATIVE QUESTIONS

  1. Would you like me to register a domain for you?
  2. Would you like free hosting?
  3. How often is the FAQ updated?
  4. I have a usefull addition to the FAQ, what do I do?
  5. I've submitted something for the FAQ, but it's not here, why not?

  1. Who wrote IP Filter?
    Darren Reed is the author of IP Filter. There have been many others who have helped him along the way. See the HISTORY file in the IP Filter source code for details.
  2. What is the website for IP Filter?
    http://coombs.anu.edu.au/ipfilter/ (or http://coombs.anu.edu.au/ipfilter/)
    or see mirrors at:
    http://coombs.anu.edu.au/ipfilter/#Mirrors
  3. Is there a tutorial?
    http://www.obfuscation.org/ipf/ is the official tutorial. Someone named Guido Van Rooij also wrote some documentation.
  4. What OS's does it run on?
    It comes as part of FreeBSD 2.2+, NetBSD 1.2+, Solaris 10+, and Open Solaris.
    It has also been tested on Solaris SPARC/x86 2.3 - 9, SunOS 4.1.1 - 4.1.4, NetBSD 1.0 - 1.4, FreeBSD 2.0.0 - 2.2.8, BSD/OS-1.1 - 4, IRIX 6.2, OpenBSD 2.0 - 2.9, HP-UX 11.00 (IPFilter 4.x), and QNX Port*. Check the website for more information on the starred items.
  5. I want to distribute IPF with my product XYZ. Is that allowed, and what do I need to do?
    Yes, it is allowed, so long as the IPFilter code is not placed under the GPL or any similar licence.

    The IPFilter licence requires you to acknowledge that your product is based upon IPFilter. This is the same whether or not it is free, for sale, open source or closed source. In short this means somewhere in the documentation about your product (i.e Credits, etc), it needs to have an attribution to IPFilter and its author.

    If you do not wish to include this, or have more specific questions or wish to licence IPFilter under different terms than the public licence, please feel free to email Darren Reed at darrenr@pobox.com.

    NOTE: The above is directly from Darren.
  6. I want to use IPF code in a product I'm working on that I intend to sell. Is that allowed, and what do I need to do?
    See I-5
  7. I want to use IPF code in a product I'm planning on giving away for free. Is that allowed, and what do I need to do?
    See I-5
  8. How does the release process for IPF work?
    Take a look at the Development Status Page for information on current releases. This contains what works and doesn't work with a specific release. The goal is generally to have all boxes be "OK" or "PASS" when a release is finalized.

    Additionally you can find all patches to the current release here.

  1. What mailing list(s) is/are available for IP Filter?
    There is a single mailing list intended for support, general discussion, and anything else related to IPF. You can join by sending mail to majordomo@coombs.anu.edu.au and putting subscribe ipfilter in the body. But PLEASE read the rest of this FAQ before posting.
  2. What do I need to know before sending stuff to the list?
    1) READ THE TUTORIAL (I-3)
    2) Search the ARCHIVES (II-5)
    3) READ II-3 and II-4
    4) Read this entire FAQ!!
    5) Optionally (but recommended), read all the man pages: ipf.4 ipf.5 ipf.8 ipfilter.5 ipfs.8 ipfstat.8 ipftest.1 ipl.4 ipmon.8 ipnat.1 ipnat.4 ipnat.5
  3. What should I ALWAYS do when sending stuff to the list?
    State your problem very clearly.
    Give all error messages.
    Give all information
    Include as much information as possible. Start with:
    # uname -a
    # isainfo -vk
    # ifconfig -a
    # netstat -rn
    # netstat -i
    # netstat -s -P ip
    # ipf -V
    # ipfstat
    # ipfstat -io
    # ipnat -slv
    Always reply to the list, and remove the original sender, no one wants to get email twice
  4. What should I NEVER do when sending stuff to the list?
    Never email anyone on the list directly unless they ask you to. If someone responds to your email on the list, you should reply TO THE LIST. This is for courtesy as well as the purpose of having your problem and solution show up in the archives for other people.

    Never send HTML email to the list.
  5. Are there archives for the mailing list?
    I'm glad you asked! There sure are at http://marc.theaimsgroup.com/?l=ipfilter&r=1&w=2.
    Please take advantage of these and search them for your topic BEFORE posting to the mailing list.

  1. What does keep state actually do? Is it useful?
    From Darren:
    First, yes, it is useful. What it does is allows you to only allow TCP packets through your firewall which are recognised as being part of an established connection rather than just arbitary TCP packets which can be used to perform "stealth scanning". In terms of rules, the following:
    pass in proto tcp all
    block out proto tcp all
    block in proto tcp all flags S
    pass in quick from any to any port = smtp flags S
    pass out proto tcp from any port = smtp to any

    can be replaced by:
    block in proto tcp all
    block out proto tcp all
    pass in quick proto tcp from any to any port = smtp flags S keep state

    keep state automatically matches packets going in the reverse direction (usually out) or on other interfaces without needing explicit rules.

    For UDP, it will automatically allow packets in which are the "reverse" of packets that have already been allowed through, without needing to allow too many packets through. For example, the following could be used for DNS clients:
    block out proto udp all
    block in proto udp all
    pass out proto udp from any port > 1024 to any port = 53
    pass in proto udp from any port = 53 to any port > 1024

    which allows through a LOT of unwanted packets. This can be effectively replaced with the following:
    block out proto udp all
    block in proto udp all
    pass in proto udp from any to any port = 53 keep state

    Keep state will also allow ICMP packets related to a TCP or UDP session through. So if you get ICMP type 3 code 4 in response to some websurfing allowed out by a keep state rule, they will be automatically allowed in. Any packet that IPF can be certain is part of a connection, even if it's a different protocol, will be let in.
  2. What is with this last match stuff?
    Some firewalls use last match theory, while others use first match. Neither is better, it's purely taste. By default, IP Filter is last match, and you can change that if you want to. So what does that mean. Let say you have the following rules:
    pass all
    block in proto tcp from any to any port = 25
    block all

    What you have here is essentially a 'block all' firewall: the first two rules don't do anything. When a packet comes in, lets say from 1.2.3.4 port 2000, to 2.3.4.5 port 79, the filter is going to do this: Does this packet match 'pass all'? Yes, it does, let's keep that in mind. Does this packet match 'block in proto tcp from any to any port = 25'? No. Does this packet match 'block all'? Yes it does, so I can forget whatever else it's matched so far and keep this one in mind. Oh, that's the last rule, let's go with that one. So, even if the first rule specifically allowed all port 79 (finger) traffic in, it still wouldn't actually get in. Let look at one more example:
    block in all
    pass in from 1.2.3.4 to any
    block in proto tcp from 1.2.3.4 to any port = 25

    Now, let's say a packet comes in from 1.2.3.4 headed to our SMTP port (25), what happens? It get's blocked, because rule 3 is the last rule to match that packet.

    Now, if you want to CHANGE this behavior, you simply add the quick to your rules, so:
    pass in quick from 1.2.3.4 to any
    block in quick proto tcp from 1.2.3.4 to any port = 25
    block in quick all

    Now notice I moved the 1st rule and made it the last rule. If I didn't, nothing would get through because of thequickkeywork. You can mix and matchquickand non-quick rules (although in general it's not advised), but basically what IPF does is when it hits a rule that matches the packet, if thequickkeyword is there, it takes that action without looking any further.
  3. What is "in" and what is "out"?
    In and out are from the perspective of the actual interface. In means arriving on the interface from the external world, leading into the box for kernel processing. Out means exiting the interface headed into the external world, having already been processed by the kernel.

    Let's look at a packet traversing your firewall from the inside out...

    This packet, call it a port 80 SYN from your browser, goes:
    (Your workstation)-->(int_if)[OS_kernel](ext_if)-->(internet)
    IN on int_if
    and thru the kernel, then
    OUT on ext_if

    The SYN+ACK reply from a 'net webserver on port 80 goes (internet)-->(ext_if)[OS_kernel](int_if)-->(Your workstation)
    IN on ext_if
    and thru the kernel, then
    OUT on int_if
  4. Does IP Filter actually work on BSD/OS? What do I need to make it work?
    Yes, it does, BUT, you may need a source license for BSD/OS. Object modules are provided for use with BSD/OS 3.1.
  5. I'm using PPPoE (or some other virtual interface/tunnel), how should I write my rulesets?
    Any rule that needs to refer to the outside interface should refer to the VIRTUAL interface and NOT the physical interface. For example, if your physical interface is elxl0 and your PPPoE interface is ppp0, then all you will see on elxl0 is PPP Frames which IP Filter can't understand anyway. Those frames will get unwrapped and 'come in' on ppp0 as IP packets which IP Filter can then read and filter.
  6. So, if map a.b.c.d/M -> w.x.y.z/32 does NAT for all protocols, why do I need a map a.b.c.d/M -> w.x.y.z/32 portmap
    Well, the first one will do NAT for you. However it will ONLY try the source port requested, so if two machines on your network request a connection to the same place with the same source address, one of them will fail. However, if you have the portmap statement first, then if the source port is in use, it will try another source port in that range (you can specify a range instead of auto).
  7. Well, after reading the answer to III-6, do I have to have the first rule if I have the second rule?
    In general, yes, but it depends. The portmap rule will only work for TCP and UDP. They will not work for any other protocol such as ICMP, ESP, etc. The other rule matches all other protocols, so generally you want both.
  8. How do I upgrade IPF?
    See the section for your specific OS.
  9. I have a dynamic IP address, how can I do NAT?
    You'll need to make your map rules look like this: map ppp0 10.0.0.0/8 -> 0/32

    The 0/32 tells IPNAT to use the current IP address for the ppp0 interface as the address to map to. Next, "ipf -y" must be run each time the interface is brought up with a new IP address to synchronise the address if currently being used. Check your ppp dialer for instructions on how to run something each time a new connection is made (DHCPd has something similar for DHCP connections, incase you are not using dialup).
  10. What's the difference between RDR, MAP, and BIMAP?
    In short:
    Rdr rewrites destination addresses and ports of packets entering an interface.
    Map rewrites source addresses and ports of packets leaving an interface.
    Bimap does both.

    In long:
    First and foremost: You probably do not need bimap. Try rdr first.
    Rdr is generally used to allow internet hosts to access servers behind the machine running IPF. As an example, apache could be running on a server behind the IPF machine, and http requests to the external ip address of the ipf machine can be redirected to that apache server.
    Map is generally used for NAT'ing (masquerading) clients behind the machine running IPF, thus you can have many clients accessing the internet via a single IP address.
    Bimap is generall used when you're NAT'ing all outbound traffic to some address range (could be one address), and you have an server that needs to be accessed via a another address, and ALSO has to be able to make outgoing connections (like a passive FTP server) using that same address. Warning: Using bimap when it's not really needed can get you in a lot of trouble. If your NAT'ing outbound connections to the same address as your server gets contacted on, you do not need bimap. Always try rdr first!
  11. When does NAT happen in relation to filtering?
    Incoming packets enter the interface, get NAT'd, get filtered, then (if they get through the filter) get passed onto the kernel for processing. Additionally outgoing packets get filtered then NAT'd:

    interface --> NAT --> filter --> OS --> filter --> NAT --> interface

    This is important to keep in mind when writing your ruleset because your rules need to use the translated (i.e. internal host) address. In other words, if your public address is Z and internal host A is talking to external host B, then the traffic from B will have a destination address of A, NOT Z because the destination NAT has already happened. For more information, see IP Filter Flow and this thread.
  12. Are there any GUI's or other aids?
    First let me say that you should really learn to write regular rulesets for IP Filter. They are made to be nearly plain english. Being able to write the rules yourself will also give you a better understanding for what is going on. That said...

    Filter Language Compiler - A tool written by Darren (the auther of IPF) that generates rules for the various packages which perform packet filtering from a common language.
    ISBA - GUI for managing IPF.
    Firewall Builder - a GUI for making rulesets for multiple firewall packages.
  13. Are there any log analyzers?
    Yes. Two I know of, probably more. There's a perl script called plog that comes with the IP Filter source code under the perl directory. Also available is fwanalog.
  14. How do you clear accounting stats?
    ipf -z -f your_rule_file
  15. What do I handle DNS if I have a NAT'ed LAN?
    If you want to use DNS in the LAN, you need a separate DNS server for the LAN addresses. This server should not be visible outside the LAN. It's possible to run the DNS on the firewall itself, but you need to be very careful with the configuration of both the DNS server itself (e.g. BIND) and ipfilter in order to prevent a hole big enough to drive through. A few things to remember. Do not allow zone transfers across the firewall; instead, set up the DNS server as a master for your internal hosts (e.g. 192.168.x.x) and as a forwarder (and forward only mode) for external names which can not be resolved. RTFM on your DNS server.
  16. I don't run DNS, but see a lot of tcp/53 packets with the SA flags set in my logs. Is this an attack on my machine?
    It might be, but if the packets come in periodic bursts from only a few machines, it is probably nothing more than a misconfigured Cisco distributed content director trying to find the shortest routes to your machine. You can eliminate the log clutter with a rule like:
    block in quick on ext-interface proto tcp from any to firewall port = domain flags SA
  17. Can you filter the loopback interface (lo0)?
    It is possible to filter the loopback interface on every platform except Solaris and HP-UX.
  18. I'm seeing port scans in my logs, what should I do?
    In most cases, do nothing. There is no law (for the most part) against port scanning. If you notice EXCESSIVE activity from a certain IP (i.e. multiple days or large bandwidth), then you can report it to the ISP that owns that IP address... other than that, there's not much you can do. There's no harm in some portscans... and it's a waste of your time to go after them. You could spend all day every day to track down all the people who port scanning you (especially if you have a large network), and blocking their IP's would make your ruleset inefficiently long. Additionally, if you run a webserver, or any public service, you'll likely block some valid IP's since many IP's are dynamic. The best defence is to secure your network, have a secure ruleset that you've tested in-depth.
  19. How do I use archie from machines behind IP Filter?
    For queries from the firewall machine itself, you can the open ports for replies to archie queries:
    pass in quick proto udp to ext-interface from any port = 1525 to firewall port > 30000 keep state
    pass in quick proto udp to ext-interface from any port = 191 to firewall port > 30000 keep state

    From NATed machines behind the firewall, you either need to modify one of the ip-filter proxies so it works with archie, or to have your users use an archie site which returns replies on the querying port, such as archie.rediris.es.
  20. How does quick affect head rules?
    Essentially the quick, like the pass or block, affects the default action for the group if nothing in the group matches. Any head rule, quick or otherwise, causes immediate recursion into that rule group. For example:
    block in quick on de0 all head 100

    descends into group 100, seeking further matches. If nothing matches inside and group 100 returns, the block in quick action specified in its head rule above is taken.

    If something inside group 100 does match, that rule's action is taken instead. If that inner matching rule doesn't have quick, the quick bit is unset, and if nothing else inside group 100 matches it returns to its head, but with the action(s) specified by the inner rule -- specifically, the quick bit is now off and overrides the original head rule's quick. So in that case, rule processing continues past the above head rule, because a rule in that group matched and set "not quick" as part of the processing actions to do. If the head rule is not quick then if no rules match, the end result is not a quick rule.
  21. How do I get the FTP Proxy to work for my firewall if I have a dynamic IP address?
    You can use:
    map foo0 0/0 -> 0/32 proxy port ftp ftp/tcp

    This says "map everything to my external IP address." Unfortunately there is no way to say 0/32 -> 0/32 yet, so either use the above rule, or you can have your ip-up (see the pppd manpage) edit your ipnat.conf each time you get a new IP.
  22. I've written a patch for XYZ feature/bug. Where do I send it?
    Most people send them to the IP Filter mailing list, and this is perfectly fine. If you do not feel comfortable doing this, feel free to send them to Darren directly.
  23. How do I use MRTG to display ip-filter statistics? Is there a MIB for ip-filter?
    There is no simple MIB, but there are perl and shell scripts available to read various ip-filter statistics into MRTG. See http://www.18james.com/utilities.html#mrtg for more information on IPF and MRTG.
  24. What do the states ("ST") in statetop mean?
    There are two numbers represented in statetop, each number represents the state of one side of the connection. The meanings of the numbers follow:
    Number Name Comment
    0 TCPS_CLOSED closed
    1 TCPS_LISTEN listening for connection
    2 TCPS_SYN_SENT active, have sent syn
    3 TCPS_SYN_RECEIVED have sent and received syn
    4 TCPS_ESTABLISHED established
    5 TCPS_CLOSE_WAIT rcvd fin, waiting for close
    6 TCPS_FIN_WAIT_1 have closed, sent fin
    7 TCPS_CLOSING closed xchd FIN; await FIN ACK
    8 TCPS_LAST_ACK had fin and close; await FIN ACK
    9 TCPS_FIN_WAIT_2 have closed, fin is acked
    10 TCPS_TIME_WAIT in 2*msl quiet wait after close

    Some additional notes:
    States < TCPS_ESTABLISHED are those where connections not established
    States > TCPS_CLOSE_WAIT are those where user has closed
    States > TCPS_CLOSE_WAIT && < TCPS_FIN_WAIT_2 await ACK of FIN

    All comments are Darren's taken straight from ip_compat.h
  25. How do I enlarge the state table? What else should be tweaked for high-stress installs?
    Edit ipf_state.h and look for the lines:
    
     #ifndef IPSTATE_SIZE
     # define        IPSTATE_SIZE    5737
     #endif
     #ifndef IPSTATE_MAX
     # define        IPSTATE_MAX     4013    /* Maximum number of states held */
     #endif
     

    IPSTATE_MAX should be approx. 70% of IPSTATE_SIZE and both numbers should be prime. The exact values you need depend highly upon the situation, but do NOT go crazy. Numbers in the 6 digits are very excessive. If you are having trouble with your state tables check out section IV-12 first.

    For very high-traffic installations this will need to be tweaked. A good number to start with is 10 connections per workstation and adjust from there. Other things that might need tweaking depending on your situation is NMBCLUSTERS and NAT_SIZE.

    Just as a guide, here's some of the other #defines and what they mean:
    NAT_SIZE - Size of the hash table for NAT rules
    RDR_SIZE - Size of the hash table for RDR rules
    NAT_TABLE_SZ - Size of the hash table which holds all active MAP/RDR entries
    HOSTMAP_SIZE - Table for holding the mapping of internal hosts to external IPs for consistency purposes when talking to a specific remote host
  26. Is there a way to remove a specific live NAT mapping or IPF state?
    Not with IP Filter itself. But the code is there to allow an external program to do this.

    Additionally Andrei Syrovenko wrote a utility called rmstate that does just that. His code is hosted at http://www.andy.in.ua/ipfilter/rmstate-1.1.tgz. We mirror his software here. Note that it is NOT guaranteed by Andrei Syrovenko, Darren Reed, Phil Dibowitz, Jason Lingohr or anyone else, nor is it part of the official IPF codebase.

    The program takes only one argument: the source IP address of the entries that should be removed from the state table. Additionally, it will only work with ipfilter 3.4.26 and later, or 4.1.29 and later.
  27. How many rules can IPF handle without noticeable performance loss?
    A lot. There have been cases where there have been more than 45,000 rules without noticeable performance loss. The important thing when dealing wih large numbers of rules is to use groups. When properly written and organized you can have tons of rules.
  28. How can I configure IPF so that laptops can connect to services on the firewall from the internal LAN and from the outside world using the external addresses, so they don't have to be reconfigured all the time?
    The solution seems a bit counter-intuitive at first, but it's actually quite simple. Setup a redirect on your internal interface, like this:
    rdr int-interface ext-address/32 port 110 -> int-address port 110 tcp
    rdr int-interface ext-address/32 port 25 -> int-address port 25 tcp

    Remember that this is only if the services are on the firewall. If the services are on machines behind the firewall see IV.8.
  29. How do you use the IPSec Proxy?
    Unfortunately, I've never used it myself. At this point the best I can do is give you the syntax:
    map ext-interface int-address/24 -> ext-address/32 proxy port 500 ipsec/udp
  30. How do you use the H.323 Proxy?
    Unfortunately, I've never used it myself. At this point the best I can do is give you the syntax:
    map ext-interface int-address/24 -> ext-address/32 proxy port 1720 h323/tcp
  31. How do you use the RAudio Proxy?
    Unfortunately, I've never used it myself. At this point the best I can do is give you the syntax:
    map ext-interface int-address/24 -> ext-address/32 proxy port 7070 raudio/tcp
  32. Is it possible to have multipe head statements for a group?
    It is not possible to do this in the 3.x version of IP Filter, however this is a feature of 4.x (currently in beta).
  33. Can you use ipnat/proxies on a bridge?
    Yes and no. A bridge won't do address translation - it's not supposed to. However, you can use IPNat's proxies to allow connections across the statetable. For example, you could use the FTP proxy as follows:
    map 0/0 -> 0/0 proxy port ftp ftp/tcp

    To enable FTP across your bridge. Remember that at this time, the IPF FTP proxy does not support EPSV Passive connections, only plain PSV.
  34. How do I make ping and traceroute work?
    This question isn't as simple as it sounds. It takes an understanding of filtering, ICMP, UDP, ping, and traceroute. Here are some of the basics to get you started. Remember that if you are keeping state on all outgoing ICMP, then outgoing pings will automatically work.

    Ping uses ICMP. Specifically it entails an ICMP type 8 code 0 (herein refered to as ICMP 8/0) packet (called "echo request") being sent to the target, and an ICMP 0/0 packet (called "echo reply") being sent back to the original host. To allow pings out one might do:
    pass out quick proto icmp from any to any icmp-type 8 code 0 keep state

    or if you didn't want to use keep state you could do:
    pass out quick proto icmp from any to any icmp-type 8 code 0
    pass in quick proto icmp from any to any icmp-type 0 code 0

    Traceroute requires ICMP 11/0 and 3/3 (TTL expired and Port unreachable respectively). You will let to need to let these in to your network to allow outgoing traceroutes. Additionally, UNIX traceroute requires UDP packets (to the target) to ports greater than 3000. So you will need to let those in or out of your network to let UNIX traceroutes in or out of your network. Microsoft's tracert utilitiy does not use UDP. For more information, see various discussion in the mailing list archives.
  35. In IPF 4.x, it's supposedly possible to "simple matching of content for TCP session startup" - how does that work?
    A utility called "ipscan" will get built if you build the ipfilter package from a download. With this, you can match on the first 16 bytes of a packet.

    A sample config would be:
    # Track ssh connections (i.e do nothing)
    #
    ssh : (), ("SSH-") = track else close
    #
    # Things which look like smtp to be tracked else closed.
    # Client can start with EHLO (ESMTP) or HELO (SMTP).
    #
    smtp : ("HELO ", "**??."), ("220 ", "....") = track else close
    #

    and then in ipfilter rules, use:
    pass out proto tcp from any to any port = 22 keep state scan ssh
    pass out proto tcp from any to any port = 25 keep state scan smtp

    At this point, it's more about ensuring that a particular kind of services appears to be initiated over a praticular port.

    Darren is still developing this new code to do more things. Eventually it will integrate differently into ipfilter rather than just via "keep state" rules.
  36. Can I have variables in my ipf.conf/ipnat.conf?
    As of IP Filter 4.x and later, you can set variables in your ipf.conf and ipnat.conf as follows:
    int_iface = "hme0";
    ext_iface = "iprb0";
    dmz_ip = "192.168.1.0/24";
    int_ip = "192.168.2.0/24";

    And then you can use those variables anywhere by prepending them with a dollar sign:
    pass in quick on $int_iface from $int_ip keep state

    Variables can contain other variables, and may also be referenced with ${variable} syntax.

  1. I have file transfer (FTP or HTTP) and if download speed is more then 100 KB/sec, connection breaks.
    Try adding flags S to each one of your TCP rules that has keep state in it.

    What might be happening is you're getting state entries for more than just the first packet of each connection and your state table is filling up. Previous versions of IPF did this when a packet arrived slightly out of window - it would not associate it with the state entry. The solution was to only add a state table entry for those packets with a SYN flag.

    This should no longer be required. However, many users will tell you it is a good security practice to use flags S with TCP rules anyway.
  2. I have to keep clearing the state table or IPF dies, why?
    See above.
  3. The default ipfboot script flushes all rules. Is this necessary every time you change some rule?
    This is done because depending on your ruleset, a new rule added may not be affective based on old rules, and also because the script reads in the entire ruleset anyway, so it will prevent duplicates. The script uses ipf -Fa which flushes rules but not state table entries. To flush state table entires use ipf -FS.
  4. Sending mail is horribly slow!
    You're probable blocking stuff to your ident port, 113. Change that rule so that you send a TCP reset:
    block return-rst in quick on ppp0 proto tcp from any to any port = 113
    Solaris users, see VII-1
  5. I can't connect to IRC.
    See above.
  6. When I try to load the LKM (if_ipl.o), I get "fr_checkp" (or other) unresolved symbols. (FreBSD, OpenBSD, SunOS)
    Make sure you have a kernel that has been correctly patched using the patches supplied with IP Filter, has "IPFILTER" in the config file and is the current kernel you are using.

    For FreeBSD/NetBSD, you will need to load if_ipl.o in an rc script (when securelevel is 0) or make sure that securelevel is -1 at runtime.
  7. When I do a make, it complains about -I(TOP).
    You're using the GNU version of make. Use the standard version of make that comes with your operating system.
  8. I'm using rdr for a webserver behind IPF and the world can see it just fine, but the internal machines can't surf to it via the external IP address.
    For the purposes of explaining this, lets take the following example:
     (internet)--->(if0[OS]if1)----|----(httpd on 192.168.0.2)
                                          |
                                          |----(browser on 192.168.0.3)
     
    if0 is some.isp.ip.addr
    if1 is 192.168.0.1

    I have a rdr on the external interface, written as:
    rdr if0 0.0.0.0/0 port 80 -> 192.168.0.2 port 80

    Now, IPFilter's rdr function does not natively support "bouncing" the connection (i.e. a packet coming in and leaving the same interface). The redirection happens only to packets coming in on the external interface. If you want to surf to 192.168.0.2 from the browser on 192.168.0.3, you can either do so directly via http://192.168.0.2/ (or by a CNAME in your DNS), or by using a "bounce" utility on the firewall to reflect inbound packets on if1 towards 192.168.0.2. By nature neither the OS nor ipf will do this for you. If you search the ipf archives you will find some bounce utilities. The golden RDR rule: rdr works *only* when the packet traverses the firewall (i.e. in one interface and out on another interface).
  9. Long ftp transfers and some other long single-connection sessions fail.
    You probably have an ipf.conf rule that looks something like:
    block return-rst in on ext-interface proto tcp all
    A rule like this will send an RST in response to an out-of-sequence ACK from the other end of a long ftp transfer, breaking the connection. Try replacing your rule with:
    block in on ext-interface proto tcp all
    block return-rst in on ext-interface proto tcp all flags S
    which will send RST only to SYN packets.
  10. I've set up to use the ftp-proxy in my ipnat.conf file, and it works fine from NAT'ed machines, but I can't ftp from the firewall machine unless I put a rule in ipf.conf to pass port 20/tcp in from remote machines. How do I get the ftp proxy to work from the firewall machine too?
    Add a second ftp proxy rule to your ipnat.conf:
    map ext-interface firewall-ip/32 -> firewall-ip/32 proxy port ftp ftp/tcp
  11. I'm using NAT and I can't ping the same machine on the internet from two different machines on my LAN at the same time.
    It isn't possible to map ports on ICMP packets. Hence, once a state table entry is set up to a particular target, only one machine can ping that target until the state table entry expires.

    For TCP and UDP, portmapping allows simultaneous connections to external targets from multiple machines in the LAN.

    There will supposedly be a workaround for this in the 4.x series.
  12. Keep state stops working - it won't make new states.
    There may be many reasons for this including that mentioned in question 1 of this section. However, there are other possibilities such as you have a very busy firewall and you're filling the state table. For this you have a few options: you can enlarge the state table, tweak some IPF values, or both. See the III-25 for details on enlarging the state table. Here are some values to tweak though.
    ipf.fr_tcpidletimeout=7200
    ipf.fr_tcpclosewait=120
    ipf.fr_tcplastack=120
    ipf.fr_tcptimeout=240
    ipf.fr_tcpclosed=60
    ipf.fr_tcphalfclosed=300
    ipf.fr_udptimeout=90
    ipf.fr_icmptimeout=35

    These values will be in very different places depending on your OS, such as /etc/rc.sysctl, /etc/sysctl.conf, or /etc/system.
  13. I'm using log body in my rules but the body of the packet isn't getting logged.
    You need to use the -b command line option to ipmon.
  14. I have an FTP server behind an IPF firewall, and I'm having problems serving passive FTP.
    The IPF How-To gives a good explanation of this. The client will try to connect to the server's internal IP address because that's the way passive FTP works: the server tells the client its IP address in the payload and the client connects to it.

    The solution is to explicitly tell your FTP server what to report as its IP address, and give it a range of ports to give out as well. You will then need to redirect traffic from those ports on your IPF box to the FTP server. Each FTP server is different, and you'll need to read the manual for your specific software, but to give an example, you can specificy this information in WU-FTPd's configuration file as follows: passive ports 0.0.0.0/0 32768 49151
    passive address your.pub.IP.addr 0.0.0.0/0

    At the time of writing, it's been reported that Microsoft IIS's FTP server is not capable of being configured this way. However, most Unix FTP servers should have an option for this somewhere.
  15. I can't seem to use round-robin load balancing with more than two hosts!
    If you use a rule like:
    rdr x.x.x.x port 80 -> y.y.y.1,y.y.y.2,y.y.y.3 port 80 tcp round-robin

    You will get an error like missing fields - 2nd port (,). This is because you can't put more than two hosts on a single round-robin line. You need to reformat it like this:
    rdr x.x.x.x port 80 -> y.y.y.1,y.y.y.2 port 80 tcp round-robin
    rdr x.x.x.x port 80 -> y.y.y.3 port 80 tcp round-robin

    or better yet like:
    rdr x.x.x.x port 80 -> y.y.y.1 port 80 tcp round-robin
    rdr x.x.x.x port 80 -> y.y.y.2 port 80 tcp round-robin
    rdr x.x.x.x port 80 -> y.y.y.3 port 80 tcp round-robin

    The two examples above act exactly the same, but notice that the second example is much easier to manage. If one of your servers goes down, it's very easy to take it out of the loop quickly with the second example. In the first example, if y.y.y.1 or y.y.y.2 goes down, and you take that line out, you loose two hosts.
  16. I'm having problems with ipnat (e.g. can't get proxies to work with bimap, or some other problem).
    When troubleshooting problems with ipnat remember that rules are process by network size. So a /32 rule will always be applied before a /24 rule, etc. Therefore a ruleset like:
    map ext-interface x.x.x.x/24 -> y.y.y.y/32 proxy port ftp ftp/tcp
    bimap ext-interface x.x.x.a/32 -> y.y.y.y/32
    bimap ext-interface x.x.x.b/32 -> y.y.y.y/32

    The proxy rule will never get matched. Therefore, if you need your bimap rules to be /32, then your proxy rule will need to be /32 to as well. Albeit a pain, the following is the only way to fix the problem:
    map ext-interface x.x.x.a/32 -> y.y.y.y/32 proxy port ftp ftp/tcp
    map ext-interface x.x.x.b/32 -> y.y.y.y/32 proxy port ftp ftp/tcp
    ...
    bimap ext-interface x.x.x.a/32 -> y.y.y.y/32
    bimap ext-interface x.x.x.b/32 -> y.y.y.y/32

    This way the proxy rules will match instead of getting skipped over.
  17. I'm using interface/32, 0/0 or 0/32, and it doesn't work!
    These special aliases do not work in IPF rules, or in IPNat rdr rules. They only work in IPNat's map and bimap rules.
  18. I stop/unload IPF, but it magically reloads itself!
    Chances are you are using IPF as a loadable kernel module. If not, then you want:
    ipf -D

    Which will disable the filter. However, if you are using a loadable kernel module, that option is not available to you. You can unload the module, but it will get reloaded the next time the device associated with IPF is accessed. So your best bet is to switch to an empty rulset:
    ipf -s

    That assumes your other ruleset actually is empty. Alternatively, you could unload the modules, and then mv the modules out of the way. This is a bit ugly, but it will work as a temporary way of keeping IPF out of the way for testing.
  19. I'm having problems connecting to Cisco VPNs through IPF NAT.
    The Cisco VPN Concentrators are often configured to expect a source port of 500 in addition to the destination port of 500. Since NAT, by default, changes the source port, this breaks. Add a line like so:
    map le0 from x.x.x.x/24 port=500 to ip.of.vpn/32 -> a.b.c.d/32

    to your ipnat.conf.
  20. I'm trying to remove entries from a pool and getting errors.
    If you try to remove an entry from an ippool and get remove_pool:SIOCLOOKUPDELNODE: No such file or directory, you're running an older version of IP Filter 4. This bug is fixed in recent versions.

    At the time of writing, this bug was in the IP Filter included with Solaris 10. If y ou are using this version your options are upgrade to the open-source version of IP Filter, or file a bug with Sun.

  1. I can only initiate x number of VPN connections to/from my NAT'd boxes! Why?
    First, are you using portmap in your ipnat (see III-6)? If not, then you will be limited to the number of external IP addresses you have to NAT to PER DESTINATION (see below for more info).
    However, some implementations of VPN will require a unique source address, and thus you will still only be able to have a number of NAT'd VPN sessions equal to the number of external IP address you have to NAT to PER DESTINATION (even if you use portmap).
    In other words, if you have 10.0.0.0/8 internal and you have only one external IP address 1.2.3.4, then you have only one VPN connection TO EACH VPN DESTINATION, so you could have hundreds of VPN sessions as long as they were to different destinations.
    But, if you have 10.0.0.0/8 internal and you have x.x.x.x/26 then you have have 64 VPN connections PER destination with as many destinations as you want.
  2. I'm having more VPN problems... ESP packets and UDP packets are not being mapped to the same IP ddress.
    From Darren: This will be because both packets match different rules. Matching the same rule packets will get the same address. I will include the ipsec proxy in 3.4.21 which will help with this.

  1. I have IPMon logging to syslog, but syslog doesn't log anything, why not?
    IPF logs as local0 so you'll want something to the effect of:
    local0.debug /var/log/ipf.log
    in your syslog.conf. NOTE: There has to be atleast one TAB in that line, not just spaces.
  2. I have IPMon logging to syslog, and I can't use ipmon -oI, why not?
    You can only use one of ipmon -oI and ipmon -s. Just do a tail -f filename where filename is whatever syslog logs ipf stuff to.
  3. When I start ipmon, it fails to start with an error.
    Are you running *BSD or SunOS? Check your kernel configuration, make sure you have "options IPFILTER_LOG"
  4. I'm getting wierd ipmon log entries, why?
    If you're seeing log entries like: Mar 22 13:45:45 gateway ipmon[94]: 13:45:44.302938 xl2 @0:1 S
    Feb 20 17:29:47 gateway ipmon[94]: 17:29:47.377435 xl2 @19:10241 L
    You've recently upgraded IP Filter on your FreeBSD system. FreeBSD installs ipmon in /sbin while IP Filter installs ipmon in /usr/sbin. Thus you are still using the old version of ipmon with your new version of IP Filter. Delete /sbin/ipmon.
  5. Can I make IPF log straight to a file instead of to syslog?
    Sure! Instead of invoking ipmon with the -s option, just specify a filename:
    ipmon filename

    Plus any other options you want. Alternatively, if you want to use syslog, don't specify a filename, and use -s.

  1. Why don't my return-rst's work?
    This is a "feature" of Solaris' STREAMS-based TCP/IP stack. Basically you have to add a rule allowing the TCP Reset to leave. So let's say that you want to return-rst on ident, port 113, so that sending mail doesn't give long delays, and IRC works:
    #return-rst for ident
    block return-rst in quick on ppp0 proto tcp from any to any port = 113
    pass out quick on ppp0 proto tcp from any port = 113 to any flags R/RSFUP
    The first rule just blocks with return-rst, the second rule allows packets out from port 113 with the RESET flag.
  2. It won't compile, something about /usr/ucb/cc.
    Sun has a compiler usually installed in /usr/ucb/cc. Unfortunately, it's a really expensive compiler that doesn't ship with Solaris by default. Fortunately, since Solaris 8, they've included gcc for you on the Solaris Companion CD (/opt/sfw), it's a package called SFWgcc. In Solaris 9 this is now on the main installation CDs and is in /usr/sfw.

    If you're using an older version of Solaris you can get gcc from SunFreeware.com.

    Note that you need to comment out the "For SUNWSpro" lines in the Makefile and uncomment the "for GCC" lines in order to compile with gcc.
  3. I'm using a 64-bit kernel, and when it tries to load ipf, it gets an error.
    You're most likely trying to use an IPF modules compiled as a 32-bit binary. You need to compile it as a 64-bit binary, so you must either use the cc with SUNWspro, or GCC 3.0 (see VII-5). GCC 2.x will NOT work. SUNWspro is available from Sun, you can get a demo license (please READ what you can and cannot do according to the demo license).
  4. How can I tell if I'm using a 32-bit or 64-bit kernel?
    Type isainfo -vk.
  5. Can I use gcc to make 64-bit Sparc kernel modules?
    GCC 2.x cannot make 64-bit executables, but GCC 3.x can. The following procedure for compiling a gcc 3x is provided by Aaron Jackson:
    # gunzip -c gcc-3.2.2.tar.gz | tar xvf -
    # mkdir objdir

    Note that objdir should NOT be in the source directory.
    # cd objdir
    # ../gcc-3.2.2/configure --enable-languages=c --prefix=INSTALL_PATH

    NOTE: INSTALL_PATH is where you want to install gcc. This should NOT be in the gcc source dir, objdir or any dir that contains an previous install of gcc.
    # make bootstrap
    # make install

    You should then be able to use this new GCC to compile a 64-bit version of IP Filter. In order to do this, you'll need to change the Makefile from:
    XARCH64="-m64 -mcmodel=medlow"

    to:
    XARCH64="-m64"
  6. What do I need to make a 64 bit Sparc kernel module?
    Sun's Forte Compiler can make 64 bit modules. This compiler is not standard with the OS, you have to buy it separately. However, there is a "try-and-buy" version which you can install, and use for a limited time. You can get this time limited version on cdrom or you can download it from Sun.com. Note that the download is very large. Please READ what you can and cannot do according to the demo license.
  7. My Sparc host is running in 64-bit mode, but I don't want to buy Sun's Forte compiler, nor do I want to install the try-and-buy. What can I do to get IPF up?
    Some generous individuals have made available precompiled IPF binaries for 64-bit machines. Try http://www.maraudingpirates.org/ipfilter/. You can also try using GCC 3.x (see VII-5).
  8. When I try to pkgadd the precompiled IPF package I downloaded, there are two sub-packages. What do I do?
    First select "ipfx", and install that subpackage. When pkgadd completes, rerun pkgadd and then install the "ipf" sub-package.
  9. Can I use IPF on Solaris as a Layer 2 bridge?
    No. IPF on Solaris only operates as a Layer 3 device (router). This means you need distinct subnets for each host interface.
  10. How can I tweak some of IPF's internal values at boot time?
    Solaris's /etc/system is consulted when booting, so you can modify IPF kernel parameters there, for example:
    
     *
     * ipf: adjust the default tcp timeouts downward so that
     *      idle (dead) and half closed states get killed off quicker.
     set ipf:fr_tcpidletimeout = 172800
     set ipf:fr_tcphalfclosed = 7200
     *
     * ipf: adjust the state table sizes so we have enough buckets.
     *      IPSTATE_MAX (=fr_statemax) should be ~70% of IPSTATE_SIZE
     *      IPSTATE_SIZE (=fr_statesize) has to be a prime number
     set ipf:fr_statemax = 7000
     set ipf:fr_statesize = 10009
     *
     * ipf: adjust the NAT table sizes so we have enough buckets.
     *      generally you have fewer than 127 rules in ipnat.conf
     *      so no need to waste memory for more.
     set ipf:ipf_nattable_sz = 10009
     set ipf:ipf_natrules_sz = 127
     set ipf:ipf_rdrrules_sz = 127
     *
     * note that the timers run "2 ticks to a second", so
     * for example, written below is the following:
     * set ipf:fr_tcpidletimeout = 172800
     * this sets the tcp idle connection timeout to
     * (172800/2) / 3600 = 24 hours.
     *
     
  11. How can I build a transparent proxy using Squid on Solaris 8?
    Solaris8 on Sparc is straightforward, however, doing this on Intel requires a tweak. Here's instructions for both platforms:
    • Get Squid-2.4STABLE1
    • Get and apply the 6 patches at http://www.squid-cache.org/Versions/v2/2.4/bugs/
      save these as the-patch-filename.patch
      $ for file in `ls *.patch`
      > do
      > echo "applying patch $file..."
      > patch -p0 < $file
      > done
    • Edit out the ipv6 struct as described in http://marc.theaimsgroup.com/?l=ipfilter&m=99557783205895&w=2

      Now for Solaris 8 on Sparc you are ready to go:
      # ./configure --enable-ipf-transparent ; make

      But for Solaris 8 on x86 you need two more steps...
    • First solve the va_args issue with gcc 2.95.2 on x86
      # diff -c src/client_side.c.orig src/client_side.c
       *** src/client_side.c.orig      Thu Jul 19 17:41:12 2001
      --- src/client_side.c Thu Jul 19 17:41:45 2001
      ***************
      *** 37,42 ****
      --- 37,45 ----
      #if IPF_TRANSPARENT #if HAVE_SYS_IOCTL_H + #if defined(va_start) /* dirty hack. sol7/8 x86 + gcc 2.95.2 */ + #define _SYS_VARARGS_H + #endif #include <sys/ioctl.h> #endif #include <netinet/tcp.h>
      #

    • Next solve the #define free issue (WTF?)
      # diff -c src/squid.h.orig src/squid.h
       *** src/squid.h.orig    Thu Jul 19 17:38:57 2001
       --- src/squid.h Thu Jul 19 17:40:26 2001
       ***************
       *** 403,411 ****
         #ifndef malloc
         #define malloc +
         #endif
       ! #ifndef free
       ! #define free +
       ! #endif
         #ifndef calloc
         #define calloc +
         #endif
       --- 403,411 ----
         #ifndef malloc
         #define malloc +
         #endif
       ! //#ifndef free
       ! //#define free +
       ! //#endif
         #ifndef calloc
         #define calloc +
         #endif
       
      #

    • Now finally for Solaris8 x86 you can
      # ./configure --enable-ipf-transparent ; make
    That should be it.
  12. Why can't I filter on the loopback interface, or virtual interfaces?
    The loopback interface on Solaris is a "fake" interface. You cannot filter it, nor can you snoop it. This is for performance reasons.

    Virtual interfaces in Solaris are very similar, to filter on them, use the physical interface instead.

    UPDATE: As of Solaris 10 Update 6, you can now do this. Set set interfcept_loopback true; in /etc/ipf.conf or /etc/ipf6.conf before all rules in the file. Thanks to Simon-Bernard Drolet.
  13. How do I make StateTop work on Solaris?
    There are three possiblities here: 1) using Solaris curses, 2) using ncurses from the Solaris Companion CD 3) using ncurses you compile yourself. For all three of these methods make sure the following is set (3.4.22 and on already has this):
    STATETOP_CFLAGS=-DSTATETOP

    Once that's done, pick one of the three methods above. The easiest way is to use Solaris curses. For that method, in the Makefile change:
    STATETOP_LIB=

    to say: STATETOP_LIB=-lcurses

    And that will do it.

    If you don't want to use Solaris curses and would prefer to use ncurses, install the ncurses package on the Solaris 8 Companion CD or from any other source of your choice and then change your STATETOP_INC line to read:
    STATETOP_INC=-L/opt/sfw/include
    and set:
    STATETOP_LIB=-L/opt/sfw/lib -R/opt/sfw/lib -lncurses

    Adjust accordingly if your ncurses libs/includes are in a different place.

    If you want to use ncurses but are using Solaris < 8, or just don't want to use the Companion CD verion of ncurses for some reason, then adjust the STATETOP_INC line to read:
    STATETOP_INC=-I/usr/local/include

    And set STATETOP_LIB to be:
    STATETOP_LIB=-L/usr/local/lib -R/usr/local/lib -lncurses

    Note that these are usual locations for the include and library files. If you installed them in other places, you'll need to specify the appropriate path's.

    NOTE: If you are using gcc 3.1+, you may need to uninstall either curses, or ncurses. Having both may cause conflicts during compile.
  14. I'm using sppp, IPSec, or some other IP Tunnel and I'm seeing random system crashes or CPU "thrash," what do I do?
    According to SunSolve many of these tunnels use a ton of space in the stack, so you should increase your stack size. To find out what it is do: echo 'lwp_default_stksize/D' | adb -k /dev/ksyms /dev/mem

    Solaris 2.6 and above in 32-bit mode default to 0x2000 while Soalris 7 and above in 64-bit mode default to 0x4000. Try doubling this number. To set it, add a line to /etc/system like this:
    set lwp_default_stksize=0x4000

    and reboot. You may also use decimal values (0x4000 = 16384 and 0x8000 = 32768). For more information on tuning kernel parameters click here, and for more information on lwp_default_stksize click here.

    Thanks to James McPherson and Darren for this information.
  15. I'm using a Sun system with an eri or bge interface, and after setting up NAT, ICMP passes through fine, but TCP doesn't. Why?
    Try disabling hardware checksumming. Edit /etc/system and add the line:
    set ip:dohwcksum=0

    and reboot. (Thanks to Ben Rosenblum and Hans Werner Strube).
  16. Aren't there any 64-bit IP Filter binaries for Solaris out there already?
    There are no official IP Filter binaries. However some kind people have made their binaries available for download. NOTE WELL: The following sites are NOT OFFICIAL. The binaries there are NOT supported by Darren Reed, Phil Dibowitz, OR the authors or owners of the sites (unless they state otherwise).
  17. Since upgrading to Solaris 9, I've been having wierd crashes. Is this IPF related? What can be done?
    From Darren Reed: "If you're using IPFilter on Solaris9, you might want to make sure you apply patch 112233-02 (or later) to fix a problem with the kernel attempting to prevent too much stack being used (and causing the system to crash.) This is particularly fatal when using IPFilter with ip.tun* and ESP+AH."
  18. Where are the instructions for installing on Solaris 7/8/9/etc.?
    Read INSTALL.Sol2 in the source directory. Solaris 7, 8, and 9 are often called 2.7, 2.8, and 2.9, and the same Sol2 file works for all of the releases.
  19. I'm getting /usr/include/ia32/sys/reg.h:300: error: parse error before "upad128_t" when I compile IPF, why?
    The problem is that the Solaris headers changed across updates of Solaris 9 and you are using a GCC from before the change on an updated system. (i.e. a GCC built for Solaris 9 <= 12/03 on Solaris 9 >= 4/04).

    You can either rebuild GCC for your version of the system (it works, even using a GCC built for the previous version), or see apply a fix to your headers: http://groups.yahoo.com/group/solarisx86/message/6617.
  20. In IPF 4.x, you can supposedly compile the rules into an LKM. How do you do this in Solaris?
    First you need to compile IPFilter to support it. Do this by uncommenting the followig line in the top level Makefile:
    #COMPIPF=-DIPFILTER_COMPILED

    Then build, and install the ipf LKM with that included. Then you need to build the ipf rules LKM. Probably the easiest way to do that is this:
    cd ip_fil4.1.1
    ipf -cc /etc/opt/ipf/ipf.conf
    make solaris

    You will then have to go searching for a file called "ipfrule" under the SunOS5 directory, somewhere - e.g.:
    SunOS5/sparc-5.6/ipfrule

    That is the LKM with the compiled filter rules. Copy this to /usr/kernel/drv to get it to load.
  21. In IPF 4.x, what is the performance gain in compiling your rulset into an LKM?
    From Darren:
    "Very significant. I did do some benchmarking of this, originally but I forget what the performance measurements were, now.

    "The improvements in performance come from two areas. The first is that the packet matching is now all in C, rather than using intermediate structures. The second is that rather than compare each field, one at a time, in each rule, it sorts the fields to be matched for each rule as an optimisation and only does comparisons when the matching is different."
  22. In IPF 4.x, I'm trying to build with gcc3 but it's not working!
    If you get an error like this:
    gcc -I. -g -I../.. -D_BSD_SOURCE -DSOLARIS2=9 -c ../../lib/debug.c -o debug.o
    ../../lib/debug.c: In function `debug':
    ../../lib/debug.c:30: error: `__builtin_va_alist' undeclared (first use in this function)
    ../../lib/debug.c:30: error: (Each undeclared identifier is reported only once
    ../../lib/debug.c:30: error: for each function it appears in.)
    *** Error code 1
    make: Fatal error: Command failed for target `debug.o'
    Current working directory /home/phil/build/ip_fil4.1.7/SunOS5/i386-5.9
    *** Error code 1
    make: Fatal error: Command failed for target `sunos5x86'
    Current working directory /home/phil/build/ip_fil4.1.7
    *** Error code 1
    make: Fatal error: Command failed for target `solaris'

    Then you're probably using gcc 3.3 or later, try 3.2.x. See the README for gcc 3.3 on var_args problems for details.
  23. How do I compile IPF 4.x with gcc?
    For pfil, do:
    CC=gcc make -f Makefile.gcc

    And for ipf, edit the Makefile and uncomment the right CC line, and then: make solaris
  24. How do I remove the IPF that comes with Solaris 10 and replace it with Darren's public-domain release?
    Jeff Earickson maintains a How-To on the subject. You can find it here.
  25. I installed IP Filter with Solaris 10, but there's no init scripts!
    Solaris 10 has deprecated the classic SYSV-style init scripts. Instead, you now need to use svcadm to control services. See Sun's Configuring Solaris IP Filter docs.


  1. Does IPF Support HP-UX?
    It does for 11.x. It does not work for 10.x. Read this.

  1. How can I set up bridging on FreeBSD?
    Recent versions of IPF support Bridging on FreeBSD. Flemming Laugaard shares this procedure for setting up Bridging. Set these in your kernel conf:
    options IPFILTER
    options IPFILTER_LOG
    options NMBCLUSTERS=65535
    options BRIDGE

    And then in sysctl.conf:
    net.link.ether.bridge=1
    net.link.ether.bridge_ipf=1
    net.link.ether.bridge_cfg=em1,em2
    net.inet.ip.forwarding=1

    Replacing em1 and em2 with your interfaces. Then put your rulset in place, and that should be it.

    Rene van Hoek points out that you'll also want to set "net.link.bridge.pfil_bridge" to disabled if you don't want all your states to be listed (and filtered) twice. See this thread for more detials.
  2. How can I get IP Filter to block by default?
    Set the kernel option: options IPFILTER_DEFAULT_BLOCK
    and recompile your kernel.
  3. What version of IPF is included in FreeBSD?
    Generally, the most recent IPF release will be found in both FreeBSD STABLE and FreeBSD CURRENT.
  4. Where do I find the sources?
    First you have to install the system sources, see the FreeBSD Handbook if you didn't choose to do this at install time. After installation, the IPF source will be in /usr/src/contrib/ipfilter/. Take care to ensure that comments in various documentation files apply to the particular version of FreeBSD you are running since IPF supports many FreeBSD versions and the operating system has changed significantly over the past few years.
  5. How do I (re)compile IPF (as an LKM) on FreeBSD?
    IPF is compiled and installed as part of the regular "make world" and "make kernel" procedures. See the FreeBSD Handbook for more on these.

    If you want to rebuild and reinstall only the ipf and ipnat shipped with the sources you have installed, do this:
    cd /usr/src/sbin/ipf
    make clean all install
    The ipl kernel module is (re)built as part of the kernel building procedure as described in the FreeBSD Handbook.

    Note that, if version skew between your running system and the source you have installed causes the compile to fail, it is best to upgrade the entire system with either a binary or source upgrade.
  6. How do I start ipfilter on a running system?
    First, create a set of filter rules appropriate to your application and save them in /etc/ipf.conf.

    Then load the ipl loadable kernel module (these are called "KLD"s in FreeBSD):
    kldload ipl
    Then load your rule set into ipfilter:
    ipf -Fa -f /etc/ipf.conf
  7. Don't I need to compile IPF into my kernel?
    No. IPF can be enabled after boot by loading the ipl loadable kernel module as above, or just by configuring it to load at startup as in the next answer.
  8. How do I configure FreeBSD to enable ipfilter at startup?
    First, create a set of filter rules appropriate to your application and save them them the file /etc/ipf.conf.

    Then, set the following variables in the /etc/rc.conf file:
    ipfilter_enable="YES"
    ipfilter_program="/sbin/ipf -Fa -f"
    ipfilter_rules="/etc/ipf.conf"
    ipfilter_flags=""
    and reboot. The startup scripts will load the ipl kernel module (if it is not already in the kernel) and pass the rule file to the ipf program.

    Note, however, if you are running FreeBSD 4.5+, the switches in ipfilter_program aren't needed, just put /sbin/ipf (Thanks to Adrian Portelli).
  9. Forget the loadable kernel module stuff, how do I do compile IPF into my kernel?
    Add the following lines to your custom kernel configuration file:
    
     options	IPFILTER
     options	IPFILTER_LOG
     
    then compile and install the kernel using the procedure described in the FreeBSD Handbook.
  10. How do I start ipnat on a running system?
    First, create a set of NAT rules appropriate to your application and save them in the file /etc/ipnat.conf.

    If not already loaded, load the ipl loadable kernel module:
    kldload ipl
    Then load your rule set:
    ipnat -f /etc/ipnat.conf
  11. How do I configure FreeBSD to enable ipnat at startup?
    First, create a set of NAT rules appropriate to your application and save them in the file /etc/ipnat.conf.

    Then set the following variables in the /etc/rc.conf file:
    ipnat_enable="YES"
    ipnat_program="/sbin/ipnat -CF -f"
    ipnat_rules="/etc/ipnat.conf"
    and reboot. The startup scripts will load the ipl kernel module (if it is not already in the kernel) and pass the rule file to the ipnat program.

    Note, however, if you are running FreeBSD 4.5+, the switches in ipnat_program aren't needed, just put /sbin/ipnat (Thanks to Adrian Portelli).
  12. How do I use the FreeBSD traffic shaper dummynet(4) with IPF?
    Dummynet is closely tied to ipfw(8) and is not supported by IPF. Darren suggests the use of the ALTQ traffic shaper instead. It is possible to use IPFW and IPF together, e.g. using IPFW for dummynet and IPF for filterning and NAT, see below.
  13. Which is better/faster/cool/etc., IPF of IPFW?
    IPF and IPFW are close enough in speed that it is not an issue. As far as which is better, this is something only you can answer. Each is different and appropriate for it's own application. Asking this indicates you have not done enough research into these two tools. Find out as much as you can about both, try both, and decide which is best for you.
  14. IPF and IPFW both have features I want to use, must I choose between them?
    No. You can run them both on a single machine. However, you must take care to ensure that one package's rules do not interfere with the other's. Note that the packages get access to rules in the order in which they were loaded, e.g. if IPFW is compiled in the kernel and IPF is loaded as a module, IPFW "sees" packets before IPF.
  15. Won't this slow down processing packets? By how much?
    Yes. How much depends much more on your particular situation than any intrinsic issues. People who have done this have reported that it does not meaningfully impact overall firewall performance.
  16. How can I tweak some of IPF's internal values?
    The sysctl(8) interface to the kernel allows setting some of the values on a running system under net.inet.ipf in the tree. You can use the /etc/rc.sysctl file to set these values at boot time.

    David lets us know that this values used in sysctl are in units of the slow timmer (500ms), so it's half-seconds, not seconds.
  17. Occasionally a server resends a TCP packet I've already sent an ACK to, and it causes the connection to die, why?
    According to FreeBSD problem-report kern/34801, ipfilter doesn't support RFC 1323 window size extensions. This became more problematic with the new net.inet.tcp.recvspace default of 65536 in FreeBSD 4.5+. You can drop recvspace down one to 65535 or to 32768 by using:
    sysctl net.inet.tcp.recvspace=32768 Dropping it merely one (to 65535) will do the trick, however having it a multiple of the page size, is supposedly better for performance. Thus you might try to use 32768.
  18. I just upgraded IPF and I'm getting errors on boot - but everything works fine.
    Installing IP Filter from source on FreeBSD can stick an extra ipfilter_flags="-E" in /etc/rc.conf which enables IP Filter for the second time thus generating a few errors. Taking out the above line will fix the problem.
  19. How do I get IPF working with IPv6 in FreeBSD?
    From FreeBSD 4.8 onwards, you can simply set ipv6_ipfilter_rules="/etc/ipf6.rules"

    in your rc.conf, and of course put rules in the file, and voila.

  1. How do I upgrade IP Filter on NetBSD?
    Upgrade IP Filter kernel source and build/install new binaries. In the IP Filter source directory:
    ./BSD/kupgrade
    make netbsd
    make install-bsd
    Recompile the kernel with new version of IP Filter:
    cd /sys/arch/`uname -m`/conf
    config mykernel
    cd ../compile/mykernel
    make depend
    make
    mv /netbsd /netbsd.old
    mv netbsd /netbsd
    Reboot, and you should be all set.
  2. How do I get IPF working with IPv6 in NetBSD?
    NetBSD 1.5.3 onwards support ipfilter with IPv6 out of the box. Simply place your rulesets in /etc/ipf6.conf and run /etc/rc.d/ipfilter reload to activate. You will also need to have IPv6 enabled in the kernel, the key directive is "options INET6". See NetBSD documentation on compiling a custom kernel if you are having problems with this.
  3. I'm getting messages about "no more space for rules" -- and I have a large ruleset. What do I do?
    You need to increase the VM kernel allocation. Compile a custom kernel and increase the vm.nkmempages value. The default is 4096, and doubling it should be more than ample for very large rulesets. Thanks to Gene.

  1. How can I get IP Filter to block by default?
    Set the kernel option: option IPFILTER_DEFAULT_BLOCK
    and recompile your kernel.
  2. How can I upgrade IP Filter on OpenBSD?
    If you are using OpenBSD 3.0 or higher, you will notice that IP Filter no longer comes with OpenBSD. To install IP Filter on OpenBSD 3.0+ see question 4. If you are using OpenBSD < 3.0 then read on.

    The following procedure assumes that you've at least configured your kernel. If you have not, check out http://www.oreillynet.com/pub/a/bsd/2000/10/31/OpenBSD.html for information on that.

    # gunzip -c ip_fil3.4.21.tar.gz | tar xf -
    # cd ip_fil3.4.21
    # BSD/kupgrade
    # make openbsd
    # make install-bsd
    # cd /sys/arch/foo/compile/kernel
    # make depend
    # make bsd
    # cp /bsd /bsd-original
    # cp bsd /bsd
    # reboot

    Note that the last two steps prior to rebooting make a backup copy of your current kernel to /bsd-original and then copy the new kernel into place.

    Pat Lougheed wrote a webpage on upgrading IP Filter in OpenBSD that goes more into depth. At the time, the procedure was a little uglier. As of now you can ignore steps 10-12 provided you're upgrading to atleast 3.4.21. You find his page here.
  3. So I've upgraded/installed IP Filter, why isn't it working?
    In order to run IP Filter you'll need to add the following to your /etc/rc.conf file:
    ipfilter=YES

    If you'd like to use IP NAT as well, then additionally add:
    ipnat=YES
  4. I just installed OpenBSD 3.x, where's IP Filter?
    OpenBSD no longer comes with IP Filter as of version 3.0. However, you can still use it! You have two options, 1, you can use the ISOs of OpenBSD3.x + IPF created by Darren Reed here (and also mirrored by locations listed here) or you can install IP Filter into your existing system. To install IP Filter into your existing OpenBSD 3.x system, simply follow the directions in the OpenBSD/README.3_0 file located in the IP filter 3.4.23 or later installation directory.
  5. I've heard that there's problems with filtering on OpenBSD bridges. What's the deal?
    In OpenBSD < 3.0, you can only filter in the in direction. However, in OpenBSD 3.0+, you can filter in both direction.

  1. Is there a linux port?
    IPF 4.x runs on Linux. Recent versions even run on 2.6.x kernels. Darren tests on SUSE 9.1 (as of this writing), but it should work reasonably well on any distro. There have been many confirmations of successfully running it on CentOS/RHEL 4.

    IPF 3.4 was succesfully ported to RedHat 4.2. It is expected to work reasonably well with any 2.0.31+ kernel, on a non-glibc system. It does not work with any other later release of Linux.
    Also note that, for Linux version 2.2.x see IP Chains, and for Linux version 2.4.x and above see IP Tables.
  2. So how do I get it running on my favorite distro?
    The following are HowTos that have been written for some distributions:

  1. Would you like me to register a domain for you?
    No, thank you. The current URL is easy, and all my big projects are in the phildev.net domain. I feel it's very easy to find right now, not only is it linked to from the IP Filter webpage, but if you plug IPF FAQ into google, this copy is the second hit.
  2. Would you like free hosting?
    No thanks. I'm set.
  3. How often is the FAQ updated?
    That depends on a lot of things. Sometimes a few times a month, sometimes once every few months. Usually an update gets in here once a month or so. However as of this update (01/11/02), I'm going to start revamping the HowTo, so there may not be updates as frequently. If an important question gets sent my way, I'll add it though.
  4. I have a usefull addition to the FAQ, what do I do?
    Email phil@ipom.com and make sure that "IPF-FAQ" is in beginning the subject line. I'd also appreciate it if the subject reflected what the contents of the email is such as "IPF_FAQ: IPF and FTP clarification" or "IPF-FAQ: Typo correction."
  5. I've submitted something for the FAQ, but it's not here, why not?
    There are many possibilities. I may be saving it because I feel it's better suited for an area in the HowTo. I may not feel it's valid for the FAQ. I may not have had time to update the FAQ. I try to respond to every submission and let you know what's going on though. Keep in mind I work full-time as a Sysadmin, I volunteer for many open-source projects, I run quite a few websites, am involved in local LUGs, I keep up the IPF FAQ, I have a girlfriend, etc., so it may take me time to update the FAQ.

Back to the main page.

Copyright © 2002 - 2007 Phil Dibowitz