Recently I was watching a Gizmodo journalist's videos about her experiment with blocking outgoing connections to Google, FB, Microsoft and Apple. I wonder if it is possible to modify MacOS's built in firewall to block IP ranges that I specify, like all known FB ranges, coinhive etc.?

I used to configure ipfw but this seems to have gone away. I'm running Mojave.

I do not want to run any closed-source program like Little Snitch to accomplish this. I just want to configure Apple's firewall if possible.

  • you can edit the hosts file to point any unwanted IPs to localhost. It's a pretty standard way to block a few IP ranges or domains. Commented Feb 5, 2019 at 13:49

1 Answer 1


It's not that complex with use of Pf firewall that's been ported from OpenBSD to MacOS quite a while ago. The whole ruleset could be as simple as:

# Block outgoing connections to IP ranges given in a table

# A persistent table to keep a list of IP networks for blocking
table <toBlockOut> persist { }

# local TCP/IP is always allowed
pass quick on lo0

# Attempts to send packets to IP networks kept in the table
# should never work
block out quick to <toBlockOut> no state

After you've saved that minimal ruleset into say pf-block-out.conf file, you can apply it with sudo pfctl -ef pf-block-out.conf — from Terminal. Similarly you can add or remove entries to the table w/o need to re-load the ruleset:

$ sudo pfctl -t toBlockOut -T show $ sudo pfctl -t toBlockOut -T del 1/1 addresses deleted.

You must log in to answer this question.

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