I am running MacOS Mojave. I am wondering if there is an easy way to block an IP address.

For example, I can ping and telnet 53. Now, I want to block all access to so ping and telnet should both fail.

Btw, I’m not looking to use dns to this host. I can block it easily in /etc/hosts file but not all apps and services respect dns and hosts override. I’m looking for a non DNS block to implement.


Finally, I found a solution by using PF.

(1) edit PF configuration

sudo vim /etc/pf.conf

Append the following line to the file:

block drop from any to <IP Address>

For example: block drop from any to

(2) Load the config by running

sudo pfctl -f /etc/pf.conf

(3) Enable PF by running:

sudo pfctl -e

(*) If you want to disable PF, run:

sudo pfctl -d

You must log in to answer this question.

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