Skip to content

Instantly share code, notes, and snippets.

@myriaglot
Created July 26, 2026 14:29
Show Gist options
  • Select an option

  • Save myriaglot/493524fc1210560a103b68b65305439c to your computer and use it in GitHub Desktop.

Select an option

Save myriaglot/493524fc1210560a103b68b65305439c to your computer and use it in GitHub Desktop.
allowlisting things

Method 2: Using flarectl (Cloudflare's CLI Tool)

If you prefer clean CLI syntax instead of writing raw curl commands, you can use flarectl, a CLI wrapper built by Cloudflare.

Step 1: Install flarectl

If you have Go installed:

go install github.com/cloudflare/cloudflare-go/cmd/flarectl@latest

Step 2: Configure Credentials

Set your environment variables in your terminal profile (~/.bashrc or ~/.zshrc):

export CF_API_TOKEN="YOUR_API_TOKEN"
export CF_ZONE_NAME="yourdomain.com"

Step 3: Run Firewall Commands

Allow/Whitelist an IP:

flarectl firewall create --zone="yourdomain.com" --mode="whitelist" --value="192.0.2.1" --notes="Whitelisted via CLI"

Block an IP:

flarectl firewall create --zone="yourdomain.com" --mode="block" --value="198.51.100.4" --notes="Malicious IP"

List active rules for the domain:

flarectl firewall list --zone="yourdomain.com"

Automating Dynamic IP Updates (e.g., Home ISP IP)

If you want to automatically allow your current public IP whenever it changes (like a Dynamic DNS script), save this quick bash script to run as a cron job:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment