> ## Documentation Index
> Fetch the complete documentation index at: https://e-gurl.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# CLI Mode & Flags

> Non-interactive command-line usage for scripting and automation

# CLI Mode

Starting with v3.0.0, DNS-MNS supports full non-interactive CLI mode via subcommands and flags. This is perfect for scripting, automation, and CI/CD pipelines.

## Commands

### Test DNS Servers

```bash theme={null}
# Test all DNS servers
dns-mns test

# Test specific category
dns-mns test gaming
dns-mns test regional
dns-mns test international

# Output JSON
dns-mns test gaming --json --top 5
```

Available categories: `international`, `regional`, `gaming`, `vpn`, `additional`, `all`

### Smart Recommendation

```bash theme={null}
# Default balanced profile
dns-mns recommend

# Gaming profile (prioritizes latency)
dns-mns recommend --profile gaming

# Privacy profile (prioritizes encryption)
dns-mns recommend --profile privacy --json
```

### Test Encrypted DNS

```bash theme={null}
# Test DoH/DoT providers
dns-mns test-doh

# Test DNSCrypt providers
dns-mns test-dnscrypt
```

### Set / Clear DNS

```bash theme={null}
# Set DNS
dns-mns set 1.1.1.1 1.0.0.1

# Reset to DHCP
dns-mns clear
```

### Live Dashboard

```bash theme={null}
dns-mns dashboard
```

Launches a live-updating TUI that monitors DNS server health, shows current DNS configuration, and proxy status.

### Auto-Update

```bash theme={null}
dns-mns update
```

Checks GitLab for new releases and self-updates the binary.

<Note>
  **Windows Users:** The update process handles Windows file locking automatically. The binary will restart itself after the update completes.
</Note>

### System Diagnostics

```bash theme={null}
# Run diagnostics
dns-mns diagnose

# Save to file for bug reports
dns-mns diagnose > dns-mns-debug.txt
```

Runs comprehensive system diagnostics to help troubleshoot issues:

* **System Info:** OS version, architecture, Go version
* **Permissions:** Administrator/root status
* **Network:** Interface configuration, current DNS settings
* **DNS Capabilities:** Ping tests, DNS query tests
* **Platform-Specific:** systemd-resolved, NetworkManager (Linux), PowerShell version (Windows)

Use this when experiencing issues and include the output in bug reports.

### OpenWrt Router Commands

```bash theme={null}
# Detect OpenWrt system
dns-mns openwrt detect

# Setup in upstream mode (recommended)
dns-mns openwrt setup --mode upstream

# Setup in direct mode
dns-mns openwrt setup --mode direct

# Check status
dns-mns openwrt status

# Restore original dnsmasq config
dns-mns openwrt restore
```

See [OpenWrt Router Support](/usage/openwrt) for detailed setup instructions.

### Advanced Evasion Suite

Use sing-box for advanced proxy protocols (VLESS, VMess, Trojan, Hysteria2, ShadowTLS, TUIC):

```bash theme={null}
dns-mns singbox start --protocol vless --server example.com:443 --uuid UUID --public-key KEY
dns-mns singbox start --protocol hysteria2 --server example.com:443 --password PASS
dns-mns singbox start --protocol shadowtls --server example.com:443 --password PASS
dns-mns singbox status
dns-mns singbox stop
```

### Advanced Proxy (Sing-box)

```bash theme={null}
# Start VLESS + REALITY proxy
dns-mns singbox start \
  --protocol vless \
  --server your-server.com:443 \
  --uuid xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \
  --public-key YOUR_PUBLIC_KEY \
  --short-id YOUR_SHORT_ID \
  --sni www.microsoft.com

# Start with configuration file
dns-mns singbox start --config /path/to/config.json

# Check proxy status
dns-mns singbox status

# Stop proxy
dns-mns singbox stop

# Test configuration
dns-mns singbox test --protocol vless --server example.com:443 --uuid xxx

# Generate example config
dns-mns singbox config-example --protocol vless-reality
```

Supports protocols: `vless`, `vmess`, `trojan`, `hysteria2`, `shadowtls`, `tuic`

### Tunnel Suite (DNSTT / Slipstream / Paqet)

DNS-MNS includes a unified tunnel command group:

```bash theme={null}
dns-mns tunnel --help

# Create a profile
dns-mns tunnel profile create --name demo-dnstt --transport dnstt --mode client --remote 127.0.0.1:5300

# Scan and test resolver candidates
dns-mns tunnel scan --name demo-dnstt
dns-mns tunnel test --name demo-dnstt

# Runtime controls (requires upstream tunnel binaries installed in PATH)
dns-mns tunnel dnstt start --name demo-dnstt
dns-mns tunnel status
dns-mns tunnel logs --tail 50
dns-mns tunnel stop
```

## Global Flags

| Flag         | Description                       |
| ------------ | --------------------------------- |
| `--json`     | Output results in JSON format     |
| `--no-color` | Disable colored output            |
| `--top N`    | Number of top results (default 3) |
| `--version`  | Show version                      |
| `--help`     | Show help                         |

The `NO_COLOR` environment variable is also respected.

## JSON Output Examples

### DNS Test Results

```json theme={null}
[
  {
    "rank": 1,
    "name": "Shecan",
    "primary": "178.22.122.100",
    "secondary": "185.51.200.2",
    "location": "Iran",
    "category": "Regional/Middle East DNS",
    "ping_ms": 5.2,
    "dns_ms": 8.1,
    "score": 13.3
  }
]
```

### Recommendation Results

```json theme={null}
[
  {
    "rank": 1,
    "name": "Shecan",
    "total_score": 86.0,
    "ping_ms": 5.2,
    "dns_ms": 8.1,
    "ping_score": 100,
    "dns_score": 95,
    "protocol_score": 20,
    "privacy_score": 40,
    "iran_score": 100,
    "geo_score": 100,
    "reason": "excellent ping, fast DNS resolution, reliable in Iran, nearby server",
    "protocol_support": ["plain"]
  }
]
```

## Scripting Examples

### Find the best DNS and set it automatically

```bash theme={null}
BEST=$(dns-mns test gaming --json --top 1 | jq -r '.[0].primary')
dns-mns set "$BEST"
```

### Monitor DNS health in a cron job

```bash theme={null}
# Add to crontab: check DNS every hour
0 * * * * dns-mns test --json --top 1 --no-color >> /var/log/dns-health.json
```
