Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,34 @@ sidebar:
order: 3
---

import { APIRequest } from "~/components";
import { APIRequest, Tabs, TabItem } from "~/components";

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.
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.

## Time-based policy duration
There are two timed DNS policy options:

- [Policy duration](#policy-duration): The policy is active for a specific amount of time after being turned on (for example, 30 minutes).
- [Policy schedule](#policy-schedule): The policy is active during a recurring weekly schedule (for example, weekdays from 9 AM to 5 PM).

## Policy duration

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.

To set a duration for a DNS policy:

1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Gateway** > **Firewall policies** > **DNS**.
2. Create a new DNS policy or choose an existing policy and select **Edit**.
3. In **Configure policy settings**, turn on **Set a policy duration**.
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.
3. In **Apply durations and schedules**, turn on **Policy duration**.
4. In **Input method**, choose the type of duration:
- Choose _Duration_ and enter a specific amount of time until the policy turns off.
- Choose _Exact end date_ and enter a specific date and time in your account's time zone for the policy to turn off.
5. Select **Save policy**.

When a policy turns off, it will remain off until you turn it back on.

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.

### Reset a policy duration
### Reset a policy's duration

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**.

Expand All @@ -37,9 +44,44 @@ For policies with an exact end time, you can change the time before the policy t
4. In **Input method**, choose _Exact end date_. In **Date and time**, enter a new date and time for the policy to turn off.
5. Select **Save policy**.

## Scheduled policies
## Policy schedule

You can use Gateway to create a new DNS policy with a schedule or add a schedule to an existing policy.

<Tabs syncKey="dashPlusAPI">
<TabItem label="Dashboard">

1. In [Zero Trust](https://one.dash.cloudflare.com), go to **Gateway** > **Firewall policies** > **DNS**.
2. Create a new DNS policy or choose an existing policy and select **Edit**.
3. In **Apply durations and schedules**, turn on **Policy schedule**.
4. (Optional) In **Time Zone**, choose a time zone to apply the policy based on the time zone you select, regardless of the user's location. By default, Gateway will use the end user's time zone to apply the policy based on the local time of the user making the DNS query.
5. In **Schedule template**, choose a preset schedule, or choose _Custom schedule_ to define a custom schedule. You can choose up to three non-overlapping time ranges of 15 minute intervals.
6. Select **Save policy**.

</TabItem>
<TabItem label="API">

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:

<APIRequest
path="/accounts/{account_id}/gateway/rules"
method="POST"
json={{
action: "block",
name: "Block gambling sites on weekends",
traffic: 'any(dns.content_category[*] in {"Gambling"})',
schedule: {
sat: "08:00-17:00",
sun: "08:00-17:00",
timezone: "Europe/Paris",
},
}}
/>

</TabItem>
</Tabs>

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.
The policy's schedule will appear in Zero Trust under **Gateway** > **Firewall policies** > **DNS** when you select the policy.

### How Gateway determines time zone

Expand Down
Loading