我在 VPC 上的 Amazon EC2 中运行了一些 17.10 实例。当我刚刚重启服务器时(不确定是否在冷启动时发生,我没有测试过),文件/etc/resolv.conf
显示为空:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
名称解析按预期失败,例如当通过其内部 DNS 名称连接到私有子网上具有静态 IP 的服务器时:
ssh: Could not resolve hostname example: Temporary failure in name resolution
现在,如果我等待一段时间,突然就会出现正确的值/etc/resolv.conf
:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 127.0.0.53
search subdomain.example.com
命令systemd-resolve --status
报告相同。/etc/resolv.conf
如果我手动强制续订,该文件也会正确设置dhclient
,并且我知道这些值来自 EC2 DHCP 服务器。
所以问题是:我的配置缺少哪部分,导致这种情况在启动时无法立即发生?
将这些值直接添加到类似的东西中/etc/resolvconf/resolv.conf.d/base
是可行的,但我认为,我正在对应该通过 DHCP 到达的东西进行硬编码。我/etc/netplan
也查看过(ifupdown
未被使用),这似乎来自云初始化的东西,所以我想知道我是否遗漏了某些东西/etc/cloud/cloud.cfg
或类似的东西?