Skip to content
VPNDetection

Block traffic from hosting networks

Keep scripts and bots that run on cloud and hosting servers away from your forms and APIs, without blocking the people behind home and mobile connections.

Real people browse from home internet providers, offices and phones. Scrapers, credential-stuffing tools and spam bots mostly run on rented servers in datacenters. Refusing requests from hosting networks on sensitive endpoints removes much of that automated traffic with little effect on real visitors.

How it works

Every answer includes asn.type, the kind of network that announces the address: isp, hosting, education, government or business. When it is hosting, the address belongs to a hosting, cloud or content network. You refuse those requests on the endpoints you choose, such as login, sign-up, contact forms and your own API.

Before you begin

  • A list of the endpoints that real people use and bots target.
  • A list of the services you rely on that run in datacenters, such as your uptime monitoring or a partner's webhooks, so you can let them through.

1. Check the network type

Node.js
export async function fromHostingNetwork(ip) {
    const r = await client.lookup(ip);
    return r.asn?.type === 'hosting';
}

asn.type is on the free plan.

2. Refuse hosting networks on sensitive routes

With a framework package, a block condition refuses matching requests with 403 before they reach your handlers. A condition is written in the shape of an answer, so it can name asn.type directly:

js
app.use(['/login', '/signup', '/contact'], vpndetection({
    apiKey: process.env.VPNDETECTION_API_KEY,
    blockCondition: { asn: { type: 'hosting' } },
}));

3. Let your own services through

Requests from your uptime monitoring, your payment provider's webhooks or a partner's integration can come from datacenters too. Mount the middleware only on the routes that need it, as above, or exclude requests with the skip option:

js
vpndetection({
    apiKey: process.env.VPNDETECTION_API_KEY,
    blockCondition: { asn: { type: 'hosting' } },
    skip: (req) => req.path.startsWith('/webhooks/'),
});

4. Leave a way in

Some real people do reach you from hosting networks: developers on cloud desktops, people behind a company's cloud gateway, and some privacy services. Don't send them to a dead end. On a form, show a message with another way to reach you; on a login, ask for verification instead of refusing.

Hosting rules work best beside your other defenses. A rate limit catches automation that runs on home connections, and the hosting rule catches the large share that runs in datacenters.

5. Test it

Send a request to a protected route from a cloud server, such as a small virtual machine. It should be refused with 403. The same request from your laptop should succeed.

With a paid plan

asn.type describes the whole network, and some providers mix hosting and consumer space in one network. A paid plan adds is_hosting, which classifies the address itself and names the provider, and is_dcproxy for proxies that run in datacenters. Use { isHosting: true } in the block condition for a more precise rule.

Next steps

To screen accounts as they're created, see Screen VPN and proxy sign-ups.