Skip to content

init

The init command runs an interactive wizard to configure NextDNS Blocker for the first time.

Terminal window
nextdns-blocker init [OPTIONS]
OptionDescription
--config-dir PATHConfig directory (default: XDG config dir)
--non-interactiveUse environment variables instead of prompts

By default, init runs an interactive wizard that guides you through the configuration process.

  1. Prompts for your NextDNS API key
  2. Prompts for your NextDNS Profile ID
  3. Validates credentials by testing API connectivity
  4. Creates the configuration files
Terminal window
$ nextdns-blocker init
NextDNS Blocker Setup
━━━━━━━━━━━━━━━━━━━━━
Enter your NextDNS API key: ********
Enter your NextDNS Profile ID: abc123
Validating credentials...
API connection successful
Creating configuration files...
Created ~/.config/nextdns-blocker/.env
Created ~/.config/nextdns-blocker/config.json
Setup complete!
Next steps:
1. Edit your blocklist: nextdns-blocker config edit
2. Install the scheduler: nextdns-blocker watchdog install
3. Check status: nextdns-blocker status

For CI/CD pipelines or automated deployments, use --non-interactive mode with environment variables.

VariableDescription
NEXTDNS_API_KEYYour NextDNS API key
NEXTDNS_PROFILE_IDYour NextDNS Profile ID
Terminal window
export NEXTDNS_API_KEY="your-api-key"
export NEXTDNS_PROFILE_ID="abc123"
nextdns-blocker init --non-interactive
ENV NEXTDNS_API_KEY=your-api-key
ENV NEXTDNS_PROFILE_ID=abc123
RUN nextdns-blocker init --non-interactive

You can specify a custom configuration directory:

Terminal window
nextdns-blocker init --config-dir /path/to/config

This is useful for:

  • Testing configurations
  • Running multiple instances
  • Non-standard deployments

The init command creates the following files:

FileDescription
.envAPI credentials (secured with 600 permissions)
config.jsonDomain blocklist and settings
PlatformDefault Path
macOS/Linux~/.config/nextdns-blocker/
Windows%APPDATA%\nextdns-blocker\

If you run init when configuration already exists:

Terminal window
$ nextdns-blocker init
Configuration already exists at ~/.config/nextdns-blocker
Overwrite existing configuration? [y/N]: n
Cancelled.

To force reconfiguration:

Terminal window
$ nextdns-blocker init
Overwrite existing configuration? [y/N]: y
# Proceeds with setup wizard...
  1. Go to my.nextdns.io
  2. Navigate to AccountAPI
  3. Click Create API key
  4. Copy the key (it’s only shown once)
  1. Go to my.nextdns.io
  2. Select your configuration profile
  3. The Profile ID is shown in the URL: my.nextdns.io/abc123/...
  4. It’s also displayed in the Setup tab

Ensure your API key is correct and hasn’t been revoked. Create a new API key at my.nextdns.io.

The Profile ID should be a short alphanumeric string (e.g., abc123). Check your NextDNS dashboard.

The config directory might have incorrect permissions:

Terminal window
chmod 700 ~/.config/nextdns-blocker

Check your internet connection and ensure you can reach api.nextdns.io.

After running init:

  1. Edit your blocklist:

    Terminal window
    nextdns-blocker config edit
  2. Install the scheduler:

    Terminal window
    nextdns-blocker watchdog install
  3. Verify everything works:

    Terminal window
    nextdns-blocker status
    nextdns-blocker health