A command-line interface for managing Pi-hole v6 servers from your local computer.
- Colorized terminal output (auto-disabled when piped)
- View query statistics and blocking status
- See top permitted/blocked domains and top clients
- Enable/disable blocking with optional timer
- Check for Pi-hole updates and refresh gravity (blocklists)
- Configuration via file, environment variables, or CLI flags
- Python 3.10+
- Pi-hole v6
git clone https://github.com/willc/pihole-toolkit.git
cd pihole-toolkit
pip install -r requirements.txtOptionally add an alias to your shell profile:
echo "alias pihole='python3 $(pwd)/pihole_cli.py'" >> ~/.zshrcRun the interactive setup:
pihole configureThis saves your Pi-hole host and password to ~/.config/pihole-cli/config.json with restricted permissions (owner-only).
Alternatively, use environment variables:
export PIHOLE_HOST=10.0.0.100
export PIHOLE_PASSWORD=your_passwordOr pass credentials via CLI:
pihole --host 10.0.0.100 --password your_password statsPriority: CLI flags > environment variables > config file > defaults
pihole statsPi-hole Statistics
Total Queries 112,877
Queries Blocked 19,835
Percent Blocked 17.6%
Unique Domains 2,564
Queries Forwarded 6,852
Queries Cached 85,986
Clients (active) 32
Clients (total) 32
Gravity size 983,062
pihole statusShows blocking state, Pi-hole version, and whether updates are available.
pihole top -n 10Shows top 10 permitted and blocked domains.
pihole clients -n 10pihole enable
pihole disable
pihole disable -d 300 # Disable for 5 minutespihole update # Check FTL, Core, and Web versions
pihole update -g # Also refresh gravity (blocklists)pihole jsonpihole config| Command | Description |
|---|---|
stats |
Show query statistics |
status |
Show blocking status, version, and update availability |
top -n N |
Top N permitted and blocked domains |
clients -n N |
Top N clients by query count |
update |
Check for Pi-hole updates |
update -g |
Check for updates and refresh gravity |
json |
Raw JSON statistics |
enable |
Enable blocking |
disable [-d SEC] |
Disable blocking (optionally for N seconds) |
configure |
Interactive setup |
config |
Show current configuration |
MIT