How to enable iptables rule for part of the day only

Solution Verified - Updated -

Issue

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.

Environment

Red Hat Enterprise Linux (RHEL)

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content