Cloudflare DNS Manager
A TUI for managing Cloudflare DNS records programmatically.
Features
📋 List all DNS records in your Cloudflare zone
➕ Create new DNS records (A, AAAA, CNAME, MX, TXT, etc.)
✏️ Edit existing DNS records
🗑️ Delete DNS records
Prerequisites
- Rust 1.70+ (with Cargo)
- A Cloudflare account with a domain
- Cloudflare API Token with DNS edit permissions
Setup
1. Get Your Cloudflare API Token
- Go to Cloudflare API Tokens
- Click "Create Token"
- Use the "Edit zone DNS" template or create a custom token with:
- Permissions:
Zone→DNS→Edit - Zone Resources: Select your domain
- Permissions:
- Copy the token (you won't see it again!)
2. Get Your Zone ID
- Go to your Cloudflare dashboard
- Select your domain
- Scroll down to find the Zone ID in the API section
- Copy the Zone ID
3. Configure the Application
You have two options for configuration:
Option A: YAML Config File (Recommended for installed binary)
# Create config directory
# Download the example config file
# Edit with your credentials
Your config.yaml should look like:
cloudflare:
api_token: "your_api_token_here"
zone_id: "your_zone_id_here"
Option B: Environment File (For development)
# Copy the example environment file
# Edit .env and add your credentials
Your .env file should look like:
CLOUDFLARE_API_TOKEN=your_api_token_here
CLOUDFLARE_ZONE_ID=your_zone_id_here
Configuration Priority: The app checks in this order:
~/.config/cloudflaredns/config.yaml(YAML config file).envin current directory- Environment variables
4. Build and Run
# Build the application
# Run the application
Usage
Once the application starts, you'll see a terminal UI displaying your DNS records.
Controls
- L - List/refresh DNS records
- C - Create new DNS record
- D - Delete selected record
- Q - Quit the application
DNS Record Fields
When creating a record:
- Type: DNS record type (A, AAAA, CNAME, MX, TXT, SRV, CAA)
- Name: The record name (e.g.,
example.comorsub.example.com) - Content: IP address, hostname, or value
- TTL: Time-to-live in seconds (use
1for automatic) - Proxied: Route through Cloudflare's proxy (orange cloud)
Project Structure
cloudflare-dns/
├── src/
│ ├── main.rs # Entry point, configuration loading
│ ├── app.rs # iocraft TUI components and application logic
│ └── cloudflare.rs # Cloudflare API client
├── Cargo.toml # Rust dependencies
├── .env.example # Example environment file
└── README.md # This file
API Reference
The application uses the Cloudflare API v4:
- List DNS Records:
GET /zones/{zone_id}/dns_records - Create DNS Record:
POST /zones/{zone_id}/dns_records - Delete DNS Record:
DELETE /zones/{zone_id}/dns_records/{record_id}
See Cloudflare API Documentation for more details.
Security Notes
- ⚠️ Never commit your
.envfile - it contains your API token - The
.envfile is already in.gitignore - Use API tokens instead of Global API Keys for better security
- Tokens should have minimal required permissions
Troubleshooting
"CLOUDFLARE_API_TOKEN environment variable is not set"
Make sure you have a .env file in the project root with your API token, or export the variables manually:
"API request failed with status 403"
- Check that your API token has the correct permissions
- Verify the token is valid and not expired
- Ensure the token has access to the specified zone
"API request failed with status 404"
- Double-check your Zone ID is correct
- Verify the zone exists in your Cloudflare account
Development
# Run in development mode with hot reload
# Run tests
# Format code
# Lint code
License
MIT
Contributing
Pull requests are welcome! For major changes, please open an issue first to discuss what you would like to change.