Skip to content
Browse the docs
guides

IP Whitelisting

Restrict tunnel access by IP address or CIDR range

Overview

IP whitelisting restricts who can access your tunnel. Only requests from allowed IP addresses will be proxied. Everyone else gets a 403 Forbidden response.

The page a visitor outside the allowlist sees: Error 403, Access denied, and a line saying their IP address is not on this tunnel's allowlist.
What a visitor outside the list sees. The request never reaches your machine.

PRO feature: IP whitelisting is available on the Pro plan.

Basic usage

Allow a single IP:

bash
zgrok http 3000 --allow-ip 203.0.113.50

Multiple IPs

Separate multiple IPs with commas:

bash
zgrok http 3000 --allow-ip 203.0.113.50,198.51.100.25

CIDR ranges

Use CIDR notation to allow entire subnets:

bash
zgrok http 3000 --allow-ip 203.0.113.0/24

This allows all IPs from 203.0.113.0 to 203.0.113.255.

Combining IPs and CIDRs

bash
zgrok http 3000 --allow-ip 203.0.113.50,198.51.100.0/24

Which address to list

List the visitor's public IPv4 address, the one their network shows to the internet. They can read it with:

bash
curl -4 https://ifconfig.me

Two kinds of entry are accepted and let nobody in:

  • Private ranges such as 10.0.0.0/8 or 192.168.0.0/16. A visitor arrives from their public address even when they sit on the same network as you.
  • IPv6 addresses. Tunnel addresses resolve to IPv4 only today, so a visitor reaches you over IPv4.

Everyone behind one office or VPN shares its public address, so one entry admits all of them. A home or mobile connection can change its address, and a visitor whose address changed gets a 403 until you restart the tunnel with the new one.

Use cases

  • Staging environments: only allow your team's office IPs
  • Client demos: restrict access to a specific client's network
  • Security testing: limit exposure during penetration testing

How it works

The zgrok server checks the source IP of each incoming request against your allowlist before proxying. Requests from non-allowed IPs receive a 403 Forbidden response and are never forwarded to your local server.

An entry that is not an address or a range is refused before the tunnel starts:

$ zgrok http 3000 --allow-ip office
error: invalid value 'office' for '--allow-ip <ALLOW_IP>': expected an IP address like 1.2.3.4 or a range like 10.0.0.0/24

On the Free plan the tunnel is refused as well, rather than started without the protection:

✗ Authentication failed: IP allowlisting (--allow-ip) requires the PRO plan. Upgrade at https://zgrok.io/pricing, or start the tunnel without --allow-ip.

An allowlist is one layer, not a login. To ask visitors for a password instead, use --basic-auth, also on Pro.

See also