DNSポリシー
ユーザーがGatewayにDNSリクエストを行うと、Gatewayはそのリクエストを組織のために設定したDNSポリシーと照合します。ドメインがブロックされたカテゴリに属していない場合、またはOverrideポリシーに一致する場合、ユーザーのクライアントはDNS解決を受け取り、HTTP接続を開始します。
DNSポリシーは、アクションとアクションの範囲を決定する論理式で構成されています。式を構築するには、セレクタとオペレーターを選択し、値フィールドに値または値の範囲を入力する必要があります。AndおよびOrの論理演算子を使用して、複数の条件を評価できます。
DNSポリシーを作成する際には、ネットワークを完全に保護するために必要なだけのセキュリティリスクカテゴリとコンテンツカテゴリを選択できます。ポリシーにより具体的なセレクタ(たとえば、ユーザーのメールやソースIP)が設定されていない限り、ポリシーは組織からGatewayに到達するすべてのDNSクエリに対して評価されます。
If a condition in an expression joins a query attribute (such as Source IP) and a response attribute (such as Resolved IP), then the condition will be evaluated when the response is received.
HTTPポリシーのアクションと同様に、DNSポリシーのアクションでは、特定の要素のセットに対して何をするかを選択できます。ポリシーごとに1つのアクションを割り当てることができます。
選択できるアクションタイプは次のとおりです:
API値: allow
利用可能なセレクタ
トラフィック
- アプリケーション
- 権威あるネームサーバーIP
- コンテンツカテゴリ
- DNS CNAME応答値
- DNS MX応答値
- DNS PTR応答値
- DNSリゾルバIP
- DNS TXT応答値
- DOHサブドメイン
- ドメイン
- ホスト
- インジケータフィード
- ロケーション
- クエリレコードタイプ
- 解決された大陸IPジオロケーション
- 解決された国IPジオロケーション
- 解決されたIP
- セキュリティカテゴリ
- ソース大陸IPジオロケーション
- ソース国IPジオロケーション
- ソースIP
アイデンティティ
許可アクションを持つポリシーは、セレクタおよび値フィールド内で指定した宛先にDNSクエリが到達することを許可します。たとえば、次の構成は、教育コンテンツカテゴリに属すると分類されるドメインにDNSクエリが到達することを許可します:
| セレクタ | オペレーター | 値 | アクション |
|---|---|---|---|
| コンテンツカテゴリ | in | 教育 | 許可 |
DNSSEC検証を無効にするを選択すると、GatewayはDNSレコードの暗号署名が検証できなくてもDNSクエリを解決します。DNSSEC検証の無効化は、検証失敗がDNSSEC設定の問題によるものであり、悪意のある攻撃によるものでないことがわかっている場合を除き、お勧めしません。
API値: block
利用可能なセレクタ
トラフィック
- アプリケーション
- 権威あるネームサーバーIP
- コンテンツカテゴリ
- DNS CNAME応答値
- DNS MX応答値
- DNS PTR応答値
- DNSリゾルバIP
- DNS TXT応答値
- DOHサブドメイン
- ドメイン
- ホスト
- インジケータフィード
- ロケーション
- クエリレコードタイプ
- 解決された大陸IPジオロケーション
- 解決された国IPジオロケーション
- 解決されたIP
- セキュリティカテゴリ
- ソース大陸IPジオロケーション
- ソース国IPジオロケーション
- ソースIP
アイデンティティ
ブロックアクションを持つポリシーは、セレクタおよび値フィールド内で指定した宛先にDNSクエリが到達することをブロックします。たとえば、次の構成は、成人向けテーマのコンテンツカテゴリに属すると分類されるドメインへのDNSクエリが到達することをブロックします:
| セレクタ | オペレーター | 値 | アクション |
|---|---|---|---|
| コンテンツカテゴリ | in | 成人向けテーマ | ブロック |
ブロックアクションを選択する際に、カスタムブロックページを表示をオンにすると、ブロックページでクエリに応答し、ブロックされたウェブサイトにアクセスしたユーザーに表示したいメッセージを指定できます。ブロックページが無効になっている場合、Gatewayはブロックされたクエリに対してIPv4宛先には0.0.0.0のAレコード、IPv6宛先には::のAAAAレコードで応答します。詳細については、カスタムブロックページの設定に関する専用のドキュメントを参照してください。
Feature availability
| WARP modes | Zero Trust plans ↗ |
|---|---|
| Enterprise |
| System | Availability | Minimum WARP version |
|---|---|---|
| Windows | ✅ | 2024.1.159.0 |
| macOS | ✅ | 2024.1.160.0 |
| Linux | ❌ | |
| iOS | ✅ | 1.3 |
| Android | ✅ | 1.4 |
| ChromeOS | ✅ | 1.4 |
Turn on Display block notification for WARP client to display notifications for Gateway block events. Blocked users will receive an operating system notification from the WARP client with a custom message you set. If you do not set a custom message, the WARP client will display a default message. Custom messages must be 100 characters or less.
Upon selecting the notification, WARP will direct your users to a block page. Optionally, you can direct users to a custom URL, such as an internal support form.
To turn on client notifications on macOS devices running DisplayLink software, you may have to allow system notifications when mirroring your display. For more information, refer to the macOS documentation ↗.
API値: override
利用可能なセレクタ
オーバーライドアクションは、DNS解決中またはその後に評価されるセレクタと一緒に使用することはできません。
トラフィック
- アプリケーション
- コンテンツカテゴリ
- DNSリゾルバIP
- DOHサブドメイン
- ドメイン
- ホスト
- ロケーション
- クエリレコードタイプ
- 解決された大陸IPジオロケーション
- 解決された国IPジオロケーション
- セキュリティカテゴリ
- ソース大陸IPジオロケーション
- ソース国IPジオロケーション
- ソースIP
アイデンティティ
オーバーライドアクションを持つポリシーは、特定のドメインに対するすべてのDNSクエリに別の宛先で応答することを許可します。たとえば、次のポリシーを使用して、www.example.comへのすべてのクエリに対してカスタム応答IP 1.2.3.4を提供できます:
| セレクタ | オペレーター | 値 | アクション | オーバーライドホスト名 |
|---|---|---|---|---|
| ホスト名 | is | www.example.com | オーバーライド | 1.2.3.4 |
API値: safesearch
利用可能なセレクタ
トラフィック
- アプリケーション
- コンテンツカテゴリ
- DNSリゾルバIP
- DOHサブドメイン
- ドメイン
- ホスト
- ロケーション
- クエリレコードタイプ
- 解決された大陸IPジオロケーション
- 解決された国IPジオロケーション
- セキュリティカテゴリ
- ソース大陸IPジオロケーション
- ソース国IPジオロケーション
- ソースIP
アイデンティティ
SafeSearchは、検索エンジンの機能で、明示的または攻撃的なコンテンツをフィルタリングするのに役立ちます。SafeSearchを有効にすると、検索エンジンは明示的または攻撃的なコンテンツをフィルタリングし、子供や職場に安全な検索結果を返します。
Cloudflare Gatewayを使用して、Google、Bing、Yandex、YouTube、DuckDuckGoなどの検索エンジンでSafeSearchを有効にできます。たとえば、GoogleのSafeSearchを有効にするには、次のポリシーを作成できます:
| セレクタ | オペレーター | 値 | アクション |
|---|---|---|---|
| ドメイン | is | google.com | 安全な検索 |
API値: ytrestricted
利用可能なセレクタ
トラフィック
- アプリケーション
- コンテンツカテゴリ
- DNSリゾルバIP
- DOHサブドメイン
- ドメイン
- ホスト
- ロケーション
- クエリレコードタイプ
- 解決された大陸IPジオロケーション
- 解決された国IPジオロケーション
- セキュリティカテゴリ
- ソース大陸IPジオロケーション
- ソース国IPジオロケーション
- ソースIP
アイデンティティ
同様に、YouTube制限アクションを選択することでYouTube制限モードを強制することができます。YouTube制限モードは、YouTubeに組み込まれた成人向けおよび攻撃的なコンテンツの自動フィルタです。YouTube制限モードを有効にするには、次のようなポリシーを設定できます:
| セレクタ | オペレーター | 値 | アクション |
|---|---|---|---|
| DNSドメイン | is | youtube.com | YouTube制限 |
この設定により、ユーザーはDNSを使用して攻撃的なサイトにアクセスできなくなります。
Gatewayは、次のセレクタまたは基準に対してDNSクエリを照合します:
You can apply DNS policies to a growing list of popular web applications. Refer to Application and app types for more information.
| UI name | API example | Evaluation phase |
|---|---|---|
| Application | any(app.ids[*] in {505}) | Before DNS resolution |
このセレクタを使用して、権威あるネームサーバーのIPアドレスに対して照合します。
| UI名 | API例 | 評価フェーズ |
|---|---|---|
| 権威あるネームサーバーIP | dns.authoritative_ns_ips == 198.51.100.0 | DNS解決中 |
Use this selector to filter domains belonging to specific content categories.
| UI name | API example | Evaluation phase |
|---|---|---|
| Content Categories | any(dns.content_category[*] in {1}) | Before DNS resolution |
When using an Allow or Block action, you can optionally block IP addresses or filter categories for CNAME records.
このセレクタを使用して、DNS応答をそのCNAMEレコードでフィルタリングします。
| UI名 | API例 | 評価フェーズ |
|---|---|---|
| DNS CNAME応答値 | any(dns.response.cname[*] in {"www.apple.com.edgekey.net"}) | DNS解決後 |
このセレクタを使用して、DNS応答をそのMXレコードでフィルタリングします。
| UI名 | API例 | 評価フェーズ |
|---|---|---|
| DNS MX応答値 | any(dns.response.mx[*] in {"gmail-smtp-in.l.google.com"}) | DNS解決後 |
このセレクタを使用して、DNS応答をそのPTRレコードでフィルタリングします。
| UI名 | API例 | 評価フェーズ |
|---|---|---|
| DNS PTR応答値 | any(dns.response.ptr[*] in {"255.2.0.192.in-addr.arpa"}) | DNS解決後 |
Use this selector to apply policies to DNS queries that arrived to your Gateway Resolver IP address aligned with a registered DNS location. For most Gateway customers, this is an IPv4 anycast address and policies created using this IPv4 address will apply to all DNS locations. However, each DNS location has a dedicated IPv6 address and some Gateway customers have been supplied with a dedicated IPv4 address — these both can be used to apply policies to specific registered DNS locations.
| UI name | API example | Evaluation phase |
|---|---|---|
| DNS Resolver IP | any(dns.resolved_ip[*] == 198.51.100.0) | Before DNS resolution |
このセレクタを使用して、DNS応答をそのTXTレコードでフィルタリングします。
| UI名 | API例 | 評価フェーズ |
|---|---|---|
| DNS TXT応答値 | any(dns.response.txt[*] in {"your_text"}) | DNS解決後 |
Use this selector to match against DNS queries that arrive via DNS-over-HTTPS (DoH) destined for the DoH endpoint configured for each DNS location. For example, you can use a DNS location with a DoH endpoint of abcdefg.cloudflare-gateway.com by choosing the DoH Subdomain selector and inputting a value of abcdefg.
| UI name | API example | Evaluation phase |
|---|---|---|
| DOH Subdomain | dns.doh_subdomain == "abcdefg" | Before DNS resolution |
Use this selector to match against a domain and all subdomains. For example, you can match example.com and its subdomains, such as www.example.com.
| UI name | API example | Evaluation phase |
|---|---|---|
| Domain | any(dns.domains[*] == "example.com") | Before DNS resolution |
Use this selector to match against only the hostname specified. For example, you can match test.example.com but not example.com or www.test.example.com.
| UI name | API example | Evaluation phase |
|---|---|---|
| Host | dns.fqdn == "test.example.com" | Before DNS resolution |
Use this selector to match against custom indicator feeds. To enable this selector, a designated third-party vendor must assign a custom indicator feed to your account.
| UI name | API example | Evaluation phase |
|---|---|---|
| Indicator Feeds | dns.indicator_feed | Before DNS resolution |
Use this selector to apply policies to a specific Gateway DNS location or set of locations.
| UI name | API example | Evaluation phase |
|---|---|---|
| Location | dns.location in {"location_uuid_1" "location_uuid_2"} | Before DNS resolution |
Use this selector to choose the DNS resource record type that you would like to apply policies against. For example, you can match A records for a domain but not MX records.
| UI name | API example | Evaluation phase |
|---|---|---|
| Query Record Type | dns.query_rtype == "TXT" | Before DNS resolution |
このセレクタを使用して、クエリが解決される大陸に基づいてフィルタリングします。ジオロケーションは、応答内のIPアドレスから決定されます。大陸を指定するには、その2文字コードを値フィールドに入力します:
- AF – アフリカ
- AN – 南極
- AS – アジア
- EU – ヨーロッパ
- NA – 北アメリカ
- OC – オセアニア
- SA – 南アメリカ
- T1 – Torネットワーク
| UI name | API example | Evaluation phase |
|---|---|---|
| 解決済み大陸IPジオロケーション | dns.dst.geo.continent == "EU" | DNS解決後 |
このセレクタを使用して、クエリが解決される国に基づいてフィルタリングします。ジオロケーションは、レスポンス内のIPアドレスから決定されます。国を指定するには、ValueフィールドにそのISO 3166-1 Alpha 2コード ↗を入力します。
| UI name | API example | Evaluation phase |
|---|---|---|
| 解決済み国IPジオロケーション | dns.dst.geo.country == "RU" | DNS解決後 |
このセレクタを使用して、クエリが解決されるIPアドレスに基づいてフィルタリングします。
| UI name | API example | Evaluation phase |
|---|---|---|
| 解決済みIP | any(dns.resolved_ips[*] == 198.51.100.0) | DNS解決後 |
Use this selector to match domains (and optionally, IP addresses) belonging to specific security categories.
| UI name | API example | Evaluation phase |
|---|---|---|
| Security Categories | any(dns.security_category[*] in {1}) | Before DNS resolution |
When using an Allow or Block action, you can optionally block IP addresses or filter categories for CNAME records.
このセレクタを使用して、クエリがGatewayに到達した大陸に基づいてフィルタリングします。
Geolocation is determined from the device’s public IP address (typically assigned by the user’s ISP). To specify a continent, enter its two-letter code into the Value field:
| Continent | Code |
|---|---|
| Africa | AF |
| Antarctica | AN |
| Asia | AS |
| Europe | EU |
| North America | NA |
| Oceania | OC |
| South America | SA |
| Tor network | T1 |
| UI name | API example | Evaluation phase |
|---|---|---|
| Source Continent IP Geolocation | dns.src.geo.continent == “North America” | Before DNS resolution |
このセレクタを使用して、クエリがGatewayに到達した国に基づいてフィルタリングします。
Geolocation is determined from the device’s public IP address (typically assigned by the user’s ISP). To specify a country, enter its ISO 3166-1 Alpha-2 code ↗ in the Value field.
| UI name | API example | Evaluation phase |
|---|---|---|
| Source Country IP Geolocation | dns.src.geo.country == “RU” | Before DNS resolution |
Use this selector to apply policies to the source IP address of DNS queries. For example, this could be the WAN IP address of the stub resolver used by your organization to send queries to Gateway.
| UI name | API example | Evaluation phase |
|---|---|---|
| Source IP | dns.src_ip == 198.51.100.0 | Before DNS resolution |
Identity-based selectors include:
- SAML Attributes
- User Email
- User Group Emails
- User Group IDs
- User Group Names
- User Name
To use identity-based selectors, enable Gateway with WARP in the Zero Trust WARP client and enroll your user in your organization. For more information, refer to Identity-based policies.
Comparison operators are the way Gateway matches traffic to a selector. When you choose a Selector in the dashboard policy builder, the Operator dropdown menu will display the available options for that selector.
| Operator | Meaning |
|---|---|
| is | equals the defined value |
| is not | does not equal the defined value |
| in | matches at least one of the defined values |
| not in | does not match any of the defined values |
| in list | in a pre-defined list of values |
| not in list | not in a pre-defined list of values |
| matches regex | regex evaluates to true |
| does not match regex | regex evaluates to false |
| greater than | exceeds the defined number |
| greater than or equal to | exceeds or equals the defined number |
| less than | below the defined number |
| less than or equal to | below or equals the defined number |
In the Value field, you can input a single value when using an equality comparison operator (such as is) or multiple values when using a containment comparison operator (such as in). Additionally, you can use regular expressions (or regex) to specify a range of values for supported selectors.
Gateway uses Rust to evaluate regular expressions. The Rust implementation is slightly different than regex libraries used elsewhere. For more information, refer to our guide for Wildcards. To evaluate if your regex matches, you can use Rustexp ↗.
If you want to match multiple values, you can use the pipe symbol (|) as an OR operator. In Gateway, you do not need to use an escape character (\) before the pipe symbol. For example, the following policy blocks requests to two hostnames if either appears in a request header:
| Selector | Operator | Value | Action |
|---|---|---|---|
| Host | matches regex | .\*whispersystems.org|.\*signal.org | Block |
In addition to regular expressions, you can use logical operators to match multiple values.
To evaluate multiple conditions in an expression, select the And logical operator. These expressions can be compared further with the Or logical operator.
| Operator | Meaning |
|---|---|
| And | match all of the conditions in the expression |
| Or | match any of the conditions in the expression |
The Or operator will only work with conditions in the same expression group. For example, you cannot compare conditions in Traffic with conditions in Identity.
Gatewayは、iCloud Private Relay ↗などのサードパーティVPNや他のインターネットフィルタリングソフトウェアを通じて送信されたトラフィックを適切にフィルタリングしません。DNSポリシーがトラフィックに適用されることを確実にするために、Gatewayに干渉する可能性のあるソフトウェアを制限することをお勧めします。
Magic WANを通じて転送されたクエリにDNSポリシーを適用するには、組織のDNSリゾルバをIPv6、DoH、またはDoTエンドポイントにポイントするか、専用のリゾルバIPv4アドレスをリクエストする必要があります。詳細については、DNSリゾルバIPとホスト名を参照してください。