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.
There is a thing similar to iptables called pf.
The configuration file is located in the
To get started, let’s look at the /etc/pf.conf configuration file that comprises pf:
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
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.