我的 Centos 7 服务器无法正确解析域名。据我所知,在现代 Linux 系统/etc/resolv.conf中,通常使用dhclient, dnsmasq或Network Manager.
因此,我有一个关于现代 Linux 中网络堆栈的一般理论问题:
谁负责阅读/etc/resolv.conf?域名解析涉及哪些参与者(服务或内核子系统)?
简短回答: Arch linux 手册说域名解析的高级配置是 /etc/nsswitch.conf在名称服务切换glibcAPI 中完成并依赖的。
glibc使用nss-resolve函数向 DNS 服务器发送 DNS 请求。
通常现代 CentOS 系统nss-resolve 依赖于 systemd-resolved服务。If/etc/resolv.conf是由类似的东西生成的dhclient-script,systemd-resolved读取它并在兼容模式下工作,模拟旧系统(如BINDDNS 客户端)的行为。
我该如何理解 的格式/etc/resolv.conf?
$ cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink …Run Code Online (Sandbox Code Playgroud) 我该如何理解 的输出dig?
DNS 服务器存储资源记录的数据库。
是否dig返回某个 DNS 服务器的数据库中的资源记录?如果是,dig返回的是哪个 DNS 服务器的数据库资源记录?
例如,dig似乎没有返回 DNS 服务器数据库中的资源记录a.edu-servers.net。
$ dig @a.edu-servers.net robot.cs.washington.edu
; <<>> DiG 9.11.3-1ubuntu1.3-Ubuntu <<>> @a.edu-servers.net robot.cs.washington.edu
; (2 servers found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 2401
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 3, ADDITIONAL: 7
;; WARNING: recursion requested but not available
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: …Run Code Online (Sandbox Code Playgroud)