I have created a Study account which I use when doing anything school related work. It's purpose is to remove the distractions of my normal account, such as social media and news websites.

I know /etc/hosts can be edited to block certain domains from being accessed, but this is for all Users, and I don't want to have to switch in and out of Admin to change it every time I want to focus.

Is there any way to block these domains for specific Users or Groups?


You could use iptables to restrict the network access. The module ipt_owner enables you to match network packets by user id. A command like

iptables -A OUTPUT -m owner --uid-owner mike --dst www.google.com -j DROP

would prohibit user mike to access www.google.com.

As iptables really works with IP's instead of hostnames, this would create several rules, one for each IP of www.google.com. Downside is that you can't use iptables to limit whole domains, you would have to repeat that command for every single hostname you would like to restrict.

Be warned: If you're new to iptables you might have a hard time... ;)

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.