LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 07-08-2004, 03:32 PM   #1
wolfpeach
LQ Newbie
 
Registered: Jun 2004
Location: Oxford, UK
Distribution: Debian
Posts: 27

Rep: Reputation: 16
How to schedule a firewall to lockdown the system out of office hours?


I guess that there must be someone out there who has done this - just wondered how to go about it....

I have a samba server for a small windows network, running Debian woody. Its a very, minimal install, with no gui etc. The network is behind a NAT router which runs its own firewall, but I would like to configure the server to lock itself down overnight, just in case.

Could I do this with cron?

Are there any commands in iptables that would allow this to be done more simply?

Any pointers much appreciated!

Wolfpeach
x
 
Old 07-08-2004, 08:00 PM   #2
Capt_Caveman
Senior Member
 
Registered: Mar 2003
Distribution: Fedora
Posts: 3,658

Rep: Reputation: 69
There are really two ways to do this. You can use two firewall scripts and just have them run as cron jobs or you can use the netfilter extension "time" that is part of patch-o-matic. If you just plan on doing something fairly simple (like a set of normal rules and lockdown rules) then definitely go with cron. If you want really complex/overlapping timing of rules then go with patch-o-matic, though it does require patching the kernel and re-compiling
 
Old 07-13-2004, 09:30 AM   #3
wolfpeach
LQ Newbie
 
Registered: Jun 2004
Location: Oxford, UK
Distribution: Debian
Posts: 27

Original Poster
Rep: Reputation: 16
Capt Caveman - thank you!

Have been experimenting w cron, and although I seem to be able to use it to call an iptables script to lock the machine down, I cant get it to 'open up' again...

Here is the script I'm using for the 'nightshift' lockdown:

#######################
#!/bin/bash

iptables -A INPUT -j DROP
iptables -A OUTPUT -j DROP
#########################

and here is the one that is meant to clear it...

##########################
#!/bin/bash

iptables -D INPUT -j DROP
iptables -D OUTPUT -j DROP
########################

Called with the following lines in /etc/crontab:

# nightshift
45 0 * * * root /bin/nightshift
# firewall off
30 7 * * * root /bin/morning

The first script seems to work... the second doesnt... Both have been chmoded to make them executable.

Seems pretty basic to me... cant see why this is not working! Any ideas??
 
Old 07-13-2004, 10:45 AM   #4
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
your lockdown script is useless.
it appends a drop rule to the END of the chain, after all the ALLOW rules.

your lockdown script should be....

iptables -F
iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

and your script to return the network to a working order should be

iptables -F
(now re run the boot-script that sets your firewall, in slackware it would be '/etc/rc.d/rc.firewall restart' it may be different for debian, maybe rc.iptables or somthing similar, or maybe rc.network even, read the scripts, see which one is responcible for firewall setup)

Last edited by qwijibow; 07-13-2004 at 10:47 AM.
 
Old 07-20-2004, 10:37 AM   #5
wolfpeach
LQ Newbie
 
Registered: Jun 2004
Location: Oxford, UK
Distribution: Debian
Posts: 27

Original Poster
Rep: Reputation: 16
qwijibow - thanks for the info! Will give that a try...

You're right, my script was bad, but better to have a try at sth & stuff it up rather than go running to the gurus straight away
 
Old 07-20-2004, 10:43 AM   #6
qwijibow
LQ Guru
 
Registered: Apr 2003
Location: nottingham england
Distribution: Gentoo
Posts: 2,672

Rep: Reputation: 47
true...
maybe add an iptables -Z command to the start of the lackdown script (you shouldnt need it, but it cant hurt)
 
  


Reply



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
System backup takes several hours to complete lagu2653 SUSE / openSUSE 2 07-02-2005 05:03 AM
System going unresponsive every few hours rahaydenuk Linux - General 5 06-09-2005 02:11 AM
System goes to lunch after about 24 hours EwanG Linux - General 6 11-01-2004 07:27 PM
System slowing down after a few hours?? BajaNick Linux - General 23 04-24-2004 03:02 AM
Schedule a script every three hours dkochan Linux - General 1 03-07-2004 10:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 03:57 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration