Where is iptables in MacOS X? I'm running Yosemite 10.10.5 (14F27) and it seems to be missing. If it's not actually native to OS X, what's the best way to install it for this operating system? If for some reason it's just not compatible, please suggest the relevant alternative, instead.

  • 1
    There is something called pf that is similar. There is a detailed documentation here
    – John K
    Sep 22 '15 at 12:34
  • 1
    @TheBro21 It's very short and very simple but, in a way, it's the answer I was looking for. Maybe you could expand or elaborate on it a bit, but if submitted as a proper answer, I would have no reason not to acknowledge / accept it it.
    – voices
    Sep 23 '15 at 19:58

There is a thing similar to iptables called pf.


The configuration file is located in the /etc/pf.conf

To get started, let’s look at the /etc/pf.conf configuration file that comprises pf:

scrub-anchor "com.apple/*"

nat-anchor "com.apple/*"

rdr-anchor "com.apple/*"

dummynet-anchor "com.apple/*"

anchor "com.apple/*"

load anchor "com.apple" from "/etc/pf.anchors/com.apple"

Here, you can see that pf is configured with a number of anchors. An anchor is a collection of rules and tables. Basically, the anchor file being loaded is /etc/pf.anchors/com.apple.

When you make change changes to your pf.conf, you can use this command to check the validness of the config:

sudo pfctl -v -n -f /etc/pf.conf

When testing, run in verbose mode with:

sudo pfctl -v /etc/pf.conf

If you set it up correctly, it should show something like pf enabled

can also add information on the fly. For example, to add a table of call localsub: sudo pfctl -t localsub -T add

Once the configuration is clear, you can run pfctl -q to turn on quiet mode to make things faster.

There is more information in more detail on the reference site.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .