Vyshakh Babji
Jul 2 · 2 min read

Recently, I was testing my WebRTC SDK for Disaster Recovery. I hit a roadblock when I wanted to block access to a few IP addresses on the go while running the DR tests. Fortunately, I found out the solution after digging through several stack overflow articles and reading through the manual for OSX terminal.

Here is how you could block certain IP addresses on the fly if you are ever hit with this roadblock.

  1. You need to edit the PacketFilter Configuration file. You can find this file in the path /etc/pf.conf
$ sudo vim /etc/pf.conf

2. Add the IP Address you need to block

block drop from any to [IP ADDRESS] Example:  ### block ip addressblock drop from any to 192.168.1.1

3. Quit VIM and load the config file by running the below command:

$ pfctl -e -f /etc/pf.conf
  • e is for enabling the packet filter
  • -f is for loading the rules contained in the file

You have successfully blocked access to the IP address.

4. Now, if you want to disable the rule, just run this:

$ pfctl -d

That’s it. Now you are ready to rock and roll :)

If you’re looking to learn more- then here are some other resources you can check out:

1. Block list table (IP, Mac, email, name, username)
2. How to edit the hosts to block IP address?
3. Why is IP to MAC address translation needed?
4. How to Block 100,000+ Individual IP addresses

For more awesome tutorials checkout our blog, or to learn more about the RingCentral Developers Program and start building cool integrations with voice, SMS, team messaging, meetings fax, and more — visit https://developers.ringcentral.com/

RingCentral Developers

Cloud Business Communications

Vyshakh Babji

Written by

RingCentral Developers

Cloud Business Communications

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade