Skip to content

非公式 / UnofficialCloudflare, Inc. 非提携。アカウント情報は入力しないでください。Not affiliated with Cloudflare, Inc. Do not enter Cloudflare credentials here.Official docsこのサイトについてプライバシー

最初のネットワークポリシーを作成する

最終更新 Markdown で表示Agent セットアップ

IP アドレスやポートなどのセレクターでリクエストをフィルタし、ネットワークレベルのトラフィックを制御できます。ID プロバイダー と連携して、ID ベースのフィルタリングを適用することもできます。

新しいネットワークポリシーを作成するには:

  1. Cloudflare ダッシュボード ↗ で Zero Trust > Traffic policies > Firewall policies を開きます。

  2. Network タブで Add a network policy を選びます。

  3. ポリシーに名前を付けます。

  4. Traffic で、許可またはブロックするトラフィックを定義する論理式を組み立てます。

  5. 論理式に一致したトラフィックに対する Action を選びます。たとえば、デバイスのシリアル番号 のリストを使い、会社のデバイスから Cloudflare One Client で接続している場合にだけアプリケーションへアクセスできるようにできます。

    セレクター 演算子 値 論理 アクション
    SNI Domain is internalapp.com And Block
    Passed Device Posture Checks not in Device serial numbers
  6. Create policy を選びます。

  1. 次の権限を持つ API トークンを作成 します。

    種類 項目 権限
    Account Zero Trust Edit
  2. (任意)API の環境変数に アカウント ID と API トークンを含めます。

  3. Create a Zero Trust Gateway rule エンドポイントへ POST リクエストを送ります。たとえば、デバイスのシリアル番号 のリストを使い、会社のデバイスから Cloudflare One Client で接続している場合にだけアプリケーションへアクセスできるようにできます。

    Create a Zero Trust Gateway rulebash
    curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/gateway/rules" \
    	--request POST \
    	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
    	--json '{
    		"name": "Enforce device posture",
    		"description": "Ensure only devices in Zero Trust organization can connect to application",
    		"precedence": 0,
    		"enabled": true,
    		"action": "block",
    		"filters": [
    				"l4"
    		],
    		"traffic": "any(net.sni.domains[*] == \"internalapp.com\")",
    		"identity": "",
    		"device_posture": "not(any(device_posture.checks.passed[*] in {\"LIST_UUID\"}))"
    	}'
{
	 "success": true,
	 "errors": [],
	 "messages": []
}

API は、ポリシーの概要とリクエストの結果を返します。

詳細は ネットワークポリシー を参照してください。

役に立ちましたか?