LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices

Reply
 
Search this Thread
Old 03-18-2013, 03:04 AM   #1
neopandid
Member
 
Registered: Aug 2011
Location: Russia
Distribution: Debian
Posts: 31

Rep: Reputation: Disabled
IPtables - time based rules


This rule is working for me, but how can I make this rule work for a period of time:
I am on Debian and the solutions on the net is not working for me.

08:00-12:00
13:00-19:00

Code:
BLOCK_ALLOW="192.168.2.5 192.168.2.6"
iptables -N BLOCKED

iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range 192.168.3.100-192.168.3.199 --dport 22 -j BLOCKED
iptables -I FORWARD -m tcp -p tcp -m iprange --dst-range 192.168.3.100-192.168.3.199 --dport 3389 -j BLOCKED

for blck in $BLOCKED_ALLOW; do
    iptables -A BLOCKED -s $blck -j ACCEPT
done
iptables -A BLOCKED -j REJECT
Thanks in advance.

Last edited by neopandid; 03-18-2013 at 06:32 AM. Reason: typo
 
Old 03-18-2013, 05:28 AM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,225

Rep: Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021Reputation: 2021
1. 'BLCOKED' != 'BLOCKED' : spelling error

2. surely /etc/security/time.conf is the way to approach this?
 
Old 03-18-2013, 06:40 AM   #3
neopandid
Member
 
Registered: Aug 2011
Location: Russia
Distribution: Debian
Posts: 31

Original Poster
Rep: Reputation: Disabled
I corrected the typo.
But I didn't understand anything from /etc/security/time.conf
How can I make this IPtables rule work only between these hours:
08:00-12:00
13:00-19:00

Last edited by neopandid; 03-18-2013 at 06:42 AM.
 
Old 03-18-2013, 06:54 AM   #4
p2006.prashant
LQ Newbie
 
Registered: Dec 2007
Location: India
Distribution: Redhat Linux 5,6.2, Solaris
Posts: 16
Blog Entries: 1

Rep: Reputation: 5
Well, there is no such approach to do in timely manner but you only have to remember time and remove the rule manually once testing is done.
 
Old 03-18-2013, 07:22 AM   #5
neopandid
Member
 
Registered: Aug 2011
Location: Russia
Distribution: Debian
Posts: 31

Original Poster
Rep: Reputation: Disabled
Are you really serious about your solution?

"iptables RULE -m time --timestart TIME --timestop TIME --days DAYS -j ACTION"

when I add this to my iptables, rules are not working.

Last edited by neopandid; 03-18-2013 at 07:25 AM.
 
Old 03-18-2013, 09:30 AM   #6
BlackRider
Member
 
Registered: Aug 2011
Distribution: Slackware
Posts: 261

Rep: Reputation: 82
You may use a cron job to alter the Iptables rules at will depending on the time.
 
  


Reply

Tags
iptables


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
Restore iptables Rules that have been saved with iptables-save tiuz Linux - Security 4 08-14-2010 05:50 PM
[SOLVED] IPTABLES: Restrict Internet access based on time of day and MAC address ScottSmith Linux - Security 7 02-09-2010 02:25 AM
Using iptables for something very specific - bandwidth based on user/day/time koobi Linux - Networking 3 10-05-2007 02:29 AM
iptables 1.27a still loading rules after installing iptables 1.3.0 yawe_frek Linux - Software 1 06-07-2007 09:50 PM
RH8 - how to automatically run iptables rules shell script at boot time nu-B Linux - General 1 10-29-2003 08:38 PM


All times are GMT -5. The time now is 02:41 AM.

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