You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
By default, Cloudflare Gateway policies apply at all times when turned on. Gateway allows you to configure any DNS policy to activate for a specific amount of time, until an end time, or on a regular time interval.
10
+
By default, Cloudflare Gateway policies apply at all times when turned on. With timed DNS policies, you can control when DNS policies are active. You can configure a policy to be active during specific time periods or set the policy to expire after a certain duration.
11
11
12
-
## Time-based policy duration
12
+
There are two types of timed DNS policies:
13
13
14
-
You can use a time-based policy duration to set a specific time frame for the policy to turn on or configure an exact time for the policy to turn off.
15
-
16
-
To set a duration for a DNS policy:
14
+
-[Scheduled policies](#scheduled-policies): The policy is active during a recurring weekly schedule (for example, weekdays from 9 AM to 5 PM).
15
+
-[Duration policies](#duration-policies): The policy is active for a specific amount of time after being turned on (for example, 30 minutes).
17
16
18
-
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Gateway** > **Firewall policies** > **DNS**.
19
-
2. Create a new DNS policy or choose an existing policy and select **Edit**.
20
-
3. In **Configure policy settings**, turn on **Set a policy duration**.
21
-
4. In **Input method**, choose _Duration_ and enter a specific amount of time until the policy turns off or choose _Exact end date_ and enter a specific date and time in your account's time zone for the policy to turn off.
22
-
5. Select **Save policy**.
17
+
## Scheduled policies
23
18
24
-
When a policy turns off, it will remain off until you turn it back on.
19
+
You can use Gateway to create a new DNS policy with a schedule or add a schedule to an existing policy.
25
20
26
-
Policies with a set duration will retain their duration when turned off or on. For example, you can create a policy at 12:00 PM and set it to turn off after six hours. If you turn the policy off at 3:00 PM and turn it back on 4:00 PM, the policy will still turn off at 6:00 PM, six hours after the original time.
21
+
<TabssyncKey="dashPlusAPI">
22
+
<TabItemlabel="Dashboard">
27
23
28
-
### Reset a policy duration
24
+
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Gateway** > **Firewall policies** > **DNS**.
25
+
2. Create a new DNS policy or choose an existing policy and select **Edit**.
26
+
3. In **Time-based settings**, turn on **Policy schedule**.
27
+
4. Choose a preset schedule or choose _Custom_ to define a custom schedule. You can choose up to three non-overlapping time ranges of 15 minute intervals.
28
+
5. (Optional) Choose **Use user's timezone** to apply the policy based on the local time of the user making the DNS query, or choose **Enforce a specific timezone** to apply the policy based on the timezone you select, regardless of the user's location.
29
+
6. Select **Save policy**.
29
30
30
-
When a policy's time duration expires, you can turn the policy back on for the duration you originally configured. To reset a policy's duration, select the policy and choose **Reset policy duration**.
31
+
</TabItem>
32
+
<TabItemlabel="API">
31
33
32
-
For policies with an exact end time, you can change the time before the policy turns off. Once the policy reaches its exact end time, you will need to edit the policy and set a new end time. To set a new exact end time:
34
+
To schedule a policy with the API, use the [Create a Zero Trust Gateway rule endpoint](/api/resources/zero_trust/subresources/gateway/subresources/rules/methods/create/) with the `schedule` parameter set to your desired days of the week, times of day, and an optional time zone. For example:
33
35
34
-
1. Select the policy.
35
-
2. Choose **Edit**.
36
-
3. Turn on **Set a policy duration**.
37
-
4. In **Input method**, choose _Exact end date_. In **Date and time**, enter a new date and time for the policy to turn off.
38
-
5. Select **Save policy**.
36
+
<APIRequest
37
+
path="/accounts/{account_id}/gateway/rules"
38
+
method="POST"
39
+
json={{
40
+
action: "block",
41
+
name: "Block gambling sites on weekends",
42
+
traffic: 'any(dns.content_category[*] in {"Gambling"})',
43
+
schedule: {
44
+
sat: "08:00-17:00",
45
+
sun: "08:00-17:00",
46
+
timezone: "Europe/Paris",
47
+
},
48
+
}}
49
+
/>
39
50
40
-
## Scheduled policies
51
+
</TabItem>
52
+
</Tabs>
41
53
42
-
You can use the Gateway API to create a new DNS policy with a schedule or add a schedule to an existing policy. To schedule a policy, use the [Create a Zero Trust Gateway rule endpoint](/api/resources/zero_trust/subresources/gateway/subresources/rules/methods/create/) or [Update a Zero Trust Gateway rule endpoint](/api/resources/zero_trust/subresources/gateway/subresources/rules/methods/update/) with the `schedule` parameter set to your desired days of the week, times of day, and an optional time zone. The schedule will appear in Zero Trust under **Gateway** > **Firewall policies** > **DNS** when you select the policy.
54
+
The policy's schedule will appear in Zero Trust under **Gateway** > **Firewall policies** > **DNS** when you select the policy.
43
55
44
56
### How Gateway determines time zone
45
57
@@ -94,3 +106,31 @@ The following command creates a DNS policy to block `clockin.com` only on weeken
94
106
:::note
95
107
Gateway will not change the policy's `enabled` status when inside or outside of the time period specified. When enabled, Gateway activates or deactivates the policy according to its schedule. When disabled, the policy is always deactivated.
96
108
:::
109
+
110
+
## Duration policies
111
+
112
+
You can use a time-based policy duration to set a specific time frame for the policy to turn on or configure an exact time for the policy to turn off.
113
+
114
+
To set a duration for a DNS policy:
115
+
116
+
1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Gateway** > **Firewall policies** > **DNS**.
117
+
2. Create a new DNS policy or choose an existing policy and select **Edit**.
118
+
3. In **Time-based settings**, turn on **Policy duration**.
119
+
4. In **Input method**, choose _Duration_ and enter a specific amount of time until the policy turns off or choose _Exact end date_ and enter a specific date and time in your account's time zone for the policy to turn off.
120
+
5. Select **Save policy**.
121
+
122
+
When a policy turns off, it will remain off until you turn it back on.
123
+
124
+
Policies with a set duration will retain their duration when turned off or on. For example, you can create a policy at 12:00 PM and set it to turn off after six hours. If you turn the policy off at 3:00 PM and turn it back on 4:00 PM, the policy will still turn off at 6:00 PM, six hours after the original time.
125
+
126
+
### Reset a policy duration
127
+
128
+
When a policy's time duration expires, you can turn the policy back on for the duration you originally configured. To reset a policy's duration, select the policy and choose **Reset policy duration**.
129
+
130
+
For policies with an exact end time, you can change the time before the policy turns off. Once the policy reaches its exact end time, you will need to edit the policy and set a new end time. To set a new exact end time:
131
+
132
+
1. Select the policy.
133
+
2. Choose **Edit**.
134
+
3. Turn on **Set a policy duration**.
135
+
4. In **Input method**, choose _Exact end date_. In **Date and time**, enter a new date and time for the policy to turn off.
0 commit comments