我有幾個 17.10 執行個體在 VPC 上的 Amazon EC2 中運行。當我重新啟動伺服器時(不確定是否發生在冷啟動時,我沒有測試過),該/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
或類似的東西?