-
Read the WAF with GetWaf, and keep its
ETag: the WAF’sversion, in quotes. -
Add a rule at the top of
rules. Rules run in order, so a block placed above anallowrule blocks even what that rule allows:{ "name": "block-range", "action": "block", "mode": null, "rateLimit": null, "conditions": [ { "type": "ipSet", "negate": false, "cidrs": ["203.0.113.0/24", "2001:db8:1234::/48", "198.51.100.7"] } ] }One condition takes up to 1,000 addresses and CIDR blocks. A single address needs no prefix length.
-
Replace the WAF with UpdateWaf, sending the
ETaginIf-Match. A412 precondition_failedmeans it changed since you read it: read it again.
With the CLI, ezgh waf rules add reads the WAF, adds the rule and replaces it in one step:
ezgh waf rules add waf_8m2k4q6t9x1c --name block-range --action block --position 1 \
--ip-set 203.0.113.0/24 --ip-set 2001:db8:1234::/48 --ip-set 198.51.100.7/32Requests from those addresses are answered 403 within seconds on every load balancer the WAF is
attached to, unless the WAF is in log-only mode.
To block a whole network operator instead, use an asn condition. To block countries, use a
country condition. See Custom rules.
To allow only the range instead, set negate to true: the rule then blocks every address outside it.