Block Internet Connection through cocoa

Posted on

QUESTION :

In unix (ubuntu) we have iptables command, using which we can block Internet connection for one user. I want to know if there is any cocoa, carbon API using which a user can block his Internet connection for some time and later can re-connect it.

Note: I don’t have administrative privileges.

ANSWER :

Mac OS X 10.7 and later supports PF, an OpenBSD packet filter, which is almost certainly the right way to go about this.

The command-line interface to manage rules is pfctl. Likely you’ll need to invoke it as root, using Authorization Services. Here’s an answer which describes an NSTask-like wrapper which may help you.

PF does appear to support rules based on UIDs (look for the user parameter on the man page). If you need help configuring PF to do what you want, post at unix.se or apple.se.

Leave a Reply

Your email address will not be published. Required fields are marked *