Is there a way to prevent a specific process from creating any TCP/UDP connection under Linux? Just like the firewall under Windows, I need to block a process's any network activity.

  • If you are extremely paranoid you could move it into a vm, or container, I gather that you are looking for something more light weight though. – Zoredache Jan 7 '13 at 9:12

One possible way to do it is to run this process under specific user and DROP all traffic generated by this user id using a rule like:

iptables -A OUTPUT -m owner --uid-owner <user_id> -j DROP

For more info, see man iptables (section: owner).


The one which Khaled said, is one of very good way of doing this.

Also, if you are into Selinux, then SElinux will serve this purpose for you and can also provide some other additional security requirements which you might be looking for.

Would surely suggest to give it a try.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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