コンテンツにスキップ

リゾルバポリシー

ベータ

デフォルトでは、Gatewayは解決のためにCloudflareのパブリックDNSリゾルバ1.1.1.1にDNSリクエストを送信します。エンタープライズユーザーは、代わりにGatewayポリシーを作成してDNSクエリをカスタムリゾルバにルーティングできます。

flowchart TD
    %% アクセシビリティ
    accTitle: GatewayがDNSクエリをルーティングする方法
    accDescr: エンドポイントからDNSおよびリゾルバポリシーを通じてユーザーに戻るDNSクエリのルーティング順序を説明するフローチャート。

    %% フローチャート
    user(["ユーザー"])-->endpoint[/"Gateway DNSエンドポイント"/]

    endpoint-->query["DNSポリシー (クエリ)"]

    query-->resolver["リゾルバポリシー"]

    resolver--"カスタムリゾルバにルーティング"-->response["DNSポリシー (レスポンス)"]

    response--"レスポンスを返す"-->user

Gatewayは、リゾルバのIPアドレスが重複していても、一致するポリシーに基づいてユーザーのトラフィックを構成されたDNSリゾルバにルーティングします。

ユースケース

プライベートネットワークサービスや内部リソースなど、公開されていないルーティングドメインへのアクセスが必要な場合は、リゾルバポリシーを使用できます。また、保護されたDNSサービスにアクセスする必要がある場合や、複数の場所のDNS管理を簡素化したい場合にもリゾルバポリシーを使用できます。

リゾルバがクライアントデバイスからのみ到達可能で、Cloudflareトンネル、Magic WANトンネル、または他のパブリックインターネット接続を介してGatewayからは到達できない場合は、デバイスのためにローカルドメインフォールバックを構成する必要があります。ローカルドメインフォールバックとリゾルバポリシーの両方が同じデバイスに対して構成されている場合、Cloudflareはクライアント側のローカルドメインフォールバックルールを最初に適用します。

リゾルバ接続

リゾルバポリシーはTCPおよびUDP接続をサポートしています。カスタムリゾルバは、IPv4またはIPv6を介してインターネットにポイントすることも、Magicトンネルなどのプライベートネットワークサービスにポイントすることもできます。ポリシーはデフォルトでポート53を使用します。ポリシー内でカスタマイズすることで、リゾルバが使用するポートを変更できます。

DNSファイアウォールを有効にすることで、権威あるネームサーバーをDDoS攻撃から保護できます。

Cloudflareトンネル

Cloudflareトンネルを介してCloudflareに接続されたプライベートリゾルバへの接続を有効にするには、cloudflaredのバージョン2023.10以降を使用してください。cloudflaredがリゾルバにUDPトラフィックをルーティングできるようにするには、QUICを介してトンネルを接続してください。

Cloudflareトンネルを使用してプライベートDNSリゾルバをCloudflareに接続する方法についての詳細は、プライベートDNSを参照してください。

Magic WAN

Magic WANを介してCloudflareに接続されたプライベートリゾルバへの接続を有効にするには、アカウントチームに連絡してください。

利用可能なDNSエンドポイント

リゾルバポリシーは、以下のDNSエンドポイントから解決のためのクエリをルーティングできます:

Gatewayは、エンドポイントに関係なく、クエリをフィルタリング、解決、およびログに記録します。

リゾルバポリシーの作成

  1. In Zero Trust, go to Gateway > Resolver policies.

  2. Select Add a policy.

  3. Create an expression for your desired traffic. For example, you can resolve a hostname for an internal service:

    SelectorOperatorValue
    Hostininternal.example.com

    Make sure your destination is not subject to Local Domain Fallback.

  4. In Select DNS resolver, choose Configure custom DNS resolvers.

  5. Enter the IP addresses of your custom DNS resolver.

  6. In Network, choose whether to route queries publicly (to the Internet) or privately (to a private network service).

  7. (Optional) Enter a custom port for each IP address.

  8. Select Create policy.

Custom resolvers are saved to your account for future use. You can add up to 10 IPv4 and 10 IPv6 addresses to a policy.

When a user’s query matches a resolver policy, Gateway will send the query to your listed resolvers in the following order:

  1. Public resolvers
  2. Private resolvers behind the default virtual network for your account
  3. Private resolvers behind a custom virtual network

Gateway will cache the fastest resolver for use in subsequent queries. Resolver priority is cached on a per user basis for each data center.

DNSポリシーの作成に関する詳細は、DNSポリシーを参照してください。

セレクタ

コンテンツカテゴリ

Use this selector to filter domains belonging to specific content categories.

UI nameAPI exampleEvaluation phase
Content Categoriesany(dns.content_category[*] in {1})Before DNS resolution

DNSリゾルバIP

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 nameAPI exampleEvaluation phase
DNS Resolver IPany(dns.resolved_ip[*] == 198.51.100.0)Before DNS resolution

DoHサブドメイン

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 nameAPI exampleEvaluation phase
DOH Subdomaindns.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 nameAPI exampleEvaluation phase
Domainany(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 nameAPI exampleEvaluation phase
Hostdns.fqdn == "test.example.com"Before DNS resolution

ロケーション

Use this selector to apply policies to a specific Gateway DNS location or set of locations.

UI nameAPI exampleEvaluation phase
Locationdns.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 nameAPI exampleEvaluation phase
Query Record Typedns.query_rtype == "TXT"Before DNS resolution

セキュリティカテゴリ

Use this selector to match domains (and optionally, IP addresses) belonging to specific security categories.

UI nameAPI exampleEvaluation phase
Security Categoriesany(dns.security_category[*] in {1})Before DNS resolution

ソース大陸

このセレクタを使用して、クエリが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:

ContinentCode
AfricaAF
AntarcticaAN
AsiaAS
EuropeEU
North AmericaNA
OceaniaOC
South AmericaSA
Tor networkT1
UI nameAPI exampleEvaluation phase
Source Continent IP Geolocationdns.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 nameAPI exampleEvaluation phase
Source Country IP Geolocationdns.src.geo.country == “RU”Before DNS resolution

ソースIP

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 nameAPI exampleEvaluation phase
Source IPdns.src_ip == 198.51.100.0Before 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.

OperatorMeaning
isequals the defined value
is notdoes not equal the defined value
inmatches at least one of the defined values
not indoes not match any of the defined values
in listin a pre-defined list of values
not in listnot in a pre-defined list of values
matches regexregex evaluates to true
does not match regexregex evaluates to false
greater thanexceeds the defined number
greater than or equal toexceeds or equals the defined number
less thanbelow the defined number
less than or equal tobelow 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.

Regular expressions

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:

SelectorOperatorValueAction
Hostmatches regex.\*whispersystems.org|.\*signal.orgBlock

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.

OperatorMeaning
Andmatch all of the conditions in the expression
Ormatch 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.