11

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 – TheBro21 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. – tjt263 Sep 23 '15 at 19:58
8

There is a thing similar to iptables called pf.

Configuration

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 127.0.0.0/24 call localsub: sudo pfctl -t localsub -T add 127.0.0.0/24

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.


References:

You must log in to answer this question.

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