IP リスト は、Cloudflare のカスタムリストの一種です。カスタムリストには、同じ種類の項目(IP アドレス、ホスト名、ASN)を 1 つ以上入れ、ルール式から参照できます。
IP リストはアカウント単位で定義し、ip.src と ip.dst フィールドとの照合に使えます。現在、Cloudflare Network Firewall(旧称 Magic Firewall)がこれらのリストで対応しているのは IPv4 アドレスだけで、IPv6 には対応していません。
この機能の使い方は次のとおりです。
1. 新しい IP リスト を作成する
例:
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/rules/lists \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '{
"name": "iplist",
"description": "This contains IPs that should be allowed.",
"kind": "ip"
}'次に リスト項目を作成 します。現在のリストに要素が追加されます。
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/rules/lists/{list_id}/items \
--header "X-Auth-Email: <EMAIL>" \
--header "X-Auth-Key: <API_KEY>" \
--header "Content-Type: application/json" \
--data '[
{"ip":"10.0.0.1"},
{"ip":"10.10.0.0/24"}
]'最後に、リストを参照する Network Firewall ルールを既存のルールセットへ追加します。
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/rulesets/{ruleset_id}/rules \
--header "Authorization: Bearer <API_TOKEN>" \
--header "Content-Type: application/json" \
--data '{
"action": "skip",
"action_parameters": {
"ruleset": "current"
},
"expression": "ip.src in $iplist",
"description": "Allowed IPs from iplist",
"enabled": true
}'マネージドリストを使ったルールを作成できます。マネージド IP リストは、Cloudflare が管理し、頻繁に更新する IP アドレスのリスト です。
これらのマネージドリストは、ルール作成時に Field ドロップダウンで IP destination address または IP source address を選び、Operator ドロップダウンで is in list または is not in list を選ぶと使えます。
例:
| Field | Operator | Value |
|---|---|---|
| IP destination address | is in list | Anonymizers |