Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

how to block a user from accessing internet in linux.

Is the following command correct.

iptables -A OUTPUT -p tcp --dport 80,443 -m owner --uid-owner $USERNAME -j DROP
share|improve this question

migrated from Nov 29 '09 at 23:17

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

should be on superuser.. – opc Nov 28 '09 at 11:20
yes .. I have the super user permissions, I want restrict internet access to some users for sometime. – Santhosh S Nov 28 '09 at 13:10 instead of – bmargulies Nov 28 '09 at 13:27
up vote 1 down vote accepted

I think that blocking http and https ports is not enough, however a user can use proxies or socks to by pass this restriction or may be some kinds of VPN.

The right way is to block all access to your users and permit all ports you need users to access.

share|improve this answer

there are some many other back-door ports that can be used besides 80 & 443... you should be using the "on network" vs "off network" strategy: block access to the IPs not part of the home LAN instead. I am not sure how to express this using iptables... I would have to google-it and so can you :-)

share|improve this answer

Your Answer


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.