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

Proposal for resolving local domain in built-in DNS #88

Closed
Vigilans opened this issue Aug 9, 2020 · 2 comments · Fixed by #89
Closed

Proposal for resolving local domain in built-in DNS #88

Vigilans opened this issue Aug 9, 2020 · 2 comments · Fixed by #89

Comments

@Vigilans
Copy link
Contributor

Vigilans commented Aug 9, 2020

你正在使用哪个版本的 V2Ray?

4.27.0

你的使用场景是什么?

透明代理/开放DNS服务器到53端口供局域网内使用

你看到的不正常的现象是什么?

V2Ray的内置DNS拒绝解析无点的域名。无点的域名不仅不能交由DNS Server解析,也无法进入Static Host查询:

func (s *Server) lookupIPInternal(domain string, option IPOption) ([]net.IP, error) {
if domain == "" {
return nil, newError("empty domain name")
}
// normalize the FQDN form query
if domain[len(domain)-1] == '.' {
domain = domain[:len(domain)-1]
}
// skip domain without any dot
if !strings.Contains(domain, ".") {
return nil, newError("invalid domain name").AtWarning()
}
ips := s.lookupStatic(domain, option, 0)

这导致的问题有:

你期待看到的正确表现是怎样的?

内置DNS应当对无点/本地域名提供更好的支持,包括:

  • 允许无点域交由Static Host与DNS Server查询,并且提供对于无点域的匹配能力。
  • 由于无点域及本地域名往往只有本地DNS才能给出解析,因此对于该类域名应优先交给系统DNS处理。

以下是对支持方法的提案:

  • 移除对于域名是否带点的检查。
  • 提供一个新规则: dotless:<substr>。该规则用于匹配无点域名。当<substr>被设置时,无点的域名需要进一步匹配作为子串的<substr>。未设置时则匹配所有无点域名。
  • 当DNS服务器中设置了"localhost"且没有为其设置"domain"字段时,默认为其配置三条匹配规则:无点域名、.local域名与.localdomain域名。也即以下配置:
     "servers": ["localhost"]
    与以下配置等价:
    "servers": [{
       "address": "localhost",
       "domains": ["dotless:", "domain:local", "domain:localdomain"]
     }]
    
    这样只在本地有意义的域名将优先送给"localhost"查询,而非经过外部DNS然后返回大量的SERVFAIL。

参考资料

@Loyalsoldier
Copy link
Contributor

容我厚颜无耻地提一个请求:方便的话,麻烦把 DNS 模块的这个 bug 也修一下 v2fly/domain-list-community#91 (comment)

路由模块对于规则都是优先匹配,而 DNS 模块对于规则是最后匹配,希望 DNS 模块跟路由模块保持一致:优先匹配域名。

@Vigilans
Copy link
Contributor Author

Vigilans commented Aug 9, 2020

@Loyalsoldier hhh这个我也注意到了,当时看了代码,这是因为用于域名匹配的Trie树实现造成的问题,导致后插入的优先匹配(并且只会尝试匹配这个,因为旧规则被覆盖了)。

当初想一起提的,不过后来觉得跟问题不是很相关,还是个breaking change(虽然利用这个feature的估计很少……),并且调教出了合适的配置,就先放着了。。

@kslr kslr closed this as completed in #89 Aug 9, 2020
xiaokangwang pushed a commit to xiaokangwang/v2ray-core-1 that referenced this issue Sep 15, 2024
Add reference on README.ENG.MD
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

Successfully merging a pull request may close this issue.

2 participants