# SmartDNS — Local DNS Server for Fastest IP Resolution > A lightweight local DNS server written in C that queries multiple upstream DNS servers simultaneously and returns the fastest responding IP address. Supports DNS over TLS, DNS over HTTPS, and custom routing rules for optimized network performance. ## Install Save in your project root: # SmartDNS — Local DNS Server for Fastest IP Resolution ## Quick Use ```bash # Install on Debian/Ubuntu wget https://github.com/pymumu/smartdns/releases/latest/download/smartdns.x86_64-linux-all.tar.gz tar xzf smartdns.x86_64-linux-all.tar.gz cd smartdns chmod +x install sudo ./install -i # Edit config and start sudo vi /etc/smartdns/smartdns.conf sudo systemctl enable --now smartdns ``` ## Introduction SmartDNS is a local DNS server that improves DNS resolution speed by querying multiple upstream DNS servers concurrently and selecting the result with the lowest latency. It runs on Linux, OpenWrt, macOS, and Windows, and supports modern encrypted DNS protocols including DNS over TLS and DNS over HTTPS. ## What SmartDNS Does - Queries multiple upstream DNS servers in parallel and returns the fastest responding result - Supports DNS over TLS (DoT) and DNS over HTTPS (DoH) for encrypted upstream queries - Caches DNS results locally with configurable TTL for faster repeat lookups - Provides domain-based routing rules to direct specific queries to designated upstream servers - Runs as a lightweight daemon suitable for routers, servers, and developer workstations ## Architecture Overview SmartDNS is written in C for minimal resource usage. It listens on a configurable local port and forwards incoming queries to all configured upstream servers simultaneously. When responses arrive, it evaluates them based on response time, IP address reachability, and optional speed-check probes. The best result is cached and returned to the client. The configuration is a simple text file with server definitions, routing rules, and cache settings. ## Self-Hosting & Configuration - Install from prebuilt packages for Debian, OpenWrt, macOS, or compile from source - Configure upstream servers in `/etc/smartdns/smartdns.conf` with protocol and port settings - Group upstream servers for split-horizon DNS (e.g., domestic vs. international resolution) - Set `speed-check-mode` to `ping` or `tcp:port` for latency-based result selection - Adjust `cache-size` and `prefetch-domain` for optimal caching behavior ## Key Features - Parallel querying of multiple upstream servers minimizes DNS resolution latency - Encrypted DNS support (DoT and DoH) prevents DNS queries from being intercepted - Domain-based routing sends queries for specific domains to designated resolvers - IP address filtering and BOGUS NXDOMAIN handling block known bad results - Lightweight C implementation runs on resource-constrained devices like routers ## Comparison with Similar Tools - **Pi-hole** — Focuses on ad blocking with DNS; SmartDNS focuses on speed optimization - **CoreDNS** — Kubernetes-oriented DNS server; SmartDNS is optimized for client-side resolution - **AdGuard Home** — Combines ad blocking with DNS; SmartDNS specializes in fastest-IP selection - **Unbound** — Recursive resolver; SmartDNS is a forwarding resolver that races upstream servers - **dnscrypt-proxy** — Focuses on encrypted DNS; SmartDNS adds parallel querying and speed testing ## FAQ **Q: How does SmartDNS choose the fastest IP?** A: It queries all configured upstream servers simultaneously and optionally probes returned IPs with ping or TCP connection tests to select the lowest-latency result. **Q: Can I use SmartDNS on my router?** A: Yes. SmartDNS supports OpenWrt and other embedded Linux distributions. Prebuilt packages are available for common router architectures. **Q: Does it block ads?** A: SmartDNS can block domains using a blocklist file, but it is not primarily an ad blocker. Combine it with Pi-hole or AdGuard Home for ad blocking. **Q: Can I route certain domains to specific DNS servers?** A: Yes. Use `nameserver` groups and `domain-rules` to direct queries for specific domains or domain patterns to designated upstream server groups. ## Sources - https://github.com/pymumu/smartdns - https://pymumu.github.io/smartdns/ --- Source: https://tokrepo.com/en/workflows/asset-8666e429 Author: AI Open Source