基于 HTTPS 的 DNS 和基于 TLS 的 DNS | 安全 DNS

DNS 查询以明文形式发送,这意味着任何人都可以读取它们。基于 HTTPS 的 DNS 和基于 TLS 的 DNS 都会加密 DNS 查询和响应,以确保用户浏览的安全性和私密性。不过,两种方法各有缺点。

学习目标

阅读本文后,您将能够:

  • 了解为什么 DNS 需要更高的安全性,以及为什么 DNS 隐私很重要
  • 了解基于 TLS(SSL)的 DNS 和基于 HTTPS 的 DNS 的工作方式,以及这两者之间的区别。
  • 探讨两种方法的优缺点
  • 比较基于 TLS/HTTPS 的 DNS 和 DNSSEC

复制文章链接

为什么 DNS 需要额外的安全层?

DNS is the phonebook of the Internet; DNS resolvers translate human-readable domain names into machine-readable IP addresses. By default, DNS queries and responses are sent in plaintext (via UDP), which means they can be read by networks, ISPs, or anybody able to monitor transmissions. Even if a website uses HTTPS, the DNS query required to navigate to that website is exposed.

This lack of privacy has a huge impact on security and, in some cases, human rights; if DNS queries are not private, then it becomes easier for governments to censor the Internet and for attackers to stalk users' online behavior.

Attacker views unsecured DNS traffic

Think of a normal, unencrypted DNS query as being like a postcard sent through the mail: anyone handling the mail may happen to catch a glimpse of the text written on the back side, so it is not wise to mail a postcard that contains sensitive or private information.

DNS over TLS and DNS over HTTPS are two standards developed for encrypting plaintext DNS traffic in order to prevent malicious parties, advertisers, ISPs, and others from being able to interpret the data. Continuing the analogy, these standards aim to put an envelope around all postcards going through the mail, so that anyone can send a postcard without worrying that someone is snooping on what they are up to.

DNS queries secured over TLS or HTTPS, attacker blocked

什么是基于 TLS 的 DNS?

DNS over TLS, or DoT, is a standard for encrypting DNS queries to keep them secure and private. DoT uses the same security protocol, TLS, that HTTPS websites use to encrypt and authenticate communications. (TLS is also known as "SSL.") DoT adds TLS encryption on top of the user datagram protocol (UDP), which is used for DNS queries. Additionally, it ensures that DNS requests and responses are not tampered with or forged via on-path attacks.

什么是基于 HTTPS 的 DNS?

DNS over HTTPS, or DoH, is an alternative to DoT. With DoH, DNS queries and responses are encrypted, but they are sent via the HTTP or HTTP/2 protocols instead of directly over UDP. Like DoT, DoH ensures that attackers can't forge or alter DNS traffic. DoH traffic looks like other HTTPS traffic – e.g. normal user-driven interactions with websites and web apps – from a network administrator's perspective.

In February 2020, the Mozilla Firefox browser began enabling DoH for U.S. users by default. DNS queries from the Firefox browser are encrypted by DoH and go to either Cloudflare or NextDNS. Several other browsers also support DoH, although it is not turned on by default.

等等,HTTPS 不也是将 TLS 用于加密的?基于 HTTPS 的 DNS 和基于 TLS 的 DNS 有何区别?

Each standard was developed separately and has its own RFC* documentation, but the most important difference between DoT and DoH is what port they use. DoT only uses port 853, while DoH uses port 443, which is the port that all other HTTPS traffic uses as well.

Because DoT has a dedicated port, anyone with network visibility can see DoT traffic coming and going, even though the requests and responses themselves are encrypted. In contrast, with DoH, DNS queries and responses are camouflaged within other HTTPS traffic, since it all comes and goes from the same port.

*RFC stands for "Request for Comments", and an RFC is a collective attempt by developers, networking experts, and thought leaders to standardize an Internet technology or protocol.

什么是端口?

在网络中,端口是计算机上的虚拟位置,开放给来自其他计算机的连接。每台联网计算机都有标准数量的端口,并且每个端口都保留用于特定类型的通信。

这可以比作港口中船舶的泊位:每个运输泊位都有编号,不同种类的船舶应该要前往特定的运输泊位来卸货或下客。网络中同样如此:某些类型的通信应该前往特定的网络端口。区别在于网络端口是虚拟的;它们是用于数字连接而非物理连接的地方。

DoT 和 DoH 哪个更好?

This is up for debate. From a network security standpoint, DoT is arguably better. It gives network administrators the ability to monitor and block DNS queries, which is important for identifying and stopping malicious traffic. DoH queries, meanwhile, are hidden in regular HTTPS traffic, meaning they cannot easily be blocked without blocking all other HTTPS traffic as well.

但从隐私角度来看,DoH 可以说是更可取的。使用 DoH 时,DNS 查询隐藏在较大的 HTTPS 流量中。这削弱了网络管理员的可见性,但增强了用户的隐私性。

1.1.1.1 是 Cloudflare 的免费 DNS 解析器,同时支持 DoT 和 DoH。

基于 TLS/HTTPS DNS 和 DNSSEC 之间有何区别?

DNSSEC is a set of security extensions for verifying the identity of DNS root servers and authoritative nameservers in communications with DNS resolvers. It is designed to prevent DNS cache poisoning, among other attacks. It does not encrypt communications. DNS over TLS or HTTPS, on the other hand, does encrypt DNS queries. 1.1.1.1 supports DNSSEC as well.

若要进一步了解 1.1.1.1,请参阅什么是 1.1.1.1