Link to home
Start Free TrialLog in
Avatar of FireBall
FireBall

asked on

SH script for iptables add rule for x minutes

is there any sh script to add an iptables rule for x minutes ?
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

You can easily write one, for example if you want to open port 80 for 5 minutes:

#!/bin/bash
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
sleep 300
service iptables restart

Open in new window


The above will add a rule to open port 80, then wait 5 minutes and restart iptables to remove the rule.
Avatar of FireBall
FireBall

ASKER

that is ok what if you add one rule in 5 minutes what if you add an other rule after 1 minute ?
I am not really understanding your follow up question.
our system blocking ip addresses when it has anomality if we block an ip on
12:01and then if we block an other ip on 12:04 both ips will be released on 12:05
ASKER CERTIFIED SOLUTION
Avatar of Steven Vona
Steven Vona
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
yes that is good and what i need