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.
- 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:
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/