Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

增加类似 resolv.conf 的 search 功能 #1901

Open
moetayuko opened this issue Jan 19, 2025 · 2 comments
Open

增加类似 resolv.conf 的 search 功能 #1901

moetayuko opened this issue Jan 19, 2025 · 2 comments

Comments

@moetayuko
Copy link
Contributor

moetayuko commented Jan 19, 2025

https://superuser.com/questions/570082/in-etc-resolv-conf-what-exactly-does-the-search-configuration-option-do

简单来说,当待查询的域名里不包含点时,则依次自动添加预定义的后缀并查询,直到返回结果。

例如查询域名为 nas,定义的后缀为 local, foo.ts.net,则依次查询

nas
nas.local
nas.foo.ts.net

直到返回结果为止,这对使用 tailscale 等协议组网的用户特别方便。

在上述示例中,只需将应用程序中的域名配置为 nas,即可在各种网络环境下通用:

  • 当两台设备在同一个物理局域网时,smartdns 首先从 Dnsmasq 的租约文件中查询,如果没有找到则使用 mDNS 协议查询,从而解析至物理内网 ip
  • 当两台设备处于异地并使用 tailscale 组网时,前两次查询都会失败,第三次查询时则会获取到 tailscale 的内网 ip
@moetayuko
Copy link
Contributor Author

目前找到的一种替代方案是在 DHCP 服务器(如 dnsmasq)通过 domain-search 选项设置备选后缀,从而让客户端查询 DNS 时自行处理 https://github.com/imp/dnsmasq/blob/770bce967cfc9967273d0acfb3ea018fb7b17522/dnsmasq.conf.example#L412

@cresky-github
Copy link

smartdns采用的是穷举法。
简单来说,就是已知/未知区别。

已知,就穷举。
未知,就是默认DNS组的事了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants