Welcome to the most active Linux Forum on the web.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 01-05-2012, 07:02 PM   #1
Registered: Feb 2011
Location: Asheville, NC, USA
Distribution: Fedora 19
Posts: 36
Blog Entries: 1

Rep: Reputation: 2
Blocking domains at specific times

I'm trying to block access to specific domains during certain times of day. I know that can be done in the firewall using iptables rules, but the list of blocked domains may need to evolve over time. It seems the hosts file would be best, but is there a way to specify an alternate hosts file to be used between certain hours?
Old 01-05-2012, 07:29 PM   #2
LQ Guru
Registered: Dec 2005
Location: Somewhere on the String
Distribution: Debian Wheezy (x86)
Posts: 6,094

Rep: Reputation: 273Reputation: 273Reputation: 273
You could write a script that could be run as a cronjob which replaces the hosts file twice a day.
Old 01-05-2012, 07:58 PM   #3
Registered: Feb 2011
Location: Asheville, NC, USA
Distribution: Fedora 19
Posts: 36

Original Poster
Blog Entries: 1

Rep: Reputation: 2
I actually thought about using crontab to copy a blocklist file to /etc/hosts.deny in the morning and a default in the evening, but when I tested the copy command
cp blocklist /etc/hosts.deny
both as a normal user and as root, nothing seemed to get copied. I checked with
less /etc/hosts.deny
. I'm new to this aspect of using Linux, but I've spent the day reading as much as I could find. Am I going about this wrong, or missing something?

EDIT: When I logged in this morning and tried again, the copy seemed to work fine, so that problem is solved. Don't know what caused it, but it's gone now.

Last edited by sabresong; 01-06-2012 at 07:21 AM. Reason: Something new has happened


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Blocking mail to specific domain from specific user orko Linux - Server 0 03-26-2009 03:18 PM
Allowing only certain hosts / domains while blocking the rest using IPTables? lolmannz Linux - Networking 2 10-19-2008 01:16 PM
Blocking mails from specific email addresses/domains in postfix jomy Linux - Networking 1 07-15-2008 09:32 PM
Limit Browser to specific domains whayford Linux - General 5 05-31-2006 08:49 AM
EXIM blocking domains n3r0 Debian 3 09-22-2004 09:23 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:23 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration