Skip to content

mixanemca/cdnscli

Repository files navigation

cdnscli

Go Version License Build Status Go Report Card

Note: This tool is under active development.

Cloud DNS CLI - manage DNS records across multiple providers!

What is it?

cdnscli is a powerful cross-platform utility for managing DNS records and zones across multiple DNS providers, written in Go. It provides convenient tools for both task automation and manual management through the terminal.

The utility supports two modes of operation:

  • Classic CLI: Perfect for use in scripts, automation, and executing standalone commands.
  • TUI (Text User Interface): An interactive text-based interface for more convenient management.

Key Features

  • Manage zones and resource records: add, modify, and delete them.
  • Retrieve detailed information about zones and records.
  • Search DNS records by various parameters.
  • Export and import resource record sets in a convenient format.
  • Easy-to-use interface, ideal for administrators and developers.

Supported Providers

Provider Authentication Features Status
Cloudflare API Token
API Key + Email
✅ Add/Update/Delete records
✅ List zones and records
✅ Search records
✅ Multiple accounts support
✅ Custom display names
✅ Fully Supported

Note: More providers are planned for future releases. If you'd like to see support for a specific provider, please open an issue.

Usage

cdnscli help

Receiving a token

Login to Cloudflare dash.
Go to My Account -> API Tokens and create a new token.

Configuration

Create a configuration file ~/.cdnscli.yaml in your home directory:

Tip: You can copy the example configuration file from the repository:

cp cdnscli.yaml.example ~/.cdnscli.yaml

Then edit the file with your credentials:

default-provider: cloudflare
client-timeout: 10s
output-format: text
debug: false

providers:
  cloudflare:
    type: cloudflare
    # display-name: Cloudflare  # Optional: custom display name for the provider (defaults to "Cloudflare" for cloudflare type)
    credentials:
      api-token: your-cloudflare-api-token-here
    # Alternative authentication (api-key + email):
    # credentials:
    #   api-key: your-api-key
    #   email: your-email@example.com

Multiple Providers

You can configure multiple providers of the same type (e.g., multiple Cloudflare accounts) by giving them different names:

default-provider: cf-production
client-timeout: 10s
output-format: text
debug: false

providers:
  cf-production:
    type: cloudflare
    display-name: Cloudflare Production  # Optional: custom display name
    credentials:
      api-token: production-account-token
  cf-staging:
    type: cloudflare
    display-name: Cloudflare Staging  # Optional: custom display name
    credentials:
      api-token: staging-account-token
  cf-personal:
    type: cloudflare
    # display-name is optional - if not specified, defaults to "Cloudflare"
    credentials:
      api-token: personal-account-token

To switch between providers, change the default-provider value in the config file, or use the default provider specified in the config.

You can also use environment variables instead of a config file:

export CLOUDFLARE_API_TOKEN=your-cloudflare-api-token-here
# or
export CDNSCLI_PROVIDERS_CLOUDFLARE_CREDENTIALS_API_TOKEN=your-cloudflare-api-token-here
# Note: environment variables use underscores, not dashes

Multiple Providers with Environment Variables

For multiple providers, you can use environment variables with the provider name:

# Set default provider
export CDNSCLI_DEFAULT_PROVIDER=cf-production

# Configure each provider
export CDNSCLI_PROVIDERS_CF_PRODUCTION_CREDENTIALS_API_TOKEN=production-account-token
export CDNSCLI_PROVIDERS_CF_STAGING_CREDENTIALS_API_TOKEN=staging-account-token
export CDNSCLI_PROVIDERS_CF_PERSONAL_CREDENTIALS_API_TOKEN=personal-account-token

Environment variables follow the pattern: CDNSCLI_PROVIDERS_<PROVIDER_NAME>_CREDENTIALS_<CREDENTIAL_KEY>

Examples

Managing Zones

List all zones:

cdnscli zone list

List zones with JSON output:

cdnscli zone list --output-format json

Get information about a specific zone:

cdnscli zone info example.com

Managing DNS Records

Add a new A record:

cdnscli rr add -t A -n www -z example.com -c 192.0.2.2

Add a CNAME record:

cdnscli rr add -t CNAME -n blog -z example.com -c example.github.io

Add an MX record with priority:

cdnscli rr add -t MX -n example.com -z example.com -c "10 mail.example.com"

Update an existing record:

cdnscli rr update -t A -n www -z example.com -c 192.0.2.3

Change a record (with full SOA example):

cdnscli rr change --name example.com --zone example.com --type SOA --content "ns1.example.com. admins.example.com. 1970010100 1800 900 604800 86400"

Delete a record:

cdnscli rr del -t A -n www -z example.com

List all records in a zone:

cdnscli rr list -z example.com

List records with JSON output:

cdnscli rr list -z example.com --output-format json

Get detailed information about a specific record:

cdnscli rr info -t A -n www -z example.com

Searching Records

Search for records by name:

cdnscli search -n www

Search for records by type:

cdnscli search -t A

Search for records in a specific zone:

cdnscli search -z example.com

Using Different Providers

If you have multiple providers configured, switch between them by changing default-provider in your config file, or specify the provider in commands (if supported).

Output Formats

Use JSON output for scripting:

cdnscli zone list --output-format json | jq '.[] | select(.name == "example.com")'

Use text output (default):

cdnscli zone list --output-format text

Installation

Quick Install (Recommended)

Download the latest release from GitHub Releases and extract the binary for your platform.

macOS (Intel):

curl -L https://github.com/mixanemca/cdnscli/releases/latest/download/cdnscli_Darwin_x86_64.tar.gz | tar -xz
sudo mv cdnscli /usr/local/bin/

macOS (Apple Silicon):

curl -L https://github.com/mixanemca/cdnscli/releases/latest/download/cdnscli_Darwin_arm64.tar.gz | tar -xz
sudo mv cdnscli /usr/local/bin/

Linux:

# For amd64
curl -L https://github.com/mixanemca/cdnscli/releases/latest/download/cdnscli_Linux_x86_64.tar.gz | tar -xz
# For arm64
curl -L https://github.com/mixanemca/cdnscli/releases/latest/download/cdnscli_Linux_arm64.tar.gz | tar -xz
sudo mv cdnscli /usr/local/bin/

Windows: Download the appropriate cdnscli_Windows_x86_64.zip or cdnscli_Windows_arm64.zip from the releases page and extract the cdnscli.exe file.

Homebrew (macOS/Linux)

Install using Homebrew:

brew install mixanemca/tap/cdnscli

Go Install

Install directly from source:

go install github.com/mixanemca/cdnscli@latest

Note: You can also install a specific version by replacing @latest with @v0.99.0 (or any other version tag).

Build from Source

git clone https://github.com/mixanemca/cdnscli.git
cd cdnscli
make
make install

Testing (WIP)

make test

License

Apache 2.0

About

Work with Cloud DNS easily from CLI!

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •