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.
sudo vim /etc/pf.conf
  • Add the IP Address that you need to block:
block drop from any to [IP ADDRESS] 
Example:  ### block ip addressblock drop from any to 192.168.1.1
  • 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 «127.0.0.1 dns.to.block»:
127.0.0.1       localhost
255.255.255.255 broadcasthost
127.0.0.1       dns.to.block
  • save file «wq!» and test it