Bug 55984 - [ipfw] [patch] time based firewalling support for ipfw2
Summary: [ipfw] [patch] time based firewalling support for ipfw2
Status: Closed Not Accepted
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 5.1-CURRENT
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ipfw (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-08-26 06:00 UTC by Christian S. Peron
Modified: 2018-02-02 22:21 UTC (History)
1 user (show)

See Also:


Attachments
file.diff (6.46 KB, patch)
2003-08-26 06:00 UTC, Christian S. Peron
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christian S. Peron 2003-08-26 06:00:36 UTC
I have enclosed a patch which allows ipfw2 to filter based on
the time of day. Mostly looking for approval/testers.
I have tested this patch but it may be missing something.

CAVEATS

As noted in the BUGS section of the ipfw.8 diff, if your system
shifts its time for daylight savings, firewall rules will have to
be refreshed, because the kernel is not aware of such things.

QUICK EXAMPLE

ipfw add allow ip from any to any times 09:00:00 17:00:00

Allow all IP traffic from 9:00 AM to 5:00 PM.

Thanks, enjoy!
Christian S.J. Peron

How-To-Repeat: N/A
Comment 1 Ceri Davies freebsd_committer freebsd_triage 2003-08-26 12:58:05 UTC
Responsible Changed
From-To: freebsd-bugs->ipfw

Assign this to the ipfw maintainers.
Comment 2 don 2003-09-11 03:03:59 UTC
suggest using 'time_second' instead of microtime() in ipfw_chk().

                        case O_TIME:
                                {
                                        u_long from, to, sum;
                                        long tzoff;
   
                                        tzoff = ((ipfw_insn_time
*)cmd)->tzoff;
                                        from = ((ipfw_insn_time
*)cmd)->from;
                                        to = ((ipfw_insn_time *)cmd)->to;
                                        sum = ipfw_calc_time_sum(time_second
+ t
zoff);
                                        match = (sum >= from  && sum <= to);
                                }
                                break;
Comment 3 Andrey V. Elsukov freebsd_committer freebsd_triage 2011-06-27 08:56:31 UTC
State Changed
From-To: open->suspended

Personally i recommend to use sets of rules and switch between them 
with cron(8). 
But maybe someone will find this feature interesting, so i suspend this PR.
Comment 4 Eugene Grosbein freebsd_committer freebsd_triage 2018-02-02 22:21:07 UTC
Suggested feature has not get attention for 15 years. Also, it is much more practical to manage time-based ipfw rules from userland (cron etc.) as ae@ noted because of daylight changes, time zone updates etc.