From dnsmasq to smartdns: Building a Reliable Home DNS Domestic and International Query Splitting System
本文最后更新于 320 天前,其中的信息可能已经有所发展或是发生改变,如有失效可到评论区留言。
Article Abstract
To resolve the stability issues caused by the inability of home network DNS queries to perform smart split routing and the reliance on router plugins, this article compares and analyzes the characteristics of two split routing tools: dnsmasq and SmartDNS. With its lightweight nature and mature rule ecosystem, dnsmasq is suitable for basic split routing scenarios, but its policy scalability is limited; SmartDNS, on the other hand, achieves smarter resolution scheduling through native support for DoH/DoT protocols, multi-upstream speed testing optimization, and flexible policy grouping. Ultimately, by deploying SmartDNS combined with geosite rules, a stable split routing system with domestic priority resolution and encrypted link backup was built, effectively improving the reliability and response speed of DNS resolution, while reserving expansion space for subsequent integration of transparent proxying and traffic forwarding.
Qwen3-14B · 2026-06-18

1 Introduction

Previously, I wrote an article about the deployment of dnscrypt-proxy (see:dnscrypt-proxy (v2.1.8) Multi-Scenario Configuration Guide: From Upstream Deployment to Downstream Integration). The architecture at that time was: using Racknerd's Chicago VPS to deploy dnscrypt-proxy as an encrypted DNS upstream server (published via DoH), while AdGuard Home in the home data center (since AdGuard Home supports DoH upstream nodes) served as the DNS downstream node for intranet devices, thereby providing a clean, pollution-free, and encrypted DNS service for the home network.

However, this solution also has a limitation in practical use:Inability to achieve split routing resolution for domestic and foreign DNS queries. Of course, this is not because dnscrypt-proxy itself does not support it, but rather because its split routing mechanism is more geared towards ”server-policy-based forwarding” (for example, through different server-names configurations), unlike dnsmasq or smartdns,which can simply and intelligently select the upstream server based on whether the queried domain is a domestic domain (such as geosite:cn)。

Therefore, in daily use, this architecture is more suitable as apure external DNS egressto use. For scenarios requiring domestic priority and smart split routing, it is not practical enough: many domestic websites simply do not respond to queries from foreign addresses.

Currently, my DNS query split routing mainly relies on the DNS hijacking and rule-based split routing functions provided by Merlin Clash on the AC86U router. Although this method is simple to deploy and has intuitive effects, it also has an inherent risk:Over-reliance on the stability of a single node. Whether it is Merlin Clash itself or the configured proxy service provider, once either party fails (such as proxy node failure, rule loading anomalies, or network fluctuations during special periods), the entire DNS split routing chain will break. The most direct consequence is that intranet devices cannot correctly resolve some domains, or even experience complete resolution failure.

I have encountered these issues more than once, which has gradually made me hesitant to point the upstream DNS of the iKuai main router directly to the DNS service of the AC86U. After all, once the AC86U has a problem, the entire network environment will be affected.

So this time, I decided tocompletely solve this problem: build astable, independent local DNS service system that does not rely on Merlin Clash and AdGuard Home, and simultaneously possesses ”smart split routing for domestic and foreign DNS queries” capabilities. Its core goals include:

  1. High stability: No longer relying on router firmware or third-party plugins; even if the proxy service fails, the DNS split routing service remains available;
  2. Smart split routing capability: With the help of rules like geosite and china-list, achieve precise split routing for domestic and foreign domains, where domestic domains go to local upstream and foreign domains go to encrypted links;
  3. Modular component design: Clear responsibilities for each part, for example, dnsmasq focuses on split routing and caching, while sing-box or dnscrypt-proxy provides encrypted resolution services;
  4. Friendly to the main router: allowing iKuai to safely send DNS requests to this system without worrying about a single point of failure disabling the entire network;
  5. Features transparent proxy compatibility: in the future, if linked with sing-box's tproxy mode, it can also achieve deep integration of DNS and traffic forwarding.

This is a complete refactoring from ”barely usable relying on plugins” to ”clear modules, stable and reliable”, aiming to build a truly trustworthy DNS infrastructure for home data center scenarios.

2 Selection of Split Routing Software

1 Overview

To achieve split resolution of domestic and foreign DNS requests, a ”base point” software is required—it must have sufficient policy flexibility to determine the attribution of requests based on factors such as domain names, IP addresses, and even response latency, and then intelligently forward query requests to appropriate targets in combination with the domestic and foreign DNS upstream servers we have on hand. This type of software acts as both a DNS forwarder and a ”DNS routing scheduler”, serving as the core of building a split DNS system. Common base point solutions include dnsmasq and SmartDNS.

2 dnsmasq Introduction: A Time-tested and Robust Basic Tool for DNS Split Routing

In the scenario of building split DNS, dnsmasq is a lightweight DNS caching and forwarding tool with a long history and wide usage, integrated by default in many embedded systems (such as OpenWrt). Although its design is very simple, with the help of appropriate configuration files, it can still handle tasks such as domain-based split resolution, cache acceleration, and blocking malicious domains, making it the ”entry-level choice” for many users when deploying scientific DNS split resolution in the early days.

2.1 Advantages

Advantage 1: Stable, lightweight, and widely relied upon

The biggest feature of dnsmasq is ”stability”—it is compact and has extremely low resource usage, running very smoothly even on low-performance routers or embedded devices. It is almost standard in custom firmware like OpenWrt, LEDE, and Padavan; it is also ubiquitous in mainstream Linux systems like Debian/Ubuntu, with low configuration and maintenance barriers.

Advantage 2: Mature supporting ecosystem, flexibly expandable relying on external rule files

Although dnsmasq's own policy capabilities are relatively limited, combined with community-maintained rule projects (such as:https://github.com/felixonmars/dnsmasq-china-list), basic split resolution by domain name can be achieved. These rule projects typically provide:

  • accelerated-domains.china.conf: Resolves domestic domains through domestic upstreams;
  • google.china.conf / apple.china.conf: Fine-grained handling of specific vendor domains;
  • bogus-nxdomain.conf: Blocks fake IPs returned by ISPs;
  • ipset.conf: Combined with firewall rules to achieve outbound NAT split routing.

Through these .conf files, dnsmasq can complete most tasks of ”determining DNS upstream based on domain ownership”.

Advantage 3: Excellent compatibility, adapting to various mainstream scenarios

dnsmasq supports DNS caching, PXE booting, DHCP services, and other functions, making it suitable for deployment in intranet gateway devices. It can provide general local DNS functions and serve as an auxiliary component for scientific network policies. In scenarios with high requirements for system dependency and compatibility, dnsmasq is a safe choice.

2.2 Disadvantages

Disadvantage 1: Limited policy expression capability, split resolution relies on piecing together rule files

dnsmasq itself does not have capabilities like ”line optimization”, ”upstream speed testing”, or ”fallback switching”. Its split resolution relies entirely on manually maintained rule files and cannot be dynamically adjusted. When you encounter issues such as changes in overseas domain CDN distribution or domestic domain pollution, dnsmasq cannot make intelligent adjustments based on actual network conditions.

Disadvantage 2: Lack of native DoH/DoT support, requiring external forwarders

dnsmasq does not support direct connection to DoH (DNS over HTTPS) or DoT (DNS over TLS) upstream servers. To use these protocols, additional components such as dnscrypt-proxy, SmartDNS, AdGuard Home, or https-dns-proxy are required as a front-end forwarding layer, which increases the complexity of deployment and debugging.

Disadvantage 3: Unfriendly to modern DNS architectures, with verbose and inflexible configurations

When configuring a large number of split resolution rules, dnsmasq requires manually importing multiple .conf files, making it difficult to organize and combine rules; meanwhile, it does not support upstream grouping mechanisms like tags or groups, nor can it achieve behaviors like ”automatically selecting the fastest after returning multiple upstream results”. This makes it feel somewhat inadequate in complex network environments.

2.2.3 Summary

As a classic DNS tool, dnsmasq has become a ”veteran” of home network DNS split resolution with its stability, lightweight nature, and extensive community support. It is suitable for resource-constrained devices and users who have a clear preset for DNS architecture and are willing to manually maintain rule files. However, when facing modern network requirements, its scalability and intelligence capabilities gradually expose bottlenecks. Therefore, in some more complex application scenarios, it may be necessary to consider introducing more modern tools, such as SmartDNS, which will be introduced in the next section.

3 SmartDNS Introduction: A Powerful Next-Generation DNS Splitter

Compared to dnsmasq, SmartDNS is a modern DNS split resolution solution that has emerged in recent years. It has natural advantages in ”intelligently selecting the fastest upstream”, ”latency speed test sorting”, and ”multi-protocol support (including DoH, DoT)”. Although initially born just for ”acceleration”, with continuous community drive, SmartDNS has gradually evolved into a fully functional split DNS hub, especially suitable for users with high requirements for speed, policy, and flexibility.

3.1 Advantages

Advantage 1: Native support for DoH / DoT, strong capability in upstream speed testing and optimization

SmartDNS supports connecting to DoH/DoT upstreams through parameters like server-tls and server-https, completing encrypted resolution requests without additional components. Meanwhile, SmartDNS periodically tests the speed of all upstreams, sorts them by response latency, and prioritizes the fastest server, effectively improving domestic and international access speeds.

This also makes it very suitable for environments with complex public network egresses and frequent bandwidth changes, such as home multi-WAN, side routers, and overseas transit scenarios.

Advantage 2: Flexible policy grouping and filtering mechanisms, supporting complex split resolution logic

SmartDNS supports tagging upstream servers and conditionally filtering them through rules, for example:

server-tls 1.1.1.1 -group foreign -exclude-default-group
server 223.5.5.5 -group domestic
server 127.0.0.1:5335 -group custom

# 分流规则
server-rule domain-suffix cn domestic
server-rule domain full netflix.com foreign

This means you can flexibly route different requests to different upstreams based on conditions such as TLD (Top-Level Domain), domain keywords, and client IP segments, and groups and rules can be used in combination, fully supporting ”multi-egress DNS split resolution” or ”targeted resolution” requirements.

Advantage 3: Support for advanced features such as cache acceleration, concurrent queries, and DNS answer filtering

SmartDNS supports concurrent queries by default (initiating requests to multiple upstreams simultaneously and only adopting the fastest response), and supports TTL control, cache poisoning protection, filtering of invalid IP addresses (such as 0.0.0.0, ISP hijacked IPs), and blocking specified domains, greatly improving the security and response speed of the DNS system.

In addition, it can also listen on multiple ports, acting as a DoH/DoT server, allowing other devices to request it via encrypted protocols, suitable for building local private DNS services.

3.2 Disadvantages

Disadvantage 1: Slightly higher resource usage, unfriendly to memory-sensitive devices

When starting, SmartDNS caches upstream configurations, speed test data, and rule lists. During multiple concurrent requests and latency analysis, it occupies more memory and CPU compared to dnsmasq, which is unfriendly to extremely low-configuration small devices (such as 64MB routers). However, for devices with 128MB+ memory or running in LXC/PVE virtual machines, this usage is completely acceptable.

Disadvantage 2: Slightly higher configuration syntax complexity, with a certain learning curve

Although SmartDNS is very powerful, its configuration syntax is not intuitive enough and may be slightly tedious for beginners. Especially when it comes to grouping, tags, and combining multiple rules, users need to carefully understand its resolution logic; any slight misconfiguration could cause all requests to fallback or hit the default group.

In addition, SmartDNS does not directly provide the ipset function (i.e., putting the resolved IP of a domain name into a specified ipset). This means that if you need to split traffic based on IP, you still have to rely on front-end tools like dnsmasq to generate ipsets or use nftables sets instead.

Disadvantage 3: Lack of a mature rule ecosystem, some split routing strategies need to be organized manually

Unlike the dnsmasq community which already has a large number of .conf files, SmartDNS's rule system is mostly user-defined. Although it is compatible with some basic geosite.dat/domain-list files, the official team does not directly maintain a split routing rule repository like felixonmars. Therefore, deployers often need to combine GFWList, CNList, GeoIP, etc., to organize rule files themselves, making it more suitable for users with some hands-on ability.

2.3.3 Summary

SmartDNS is a modern, powerful DNS split routing tool, showing overwhelming advantages especially in DoH/DoT support, multi-upstream speed measurement optimization, and flexible policy scheduling. For scenarios pursuing high performance and complex DNS policies, it is a highly competitive choice. However, at the same time, it also places higher demands on device performance and configuration skills, making it more suitable for running on servers, LXC containers, or bypass gateways with relatively abundant resources.

Compared with dnsmasq, SmartDNS is a ”future-oriented” DNS tool. The complexity and flexibility it brings are exactly what modern home networks and high-performance bypass gateway architectures urgently need.

3 Deployment and Configuration of “Base Point” Software

1 dnsmasq

1.1 dnsmasq's DNS Request Processing Logic (Practical & Concise Version)

For most users, the actual processing flow of dnsmasq can be simply understood in three steps:

Step 1: Check first hostsFile

dnsmasq will prioritize looking up static resolution rules, reading the contents of the /etc/hosts file by default.

Purpose: Suitable for binding certain specific domain names (such as ad blocking, local area network services):

192.168.10.100 nas.local
0.0.0.0 ads.example.com

0.0 ads.example.com”Step 2: Look at "“/etc/dnsmasq.d/*.conf

" to see if they match the routing rules

server=/baidu.com/114.114.114.114
server=/bilibili.com/114.114.114.114
server=/google.com/8.8.8.8
server=/github.com/8.8.8.8

server=/baidu.com/114.114.114.114

server=/cn/114.114.114.114

server=/cn/114.114.114.114These rules tell dnsmasq:。


For specific domain name requests, send them to the designated upstream DNS”For general routing needs, "“/etc/dnsmasq.d/" directory having 2 conf files is enough,dnsmasq-china-listin the project:和accelerated-domains.china.confapple.china.conf


, you can download them yourself. You can also create a scheduled script to regularly download and update these 2 files, but it's generally not very necessary, as updating these 2 so frequently doesn't make much sense.

Step 3: Use the default upstream DNS as a fallback (usually overseas)”Step 2: Look at "“If a domain name is neither in the hosts file nor matches any ”

server=1.1.1.1
server=8.8.8.8

Purpose: server=1.1.1.1

Summary:

Used to resolve all domain names not specifically designated, usually overseas DNS.

  1. The actual order in which dnsmasq processes DNS requests is:
  2. First check the hosts file (default /etc/hosts or custom addn-hosts)“Step 2: Look at "”Then check "
  3. ” to see if there are designated routing rules

Finally, requests that do not match will go to the upstream resolution specified by the “server=” statement in the "dnsmasq.conf" configuration file

1.2 Installing dnsmasq

1.2.1 Installation from Source

Note: For dnsmasq version 2.89 and later, it is no longer recommended to use "resolv-file=/etc/dnsmasq.upstream.conf" to specify upstream DNS. Instead, it is recommended to directly use the more controllable "server=" method in the dnsmasq.conf configuration file to configure global or split DNS, which is especially suitable for users who need to split domestic/overseas DNS queries.

apt-get install -y dnsmasq

apt-get install -y dnsmasq

image.png

Currently, the version installed via apt is 2.90, while the official latest version is 2.91. They are similar, so there is no need to insist on the latest version:

1.2.2 Installation via Docker

As for other platforms, the installation method is similar, so I won't go into detail here, just being a bit lazy.

docker run --name=dnsmasq -d --restart=always \
-p 1053:53/udp \
-p 1053:53/tcp \
-v /docker/dnsmasq/dnsmasq.conf:/etc/dnsmasq.conf:ro \
-v /docker/dnsmasq/dnsmasq.d:/etc/dnsmasq.d:ro \
-e "DNS1=8.8.8.8" -e "DNS2=1.1.1.1" \
--cap-add=NET_ADMIN \
dockurr/dnsmasq

docker run --name=dnsmasq -d --restart=always \

Note 1: When deploying dnsmasq using Docker, when configuring ”dnsmasq.conf” later, you cannot fill in the host machine's address after ”listen-address=” because Docker cannot see the host's IP. Therefore, you can fill in 127.0.0.1, or simply comment out or delete the "listen-address=" line, which defaults to listening on all addresses.

1.3 Configuring Split Routing Rules

mkdir -p /etc/dnsmasq.d/
cd /etc/dnsmasq.d/
wget https://github.com/felixonmars/dnsmasq-china-list/blob/master/accelerated-domains.china.conf
wget https://github.com/felixonmars/dnsmasq-china-list/blob/master/apple.china.conf

1.4 Creating the dnsmasq.conf Configuration File

mkdir -p /etc/dnsmasq.d/

For dnsmasq, the content of the configuration file /etc/dnsmasq.conf determines the core behavior and operation of the entire service: it not only controls basic settings such as listening addresses, cache size, log output, whether to enable DHCP, and whether to read the /etc/hosts file, but also defines advanced options such as whether to enable routing, whether to block IPv6, and whether to read additional configuration directories (such as /etc/dnsmasq.d/).

In addition, dnsmasq allows loading additional configuration files through the conf-dir= or conf-file= directives, making it highly flexible and maintainable. For example, we usually split various server= routing rules, address redirections, ad blocking rules, etc., into multiple configuration files and place them centrally in the /etc/dnsmasq.d/ directory for easy modular management.

It can be said that /etc/dnsmasq.conf is the "master console" of dnsmasq's behavior, and the configurations it contains or imports together form the "working brain" of dnsmasq. A scientific and reasonable configuration can make dnsmasq a core component of an efficient, stable, and routable home DNS service.

# 监听本地回环接口和主网卡 eth0(确保 DNS 请求能被容器或主机访问到)
interface=lo
interface=eth0

# 设置监听的端口为 53(DNS 默认端口)
port=53

# 启用所有上游 DNS 查询同时发出,谁先返回就用谁的结果,提升响应速度
all-servers

# 指定上游 DNS 服务器(支持分流或兜底)
server=1.1.1.1         # Cloudflare 公共 DNS(国外)
server=8.8.8.8         # Google 公共 DNS(国外)

# 设置 DNS 缓存容量,单位为条(可根据内存适当调大)
cache-size=1000

# 不读取 /etc/hosts(通常是防止意外污染或使用统一 hosts 文件)
no-hosts

# 指定额外的 hosts 文件路径,用于本地解析定制
addn-hosts=/etc/dnsmasq.hosts

# 忽略系统默认的 /etc/resolv.conf(避免干扰上游配置)
no-resolv

# 加载 /etc/dnsmasq.d/ 目录下所有 .conf 文件(常用于域名分流配置)
conf-dir=/etc/dnsmasq.d

# 最大并发转发查询数(防止高并发时丢包或延迟)
dns-forward-max=150

# 开启兼容 Windows 的行为,过滤无效 IPv6 请求(如 WPAD 相关)
filterwin2k

# (可选)禁用 IPv6 解析
#no-ipv6

# 启用查询日志(调试或分析用,线上长期开启建议配合 logrotate)
log-queries
log-facility=/var/log/dnsmasq.log

# 不启用 DHCP 功能(dnsmasq 默认支持 DHCP,这里关闭以避免冲突)
no-dhcp-interface=eth0

Create the dnsmasq.conf configuration file:

vim /etc/dnsmasq.conf

Paste the above configuration example into it and save, then restart the dnsmasq service:

systemctl restart dnsmasq.service

If you do not want to use the default configuration file path and name, you need to customize it yourself using the ”–conf-file” parameter. For example, if you want to use ”/opt/my.conf” as the dnsmasq configuration file, you first need to copy ”/lib/systemd/system/dnsmasq.service” (the default path of the dnsmasq.service file when dnsmasq is installed via apt) to the ”/etc/systemd/system” path and edit it:

cp /lib/systemd/system/dnsmasq.service /etc/systemd/system/dnsmasq.service
vim /etc/systemd/system/dnsmasq.service

Change the ”ExecStart” field in it to:

ExecStart=/usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq --conf-file=/opt/my.conf

Then just restart the service:

systemctl daemon-reexec
systemctl daemon-reload
systemctl restart dnsmasq.service

Actually, you can also use the officially recommended ”systemctl edit” method to directly override the ExecStart field in ”/lib/systemd/system/dnsmasq.service”. This will generate an override file ”override.conf” in the ”/etc/systemd/system/dnsmasq.service.d/” directory, which only contains the override for the ExecStart field. However, I don't like this method as it feels scattered, so I just copied it directly to ”/etc/systemd/system/dnsmasq.service” and modified it directly, which is equivalent to the command ”systemctl edit –full dnsmasq.service”.


2 smartdns

2.1 Installing smartdns

2.1.1 Installation from Source

Since the version of smartdns provided in apt is too old, only 40:

image.png

While the latest release version on the official GitHub page is currently 46.1, which is a huge difference:
image.png

Therefore, we will not use apt for installation, but instead directly download and use the latest version from GitHub.

Download the installation package for the corresponding environment

Since I am using Debian 12, I download:

image.png

cd ~
wget https://github.com/pymumu/smartdns/releases/download/Release46.1/smartdns.1.2025.03.02-1533.x86_64-linux-all.tar.gz

Decompress

tar zxf smartdns.1.2025.03.02-1533.x86_64-linux-all.tar.gz

Execute the installation script

cd smartdns
chmod +x install
./install -i

Installation completed:

image.png

The image above shows the execution content of the self-extracting installation script (./install -i) in the official SmartDNS release package: it mainly completes the process of ”copying binaries + registering services”.

2.1.2 Installation via Docker

Create directory

mkdir -p /etc/smartdns

Create container using docker run format command

docker run -d --name smartdns --restart=always -p 53:53/udp -v /etc/smartdns:/etc/smartdns pymumu/smartdns:latest

2.2 Obtaining the geosite File

The geosite file mainly comes from the project on GitHub:Loyalsoldier/v2ray-rules-dat, which provides quite a few options:

image.png


Which ones to choose specifically depends on your traffic splitting requirements and scenarios. For me, the requirement is very simple: ”specified domains” go through domestic DNS, and everything else goes through foreign DNS, which is simple, brute-force, and practical. The ”specified domains” consist of direct-list.txt and apple-cn.txt in the image above, which are actually consistent with the two conf files under the ”/etc/dnsmasq.d/” path in my previous dnsmasq configuration:
accelerated-domains.china.conf and apple.china.conf.


Merge the contents of ”direct-list.txt” and ”apple-cn.txt” into the file ”/etc/smartdns/china.conf”:

curl "https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/direct-list.txt" >> /etc/smartdns/china.conf
curl "https://raw.githubusercontent.com/Loyalsoldier/v2ray-rules-dat/release/apple-cn.txt" >> /etc/smartdns/china.conf

Convert the format to rules recognizable by SmartDNS, remove ”full:”, and specify these domains as the cn group:

sed "s/^full://g;/^regexp:.*/d;s/^/nameserver \//g;s//\/cn/g" -i /etc/smartdns/china.conf

2.3 Creating the Configuration File smartdns.conf

Create configuration file:

vim /etc/smartdns/smartdns.conf

Paste the following content into it and save:

# 禁用 IPv6
force-AAAA-SOA yes
disable-ipv6 yes

# 监听本地 53 端口
bind :53

# 缓存大小与性能设置
cache-size 2048
dualstack-ip-selection no
prefetch-domain yes
speed-check-mode ping

# 包括定制国内域名规则 (direct-list + apple-cn)
conf-file /etc/smartdns/china.conf

# 国内 DNS,标准 UDP
server 119.29.29.29 -group cn
server 114.114.114.114 -group cn

# 境外 DNS,标准 UDP + DoH
server 1.1.1.1 -group foreign
server 8.8.8.8 -group foreign

# 启用并发解析,使用最快响应
server-policy fastest-response

# 默认策略为:根据域名规则使用分组
nameserver-policy /cn/ cn
nameserver-policy /china/ cn
# 其他走 foreign(注意:如果没有匹配到 cn 则默认用 foreign)

When specifying upstream DNS in the configuration file smartdns.conf, SmartDNS provides multiple query methods. Currently supported are UDP, TCP, DOT, DOH, DOQ, and DOH3. These query protocols each have their own advantages and disadvantages in terms of performance and security, and can be configured and used as needed. The table below describes several protocols:

image.png


Restart the smartdns service:

systemctl restart smartdns

Note: The content of this section is about using smartdns as a downstream DNS client, but smartdns also supports acting as an upstream DNS server. Compared with dnscrypt-proxy, except for not supporting dnscrypt, other functions are all fine, so you can choose according to your needs.

2.4 Scheduled Updates for china.conf

mkdir /root/script
vim /root/script/update-smartdns-china.sh

Paste the following content into it and save:

#!/bin/bash"TMP_FILE"TMP_FILE"TMP_FILE"/d;s/^/nameserver \//g;s//\/en/g' "TMP_FILE"

vim /root/script/update-smartdns-china.sh

chmod +x /root/script/update-smartdns-china.sh

chmod +x /root/script/update-smartdns-china.sh

0 3 * * * /root/script/update-smartdns-china.sh

4 Summary

0 3 * * * /root/script/update-smartdns-china.sh

In fact, for the vast majority of domestic and international DNS split routing needs in personal home networks, the conventional split routing logic — "specified domestic domain name queries go to domestic DNS servers, and all others go to foreign DNS" — is already sufficient. From the perspective of "achieving split routing", both dnsmasq and smartdns are up to the task, especially when used in conjunction with rule files (such as direct-list.txt and apple-cn.txt), where the configuration is also very clear and straightforward.

But as mentioned earlier in the article, smartdns has a very significant advantage over dnsmasq: its support for upstream DNS server types is much richer and more flexible. In addition to standard UDP 53 queries, it also natively supports encryption protocols such as DoT (DNS over TLS) and DoH (DNS over HTTPS). This makes it easier to connect to modern DNS services like Cloudflare, Google, NextDNS, or even self-built DoH servers, improving privacy and anti-interference capabilities.

More importantly, smartdns also supports sending requests to multiple upstreams concurrently and automatically selecting the fastest responding result to return, which can significantly improve the DNS resolution experience during network quality fluctuations (dnsmasq is essentially serial querying). In addition, it has built-in enhancement features such as caching, prefetching, speed testing, and automatic domain speed-test optimization, making it not only "capable of split routing" but also "fast, accurate, and anti-interference" in practical use.

Final conclusion: smartdns is superior to dnsmasq when implementing domestic and international split routing functions.

The reason for emphasizing the types of upstream DNS servers supported by the split routing software is that this directly affects the flexibility and fault tolerance of overseas DNS queries: if the split routing software only supports the traditional UDP 53 query method, the available upstream DNS servers will be very limited, often relying only on public DNS services such as 1.1.1.1 and 8.8.8.8. Although this solution is simple, it is prone to two problems in practical use: first, these public DNS services themselves are easily interfered with; second, when the home scientific internet access environment fluctuates or is interrupted, overseas DNS queries may also fail altogether.

Under this design, the overseas DNS query method has a redundant structure with multiple paths:

  • Scientific service channel → Use standard public DNS, such as 1.1.1.1, 8.8.8.8, with low latency and fast speed, making it the preferred choice.
  • Non-scientific channel + self-built DoH/DoT → Use the native exit of home broadband combined with the encrypted DNS service deployed on overseas VPS to continue ensuring overseas domain name resolution when the scientific service fails.

As shown in the figure below:

image.png

Since smartdns supports concurrent queries and automatically selects the fastest response, even if multiple upstream DNS are configured, as long as the scientific service channel is normal, the DNS path based on the scientific service channel will respond faster and be preferred without manual intervention, maximizing the balance ofPerformance与availability; and when the scientific service channel has problems, the response of the non-scientific channel will serve as a fallback for overseas queries. Because of this, DNS split-routing software with modern protocol support is not only ”capable of split-routing” but also ”capable of providing a fallback”, which is particularly important in unstable network environments. To achieve this effect, you only need to fill in the addresses of overseas DNS services under different channels for the overseas upstream DNS servers in the configuration file at the same time. Taking the smartdns configuration file as an example:

image.png

From this perspective, dnsmasq is a bit inferior (because it does not directly support DoT/DoH). If I want to use dnsmasq to achieve the same fault tolerance, I also need to pair it with the previously deployed AdGuard Home (AdGuard Home supports encrypted protocols such as DoH and DoT), which adds another functional node.

Note 1: Only after writing the article did I see that there is also Mosdns, which is more complex than smartdns and supports more features. I took a quick glance, and I don't need those extra features anyway. Forget it, I'm too lazy to mess with it; smartdns is already enough for a home intranet environment.

Note 2: To write this article, I messed around with dnsmasq and smartdns again. It would feel like a waste not to use them both, so in the end, I set up the DHCP server on iKuai like this:

image.png

This way, the DNS server addresses of all intranet devices have smartdns as the preferred option and dnsmasq as the backup. Now, unless the LXCs deploying smartdns and dnsmasq both die, the domestic and international split-routing effect of intranet DNS requests will be rock solid.

View Related Categories · 3 Matches
📌 Content Structure Prompt:
This content is part of the following knowledge map, where you can view the complete content path: Blog Knowledge Map。
📎 Related Articles
Share this article
The blog content is original, please indicate the source when reposting! The RSS address of the blog is:https://blog.tangwudi.com/feed, welcome to subscribe; if needed, you can join theTelegram Groupto discuss questions together.
No Comments

Send Comment Edit Comment


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗ
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
Kaomoji
Emoji
Little Dinosaur
Flower!
Previous
Next
       

👋 Welcome to “Wudi's Personal Blog”

Here, long-term exploration is mainly carried out around the following directions:

🧱 Personal Digital Infrastructure and Blog System Construction
☁️ Cloudflare and Network Architecture Practice
🧠 AI and Knowledge System Exploration
🛡️ Network Security and Access Optimization
🎵 Music and Sound Cognition
👁️ Cognitive Perspectives and Worldviews