I needed to do a webRTC test and to do this I needed to block an IP on my MAC, to do this you can do the following:

  • You need to edit the PacketFilter Configuration file or create a new file.
sudo vim /etc/pf.conf
  • Add the IP Address that you need to block:

block out from any to
  • Quit saving VIM and load the config file with the below command:
pfctl -e -f /etc/pf.conf
  • To disable the rule, just need to run:
pfctl -d

In case you need to block some DNS, you can do the following:

  • Open etc/hosts (need to be root):
sudo vi /private/etc/hosts
  • Add the next line to the file « dns.to.block»:       localhost broadcasthost       dns.to.block
  • save file «wq!» and test it