You can force an IP or subnet mask ban using a whitelist policy. This allows requests from all IPs or subnets, except specified IPs or subnet masks.
Note: To ban all IPs or subnets except specified values, select the blacklist option.
You can set an IP ban in two ways: in the customer portal or via the API.
1. Go to your list of resources under protection.
2. Click three dots on the line of the relevant resource and click Access Policy.
3. On the page that opens, type the IPs or subnet masks in the “Whitelist” field (click the plus button on the right to add more than one) and save changes.
That’s it. The specified IP will be banned for two hours.
Here’s an example of restricting a specific IP using an API request:
// @name Get client ddos resource
GET https://api.gcore.com/security/resources/<resource_id>
Authorization: Bearer {{token_client}}
Content-Type: application/json
> {%
client.global.set("resource", JSON.stringify(response.body.resource));
%}
###
// @name Add whitelist into ddos resources
< {%
let resource = client.global.get("resource");
resource = JSON.parse(resource);
resource["whitelists"] = [{"whitelist_data": "3.3.3.3"}];
resource = JSON.stringify(resource);
request.variables.set("resource_whitelist", resource);
%}
PUT https://api.gcore.com/security/resources/<resource_id>
Authorization: Bearer {{token_client}}
Content-Type: application/json
{{resource_whitelist}}
Was this article helpful?
Discover the all-in-one Web security solution by Gcore