Hi E71,
DNS blocking approach is possible as you can see from the following link:
http://www.deer-run.com/~hal/sysadmin/dns-advert.html
As you can see you need to edit /etc/named.conf file for the domains that you want to block. The automation that you are looking for is also possible using crontab. However, this will interrupt the internet connectivity.
I am talking about the following approach. Let say you decided to block the sites between 12 noon to 1400 hrs. Here is what you did:
1. Set up a cronjob to run at 12 that will stop bind.
2. Rename /etc/named.conf /etc/named.conf.original
3. Rename /etc/named.conf.edited (This is the edited file which contains blocked domains) to /etc/named.conf
4. Start bind
then at 1400 hrs another cronjob will run which will perform the following:
1. Stop bind.
2. Rename /etc/named.conf to /etc/named.conf.edited
3. Rename /etc/named.conf.original to /etc/named.conf
4. Start bind
As you can see that you have restart bind for the changes to take effect. This will interrupt internet and I don't think so that users will be happy about this.
I would suggest using iptables approach and run the cronjob against it. Here is how it will go:
1. cp /etc/sysconfig/iptables /etc/sysconfig/iptables.backup (This step is for backup)
2. Edit iptables rules to block the domains that you want.
3. cp /etc/sysconfig/iptables /etc/sysconfig/iptables.edited
Now you can switch using iptables file using cronjob as follows:
At 12 noon - cronjob
1. service iptables stop
2. mv /etc/sysconfig/iptables /etc/sysconfig/iptables.original
3. mv /etc/sysconfig/iptables.edited /etc/sysconfig/iptables
4. service iptables save
5. service iptables start
At 14 hrs - cronjob
1. service iptables stop
2. mv /etc/sysconfig/iptables /etc/sysconfig/iptables.edited
3. mv /etc/sysconfig/iptables.original /etc/sysconfig/iptables
4. service iptables save
5. service iptables start
Note: Though I have mentioned the step for backup. Make sure yourself that you take a backup to USB or at some other place of the configuration files that you will going to edit.