Skip to main content

DNS-MNS OpenWrt Integration Guide

This guide covers the comprehensive OpenWrt integration features available in DNS-MNS v6.4.0.

Overview

DNS-MNS provides native OpenWrt router support with advanced features including:
  • Split-Horizon DNS - Different DNS servers based on domain
  • Per-Device Policies - Custom DNS rules per MAC/VLAN/Subnet
  • Auto-Benchmarking - Automatic DNS performance monitoring and failover
  • Metrics & Logging - Prometheus export and structured query logging
  • ubus Integration - Native OpenWrt system bus support
  • Hot-Reload - Configuration changes without restart

Architecture

Installation

Prerequisites

  • OpenWrt 19.07+ or 21.02+ or 23.05+
  • Architecture: x86_64, MIPS, MIPSel, ARMv7, ARM64
Starting with v9.0.1, every release ships pre-built .ipk packages that can be installed directly with opkg — no manual extraction or chmod required.
The .ipk installs the binary to /usr/bin/dns-mns, the init script to /etc/init.d/dns-mns, and a default UCI config to /etc/config/dns-mns. Existing /etc/config/dns-mns files are preserved on upgrade.

Method 2: Manual binary install

Install Init Script (manual install only)

Configuration

Main Configuration (/etc/config/dns-mns)

Split-Horizon DNS Rules

Per-Device Policies

CLI Commands

Service Management

DNS-MNS CLI

ubus Commands

Features

1. Split-Horizon DNS

Routes DNS queries to different servers based on domain:
  • .ir domains → Iranian DNS (Shecan, etc.)
  • .local domains → Local resolver
  • International → Encrypted DNS with DPI evasion
Benefits:
  • Faster local domain resolution
  • Bypass international censorship for foreign sites
  • Keep local traffic local

2. Per-Device Policies

Apply different DNS settings per device: Policy Types:
  • device - Match by MAC address
  • vlan - Match by VLAN ID
  • subnet - Match by IP subnet
  • group - Match multiple devices
Preset Policies:
  • kids-safe - Cloudflare Family DNS with safe search
  • gaming-optimized - Shecan with DPI evasion
  • iot-restricted - AdGuard with logging
  • guest-network - Standard DNS for guests

3. Auto-Benchmarking Scheduler

Automatically tests DNS servers and switches to the best: Features:
  • Periodic benchmarking (default: every 6 hours)
  • Health checking (default: every 60 seconds)
  • Automatic failover on consecutive failures
  • Performance-based switching (20% improvement threshold)
  • Switch history tracking

4. Metrics & Monitoring

Prometheus Metrics:
  • dns_mns_total_queries - Total query counter
  • dns_mns_cached_queries - Cache hit counter
  • dns_mns_blocked_queries - Blocked query counter
  • dns_mns_failed_queries - Failed query counter
  • dns_mns_unique_clients - Active clients gauge
  • dns_mns_unique_domains - Unique domains gauge
  • dns_mns_avg_response_time - Response time gauge
  • dns_mns_server_queries{server="..."} - Per-server queries
Access:

5. Structured Logging

JSON-formatted logs with rotation: Log Format:
Log Rotation:
  • Default size: 1MB per file
  • Default retention: 3 files
  • Automatic compression of old logs

6. Hot-Reload

Reload configuration without restart:
What can be reloaded:
  • DNS server lists
  • Split-horizon rules
  • Policy configurations
  • Logging settings
  • Scheduler intervals

Advanced Configuration

Custom DNS List

Firewall Rules (Direct Mode)

When using direct mode, ensure DNS traffic reaches DNS-MNS:

Integration with AdGuard Home

Troubleshooting

Check Service Status

Verify DNS Resolution

Common Issues

Permission Denied:
Port Already in Use:
High Memory Usage:

API Reference

ubus API

REST API (when enabled)

Migration from Legacy

If upgrading from DNS-MNS < 6.4.0:

Best Practices

  1. Start with Upstream Mode - Safer for initial deployment
  2. Enable Logging - Helps with troubleshooting
  3. Set Up Monitoring - Use Prometheus/Grafana for visibility
  4. Test Policies - Verify per-device rules work as expected
  5. Regular Backups - Backup /etc/config/dns-mns
  6. Monitor Memory - On routers with < 64MB RAM, use low memory mode

Support