Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question

migrated from stackoverflow.com Dec 31 '12 at 3:12

This question came from our site for professional and enthusiast programmers.

    
Do you want to disable WiFi or Ethernet connection via a script? –  Black Frog Dec 26 '12 at 20:58
    
If you can share would love to go through it :-) –  Miraaj Dec 27 '12 at 6:07
    
I have got one useful answer, not sure why I have been down voted :-( –  Miraaj Dec 28 '12 at 6:22
    
hi to people who are voting to close this question. I have found a similar question, related to .net, in SO stackoverflow.com/questions/2752711/…, which has got some useful answer to, and is not closed, so I am not sure why this question is voted to be closed. Please clarify. Again I think that it can bring some more useful answer if not closed. –  Miraaj Dec 28 '12 at 12:41
    
Because that example is running on Windows 7 which every user is also guarantee to be admin. On a Unix system, if you user wants to block internet, just disable the Wi-Fi or unplug the Ethernet cable. Simply. –  Black Frog Dec 28 '12 at 16:00

1 Answer 1

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.

share|improve this answer
    
thanx a lot for your useful answer.. will surely try it :-) –  Miraaj Dec 27 '12 at 6:08
    
I have one more question.. suppose a user is not having administrative privileges, and still he wants to block Internet Connection, only for his account then how can he do it? –  Miraaj Dec 27 '12 at 14:15
    
I think a helper program with admin privileges is the only way that would work. –  noa Dec 27 '12 at 14:33
    
ok...once again thanx :-) –  Miraaj Dec 28 '12 at 5:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.