How to enable iptables rule for part of the day only

Solution Verified - Updated -


I’d like to know how we can set up a firewall rule for blocking specific packets with based on the time of day.
We would like to only enable a specific rule to block this traffic during particular period time, let’s say only between 12AM to 3AM.

I’m thinking about using crontab to schedule iptables command to enable the rule at 12AM and to disable the same rule at 3AM to allow the packets to go be accepted. The volume of traffic is very high and affecting our user experience and adding stress on the system.


Red Hat Enterprise Linux (RHEL)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In