Ubuntu – How to restrict user’s access to the internet for time intervals


I want that one of the users (not in the sudoers list) have Internet access from 14:00 until 16:00 and from 17:00 until 18:30. Is it possible? Can I set different time intervals for different week days?

Best Answer

You can use iptables's owner extension to block a user from accessing the net, like

 sudo iptables -A OUTPUT -m owner --uid-owner user_you_want_to_block -j REJECT

Now you can use cron to add or remove those rules (which may need a little bit of shell scripting if you already have some iptable rules or want it to to for different users at different times).