llm-over-dns

Environment Configuration Guide

This guide details how to configure the LLM over DNS server using environment variables and .env files.


βš™οΈ Configuration Methods & Precedence

The server supports four ways to load configurations, resolved in order of priority:

  1. Environment Variables (Highest precedence)
  2. .env.local File (Local-only gitignored overrides)
  3. .env File (Shared environment defaults)
  4. Hard-coded Defaults (Lowest precedence)

πŸ”‘ LLM Gateways & API Configuration

The server natively integrates with two major LLM API gateway providers: AnyRouter and OpenRouter.

[!TIP] AnyRouter is the highly recommended default because it is built for high speed, low latency, native OpenAI/Anthropic compatibility, and resilient model fallback lists.

To configure the server to route requests through the AnyRouter gateway, simply set ANYROUTER_API_KEY. If this key is present, the server automatically switches the base completion endpoint and defaults to optimized AnyRouter models.


2. OpenRouter

If ANYROUTER_API_KEY is not set, the server falls back to using OpenRouter.


🌐 DNS Server Configuration


πŸ“ Logging Configuration


πŸ“‹ Comprehensive Reference Table

Variable Precedence Fallback Default Value Description
ANYROUTER_API_KEY None None Primary AnyRouter API key. Set this to activate AnyRouter.
OPENROUTER_API_KEY None None OpenRouter API key. Used if ANYROUTER_API_KEY is empty.
ANYROUTER_MODEL None google/gemini-2.5-flash-lite,meta/llama-3.2-3b-instruct List of models used in fallback order for AnyRouter.
OPENROUTER_MODEL None nvidia/nemotron-nano-9b-v2:free,meituan/longcat-flash-chat:free... List of fallback models for OpenRouter.
DNS_PORT PORT 53 Listening port for UDP DNS server.
DNS_ADDRESS HOST 0.0.0.0 IP binding address.
RUST_LOG None info Logging verbosity filter.

πŸ”’ Security Best Practices

  1. Protect your .env: Make sure .env and .env.local are explicitly added to .gitignore. Never commit keys to a shared VCS.
  2. Restrict Permissions: On Linux systems, keep your local .env file secure:
    chmod 600 .env
    
  3. API Key Safety: Rotate keys regularly via the gateways’ web dashboards.