blob: 4c0cae06f3d0138674ce83d4b455ddd401532dfd [file] [log] [blame]
Jan Engelhardtad326ef2007-09-23 15:17:42 +00001This matches if the packet arrival time/date is within a given range. All
Jan Engelhardtdb50b832011-05-23 18:38:09 +02002options are optional, but are ANDed when specified. All times are interpreted
3as UTC by default.
Jan Engelhardtad326ef2007-09-23 15:17:42 +00004.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +01005\fB\-\-datestart\fP \fIYYYY\fP[\fB\-\fP\fIMM\fP[\fB\-\fP\fIDD\fP[\fBT\fP\fIhh\fP[\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]]]]]
Jan Engelhardtad326ef2007-09-23 15:17:42 +00006.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +01007\fB\-\-datestop\fP \fIYYYY\fP[\fB\-\fP\fIMM\fP[\fB\-\fP\fIDD\fP[\fBT\fP\fIhh\fP[\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]]]]]
Jan Engelhardtad326ef2007-09-23 15:17:42 +00008Only match during the given time, which must be in ISO 8601 "T" notation.
9The possible time range is 1970-01-01T00:00:00 to 2038-01-19T04:17:07.
10.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010011If \-\-datestart or \-\-datestop are not specified, it will default to 1970-01-01
Jan Engelhardtad326ef2007-09-23 15:17:42 +000012and 2038-01-19, respectively.
13.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010014\fB\-\-timestart\fP \fIhh\fP\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]
Jan Engelhardtad326ef2007-09-23 15:17:42 +000015.TP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010016\fB\-\-timestop\fP \fIhh\fP\fB:\fP\fImm\fP[\fB:\fP\fIss\fP]
Jan Engelhardtad326ef2007-09-23 15:17:42 +000017Only match during the given daytime. The possible time range is 00:00:00 to
1823:59:59. Leading zeroes are allowed (e.g. "06:03") and correctly interpreted
19as base-10.
20.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020021[\fB!\fP] \fB\-\-monthdays\fP \fIday\fP[\fB,\fP\fIday\fP...]
Jan Engelhardtc6775d62010-07-23 21:23:05 +020022Only match on the given days of the month. Possible values are \fB1\fP
23to \fB31\fP. Note that specifying \fB31\fP will of course not match
Jan Engelhardtad326ef2007-09-23 15:17:42 +000024on months which do not have a 31st day; the same goes for 28- or 29-day
25February.
26.TP
Jan Engelhardtc6775d62010-07-23 21:23:05 +020027[\fB!\fP] \fB\-\-weekdays\fP \fIday\fP[\fB,\fP\fIday\fP...]
Jan Engelhardtc6775d62010-07-23 21:23:05 +020028Only match on the given weekdays. Possible values are \fBMon\fP, \fBTue\fP,
29\fBWed\fP, \fBThu\fP, \fBFri\fP, \fBSat\fP, \fBSun\fP, or values from \fB1\fP
30to \fB7\fP, respectively. You may also use two-character variants (\fBMo\fP,
31\fBTu\fP, etc.).
Jan Engelhardtad326ef2007-09-23 15:17:42 +000032.TP
Florian Westphal8d8896a2012-09-17 00:23:08 +000033\fB\-\-contiguous\fP
34When \fB\-\-timestop\fP is smaller than \fB\-\-timestart\fP value, match
35this as a single time period instead distinct intervals. See EXAMPLES.
36.TP
Jan Engelhardtdb50b832011-05-23 18:38:09 +020037\fB\-\-kerneltz\fP
38Use the kernel timezone instead of UTC to determine whether a packet meets the
39time regulations.
40.PP
41About kernel timezones: Linux keeps the system time in UTC, and always does so.
42On boot, system time is initialized from a referential time source. Where this
43time source has no timezone information, such as the x86 CMOS RTC, UTC will be
44assumed. If the time source is however not in UTC, userspace should provide the
45correct system time and timezone to the kernel once it has the information.
46.PP
47Local time is a feature on top of the (timezone independent) system time. Each
48process has its own idea of local time, specified via the TZ environment
49variable. The kernel also has its own timezone offset variable. The TZ
50userspace environment variable specifies how the UTC-based system time is
51displayed, e.g. when you run date(1), or what you see on your desktop clock.
52The TZ string may resolve to different offsets at different dates, which is
53what enables the automatic time-jumping in userspace. when DST changes. The
54kernel's timezone offset variable is used when it has to convert between
55non-UTC sources, such as FAT filesystems, to UTC (since the latter is what the
56rest of the system uses).
57.PP
58The caveat with the kernel timezone is that Linux distributions may ignore to
59set the kernel timezone, and instead only set the system time. Even if a
60particular distribution does set the timezone at boot, it is usually does not
61keep the kernel timezone offset - which is what changes on DST - up to date.
62ntpd will not touch the kernel timezone, so running it will not resolve the
63issue. As such, one may encounter a timezone that is always +0000, or one that
64is wrong half of the time of the year. As such, \fBusing \-\-kerneltz is highly
65discouraged.\fP
Jan Engelhardtad326ef2007-09-23 15:17:42 +000066.PP
67EXAMPLES. To match on weekends, use:
68.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010069\-m time \-\-weekdays Sa,Su
Jan Engelhardtad326ef2007-09-23 15:17:42 +000070.PP
71Or, to match (once) on a national holiday block:
72.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010073\-m time \-\-datestart 2007\-12\-24 \-\-datestop 2007\-12\-27
Jan Engelhardtad326ef2007-09-23 15:17:42 +000074.PP
75Since the stop time is actually inclusive, you would need the following stop
76time to not match the first second of the new day:
77.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010078\-m time \-\-datestart 2007\-01\-01T17:00 \-\-datestop 2007\-01\-01T23:59:59
Jan Engelhardtad326ef2007-09-23 15:17:42 +000079.PP
80During lunch hour:
81.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010082\-m time \-\-timestart 12:30 \-\-timestop 13:30
Jan Engelhardtad326ef2007-09-23 15:17:42 +000083.PP
84The fourth Friday in the month:
85.IP
Jan Engelhardtfea74bf2009-01-12 04:53:18 +010086\-m time \-\-weekdays Fr \-\-monthdays 22,23,24,25,26,27,28
Jan Engelhardtad326ef2007-09-23 15:17:42 +000087.PP
88(Note that this exploits a certain mathematical property. It is not possible to
89say "fourth Thursday OR fourth Friday" in one rule. It is possible with
90multiple rules, though.)
Florian Westphal8d8896a2012-09-17 00:23:08 +000091.PP
92Matching across days might not do what is expected. For instance,
93.IP
94\-m time \-\-weekdays Mo \-\-timestart 23:00 \-\-timestop 01:00
95Will match Monday, for one hour from midnight to 1 a.m., and then
96again for another hour from 23:00 onwards. If this is unwanted, e.g. if you
97would like 'match for two hours from Montay 23:00 onwards' you need to also specify
98the \-\-contiguous option in the example above.