![如何从 netplan 配置 /etc/resolv.conf 中的 ndots 选项?](https://linux22.com/image/1176252/%E5%A6%82%E4%BD%95%E4%BB%8E%20netplan%20%E9%85%8D%E7%BD%AE%20%2Fetc%2Fresolv.conf%20%E4%B8%AD%E7%9A%84%20ndots%20%E9%80%89%E9%A1%B9%EF%BC%9F.png)
我使用 netplan 管理一个简单的桥接器,并且从同一台服务器使用 BIND 提供 DNS 服务,除了相对域解析之外,一切都运行良好。
host -t A foo
输出:
foo.example.com has address 192.168.0.3
但host -t A bar.foo
(这是 的别名foo
)输出:
Host bar.foo not found: 3(NXDOMAIN)
即使ping bar.foo
正确解析了域别名并输出:
PING foo.example.com (192.168.0.3) 56(84) bytes of data.
我认为可以通过在指令ndots:2
中添加来控制这一点,以便将第二个查询视为相对查询,但这当然不是一个可直接编辑的文件。从 netplan 传递此配置的正确方法是什么?或者有其他地方可以指定?如果可以避免,我不想制作常规文件。options
/etc/resolv.conf
/etc/resolv.conf
我没有找到任何有用的solved.conf 手册页。
/etc/netplan/00-my-config.yaml
:
network:
ethernets:
eno1:
dhcp4: false
dhcp6: false
version: 2
bridges:
br0:
interfaces:
- eno1
addresses:
- 192.168.0.2/24
gateway4: 192.168.0.1
nameservers:
addresses:
- 192.168.0.2
- 192.168.0.1
search:
- example.com
/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 "resolvectl 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 at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
options edns0
search example.com
答案1
您有两个不同的问题:
host -t A bar.foo
明确查找“bar.foo”的“A”记录。假设您的意思是“bar.foo”是“foo”的 CNAME,我认为指定-t A
应该返回 NXDOMAIN,因为没有 A 记录。- Netplan.io 负责
system-resolved
DNS 管理。systemd 似乎明确选择不支持类似 ndots 的功能。我认为这是一个没有实际意义的问题,因为您的问题是由于您host
对上面描述的命令的选择造成的。