Skip to main content

OpenWrt Router Support

DNS-MNS now supports OpenWrt routers, allowing you to provide smart DNS resolution for your entire network. This is especially useful for Iranian users who want to bypass DNS censorship for all devices on their home network.

Overview

DNS-MNS on OpenWrt operates in two modes:

Upstream Mode (Recommended)

DNS-MNS works alongside dnsmasq. Dnsmasq stays on port 53 and forwards queries to DNS-MNS running on a different port.

Direct Mode

DNS-MNS replaces dnsmasq on port 53. Dnsmasq DNS is disabled, but DHCP continues to work.

Installation

Download the Correct Binary

OpenWrt runs on various architectures. Download the appropriate binary for your router:
ArchitectureDownload FileCommon Routers
x86_64dns-mns-openwrt-x86_64x86 routers, virtual machines
MIPSdns-mns-openwrt-mipsOlder routers (TP-Link WR841N, etc.)
MIPSeldns-mns-openwrt-mipselSome TP-Link and D-Link models
ARM v7dns-mns-openwrt-armv7Raspberry Pi 2/3, modern routers
ARM64dns-mns-openwrt-aarch64Raspberry Pi 4, high-end routers

Identify Your Router Architecture

SSH into your OpenWrt router and run:
uname -m
Common outputs:
  • x86_64 → Use x86_64 binary
  • mips → Use MIPS binary
  • mipsel or mipsle → Use MIPSel binary
  • armv7l → Use ARM v7 binary
  • aarch64 → Use ARM64 binary

Install on OpenWrt

  1. Download to your computer, then copy to the router:
# From your computer
scp dns-mns-openwrt-x86_64 root@192.168.1.1:/tmp/
  1. SSH to router and install:
ssh root@192.168.1.1
mv /tmp/dns-mns-openwrt-x86_64 /usr/bin/dns-mns
chmod +x /usr/bin/dns-mns
  1. Verify installation:
dns-mns --version

Configuration

Step 1: Detect OpenWrt

Verify DNS-MNS detects your OpenWrt system correctly:
dns-mns openwrt detect
Example output:
[OK] OpenWrt detected!

  Version:  23.05.0
  Board:    x86/64

[OK] dnsmasq is installed
[OK] dnsmasq is running
  Port:     53

Step 2: Choose and Setup Mode

Step 3: Check Status

View the current configuration:
dns-mns openwrt status
Example output:
========================================
OPENWRT STATUS
========================================
  OpenWrt Version:  23.05.0
  Board:            x86/64

  dnsmasq Status:
    Installed: Yes
    Running:   Yes
    Port:      53
    Upstream:  127.0.0.1:5353

  DNS-MNS Status:
    Configured: Yes
    Mode:        upstream
========================================

Step 4: Enable Auto-Start

To start DNS-MNS automatically on boot:
# Install the init script (included in release)
cp /path/to/dns-mns.init /etc/init.d/dns-mns
chmod +x /etc/init.d/dns-mns

# Create UCI config
cat > /etc/config/dns-mns << 'EOF'
config dns-mns 'main'
	option enabled '1'
	option mode 'upstream'
	option listen_addr '127.0.0.1'
	option listen_port '5353'
	option auto_start '1'
EOF

# Enable and start service
/etc/init.d/dns-mns enable
/etc/init.d/dns-mns start

Managing the Service

Start/Stop/Restart

# Start
/etc/init.d/dns-mns start

# Stop
/etc/init.d/dns-mns stop

# Restart
/etc/init.d/dns-mns restart

# Check status
/etc/init.d/dns-mns status

View Logs

# Real-time logs
logread -f | grep dns-mns

# Recent logs
logread | grep dns-mns

Restoring Original Configuration

If you need to revert to your original dnsmasq configuration:
dns-mns openwrt restore
This will:
  • Restore dnsmasq configuration from backup
  • Restart dnsmasq with original settings
  • Remove DNS-MNS configuration

CLI Commands Reference

CommandDescription
dns-mns openwrt detectDetect if running on OpenWrt and show system info
dns-mns openwrt setup --mode upstreamConfigure dnsmasq to use DNS-MNS as upstream
dns-mns openwrt setup --mode directConfigure DNS-MNS to replace dnsmasq on port 53
dns-mns openwrt statusShow current OpenWrt DNS configuration
dns-mns openwrt restoreRestore original dnsmasq configuration

Setup Flags

FlagDescriptionDefault
--modeOperation mode: upstream or directupstream
--listenListen address for DNS-MNS127.0.0.1
--portListen port for DNS-MNS (upstream mode)5353
--auto-startEnable auto-start on boottrue

Troubleshooting

DNS-MNS Not Detecting OpenWrt

If dns-mns openwrt detect fails, verify:
# Check for OpenWrt files
ls /etc/openwrt_release /etc/openwrt_version 2>/dev/null

# Check for uci
which uci

Dnsmasq Fails to Start

If dnsmasq fails after configuration:
# Check for configuration errors
dnsmasq --test --conf-file=/etc/dnsmasq.conf

# Restore backup manually
cp /etc/config/dhcp.dns-mns-backup /etc/config/dhcp
uci commit dhcp
/etc/init.d/dnsmasq restart

Port Already in Use

If port 5353 is already in use:
# Find what's using the port
netstat -tlnp | grep 5353

# Use a different port
dns-mns openwrt setup --mode upstream --port 5354

Low Memory on Router

For routers with limited RAM (< 64MB):
# Use direct mode (less memory overhead)
dns-mns openwrt setup --mode direct

# Or limit concurrent connections
dns-mns proxy --listen 127.0.0.1:5353 --protocol auto &
echo $! > /var/run/dns-mns.pid

Building from Source for OpenWrt

To build a custom binary for your router:
# Clone repository
git clone https://gitlab.com/E-Gurl/dns-mns.git
cd dns-mns

# Build for your router architecture
# x86_64
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags="-s -w -extldflags '-static'" -o dns-mns-openwrt-x86_64 ./cmd/dns-mns/

# MIPS
CGO_ENABLED=0 GOOS=linux GOARCH=mips GOMIPS=softfloat go build -ldflags="-s -w -extldflags '-static'" -o dns-mns-openwrt-mips ./cmd/dns-mns/

# ARM v7
CGO_ENABLED=0 GOOS=linux GOARCH=arm GOARM=7 go build -ldflags="-s -w -extldflags '-static'" -o dns-mns-openwrt-armv7 ./cmd/dns-mns/
Or use the Makefile:
make build-openwrt
make verify-static

Comparison with SmartDNS

FeatureDNS-MNSSmartDNS
DoH/DoT Support✅ Built-in✅ Yes
DNSCrypt Support✅ Built-in❌ No
Auto Protocol Switching✅ Yes⚠️ Limited
Iran-Optimized✅ Yes⚠️ Generic
DPI Evasion✅ TLS Fragmentation❌ No
Censorship Detection✅ Yes❌ No
VLESS/REALITY Proxy✅ Built-in❌ No
OpenWrt Integration✅ Native UCI✅ Yes

Best Practices

  1. Start with Upstream Mode: It’s safer and allows easy rollback
  2. Backup Your Config: Before making changes, backup /etc/config/dhcp
  3. Test Before Auto-Start: Manually test DNS resolution before enabling auto-start
  4. Monitor Memory Usage: On low-end routers, monitor with free -h
  5. Use Dashboard: Run dns-mns dashboard to monitor performance