Blocking from 9 to 5 with iptables and the time module

I've been using facebook a lot and it's usually open in a tab in my browser. Since I'm pretty easily distracted, I decided to do something about using facebook so much, so I could get some work done instead. Of course, I didn't want to block facebook at all times, since I like to stay in contact with friends. That's when I remembered the time module for iptables, the linux firewall.

I wrote a small shell script to block from 9 AM to 5 PM, every day:

# Note that the time module uses 24-hour time notation
iptables -A OUTPUT -d -p tcp -m time --timestart 09:00 --timestop 17:00 -j REJECT
iptables -A OUTPUT -d -p tcp -m time --timestart 09:00 --timestop 17:00 -j REJECT

This doesn't block access to all of Facebook's web servers, for instance, if you already are logged in to Facebook when the clock strikes 9, you will still receive the feed to your wall.

Of course, you can add other services as well, like slashdot. :-)

Could you use this little script yourself? Do you think facebook consumes too much of your time?

Written by Jannich Brendle tor 11 november 2010 In How to

tags: facebookproductivityfirewall

Related posts