Restrict access by IP address or country
Network rules decide which networks can reach a distribution. An allow list opens the site only to the IP ranges or countries you list. A block list refuses the ranges or countries you list and lets everyone else through. Rules accept IPv4 and IPv6 addresses and ranges (203.0.113.0/24, 2001:db8:1::/48) and two-letter country codes (JP).
A rule change is live at the edge within seconds. It does not create a deployment, and rolling back a deployment never adds or removes a rule. A visitor who is refused sees a 403 page in English and Japanese that shows their address and country, so they can send it to you.
1. Find your office's address
Open https://ip.edge.deca-dev.com/ from the office network. It shows the address and country Edge sees for you, which is exactly what the rules check:
{ "ip": "203.0.113.24", "country": "JP" }Edge reaches visitors over IPv4 and IPv6. A browser may use either, and may use IPv4 for one host and IPv6 for another. If your office has both, ask your network team for both ranges and add both, or some staff will be refused. The address is the one your traffic leaves the network from — a proxy or VPN, not each laptop.
2. Add the rules
On Security, choose the distribution. Under Network:
- Choose Add my address to allow the address shown, or pick Allow IP, paste your ranges (one per line or comma-separated) and choose Add.
- Leave Live site and preview links selected unless you want only one of them restricted. Preview links are restricted by default.
- Tick Apply to every site in this workspace to add the rule to every distribution in the workspace at once, including ones created later.
The same rules from an agent, the CLI, or the API:
Only allow visitors to acme-intranet from 203.0.113.0/24 and 2001:db8:1::/48. My address is 203.0.113.24.edge access network add acme-intranet 203.0.113.0/24 2001:db8:1::/48 --note "Tokyo office"curl -s -X POST \
https://api.edge.deca-dev.com/v1/distributions/6b1e2f0a-4c7d-4e2a-9b3f-2d8c5a7e1f90/access/network-rules \
-H "Authorization: Bearer $EDGE_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"rules": [
{ "kind": "ip_allow", "value": "203.0.113.0/24", "note": "Tokyo office" },
{ "kind": "ip_allow", "value": "2001:db8:1::/48", "note": "Tokyo office" }
],
"caller_ip": "203.0.113.24"
}'The agent runs edge_network_rule_create. The whole batch is added, or none of it is. A bare address is stored as a single-address range (/32 or /128).
Edge stops you locking yourself out. If the new allow list would not include your own address, the request fails with NETWORK_SELF_LOCKOUT and nothing changes. The console and the CLI pass your address automatically; an agent passes the one you give it. Repeat with Add anyway (--confirm, "confirm": true) only if you meant it.
For the whole workspace, omit the distribution: edge access network add --all-sites … or POST /v1/access/network-rules.
3. Block addresses or countries
Block rules work the same way with Block IP or Block country:
Block visitors from 198.51.100.0/24 on every site in this workspace.edge access network add --all-sites --block 198.51.100.0/24curl -s -X POST https://api.edge.deca-dev.com/v1/access/network-rules \
-H "Authorization: Bearer $EDGE_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "rules": [ { "kind": "ip_block", "value": "198.51.100.0/24" } ] }'A blocked visitor always gets 403, even one who could sign in. Country rules use country_allow and country_block (--country on the CLI).
4. Combine the rules with sign-in
A site can use network rules on their own, or together with sign-in in one of two ways. The With sign-in setting appears on Security once the distribution requires sign-in:
| You want | Sign-in | With sign-in |
|---|---|---|
| Only the office, no password | off | — |
| The office, and everyone there still signs in | on | Allowed networks must still sign in (enforce) |
| The office walks straight in; everyone else signs in | on | Allowed networks skip sign-in (login_fallback) |
On acme-intranet, let the office network skip sign-in and make everyone else sign in.edge access network mode acme-intranet login-fallbackcurl -s -X PUT \
https://api.edge.deca-dev.com/v1/distributions/6b1e2f0a-4c7d-4e2a-9b3f-2d8c5a7e1f90/access/network-mode \
-H "Authorization: Bearer $EDGE_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "mode": "login_fallback" }'The agent runs edge_network_mode_set. Only a visitor matched by an allow rule skips sign-in. Block rules still answer 403.
5. Test an address
Before you tell people the site is ready, check what a given address would get. On Security, type the address (and optionally a country) next to Test an address.
What would 198.51.100.7 get on acme-intranet?edge access network check acme-intranet 198.51.100.7curl -s -X POST \
https://api.edge.deca-dev.com/v1/distributions/6b1e2f0a-4c7d-4e2a-9b3f-2d8c5a7e1f90/access/network-check \
-H "Authorization: Bearer $EDGE_TOKEN" \
-H "Content-Type: application/json" \
-d '{ "ip": "198.51.100.7" }'{
"decision": "not_allowed",
"reason": "ip_not_listed",
"rule_id": null,
"network_mode": "enforce",
"outcome": "forbidden",
…
}The agent runs edge_network_check. outcome is what the visitor sees: forbidden, sign_in, skip_sign_in, or continue.
To undo a rule, choose Remove next to it, or run edge access network rm with the rule id (edge_network_rule_delete, DELETE /v1/access/network-rules/{id}). The site opens again within seconds.
Next
- Access control — every rule kind and the evaluation order
- Read request logs — find refused requests by IP or country
- Password-protect a distribution