我无法使用我的 Elastic Compute Cloud (Amazon EC2) 实例解析 Amazon Route 53 私有托管区域记录。
简短描述
通过 systemd-resolved 服务的 Linux 操作系统发行版,使用存根解析器处理 DNS 查询。存根解析程序 IP 位于 /etc/resolv.conf。本地 DNS 存根侦听器不会转发带有“.local”后缀的域名的 DNS 请求。DNS 请求失败,并显示与以下输出类似的响应代码 “ServFail”:
### failed ###
ubuntu@ip-172-31-2-3:~$ dig example.local.
; <<>> DiG 9.18.1-1ubuntu1.1-Ubuntu <<>> example.local.
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to DNS
;; ->>HEADER<<- opcode: QUERY, status: SERVFAIL, id: 29563 ### status: SERVFAIL ###
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;example.local. IN A
;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP) ### 127.0.0.53 is systemd-resolved ###
;; WHEN: Thu Jun 30 12:34:56 UTC 2022
;; MSG SIZE rcvd: 42
### success ###
ubuntu@ip-172-31-2-3:~$ dig example.local. @172.31.0.2 ### dig to @172.31.0.2 AmazonProvidedDNS / Route 53 Resolver ###
; <<>> DiG 9.18.1-1ubuntu1.1-Ubuntu <<>> example.local. @172.31.0.2
;; global options: +cmd
;; Got answer:
;; WARNING: .local is reserved for Multicast DNS
;; You are currently testing what happens when an mDNS query is leaked to DNS
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29352 ### status: NOERROR ###
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;example.local. IN A
;; ANSWER SECTION:
example.local. 300 IN A 192.0.2.1
;; Query time: 4 msec
;; SERVER: 172.31.0.2#53(172.31.0.2) (UDP) ### 172.31.0.2 is AmazonProvidedDNS / Route 53 Resolver ###
;; WHEN: Thu Jun 30 12:34:56 UTC 2022
;; MSG SIZE rcvd: 58
解决方法
要解析带有 “.local” 后缀的域名,请使用外部解析器而不是本地 DNS 存根侦听器。
**注意:**最好避免使用域名“.local”后缀,因为 RFC 6762 将此域名专供Multicast DNS 使用。
1. 将 DNS 解析器从本地 DNS 存根侦听器更改为外部 DNS 解析器(AmazonProvidedDNS)。
cd /etc/
sudo ln -sf ../run/systemd/resolve/resolv.conf
2. 更改 .conf 以停止本地 DNS 存根侦听器。
cd /etc/systemd/
sudo cp -ip resolved.conf resolved.conf.org
sudo sed -i -e 's/#DNSStubListener=yes/DNSStubListener=no/' resolved.conf
3. 重新启动 systemd-resolved。
sudo systemctl restart systemd-resolved
相关信息
Amazon Route 53 DNS 的最佳实践
如何排查 Route 53 私有托管区域的 DNS 解析问题?