Amazon EC2 Ubuntu 20 - DNS 解析不起作用
我也发布了我的解决方案。我希望这可以为其他人节省很多时间。
我有一个运行 Ubuntu 20 的 EC2 实例。DNS 解析从来不工作,或者经常失败。
我的文件 /etc/resolv.conf 有
nameserver 127.0.0.53
该文件不是符号链接,我当然可以编辑它以使用 nameserver 8.8.8.8 ,
但是该文件会定期被覆盖,并且 127.0.0.53 (或其他内容)类似)回来了。
我只是想让 dns 工作!
请参阅下面我的解决方案。
I posted my solution too. I hope this saves someone else a lot of time.
I have an EC2 instance running Ubuntu 20. DNS resolution never works, or fails a lot.
My file /etc/resolv.conf has
nameserver 127.0.0.53
The file is not a symlink, and I can certainly edit it to use nameserver 8.8.8.8 ,
But the file periodically gets overwritten and the 127.0.0.53 (or something similar) is back.
I just want dns to work!
See my solution below.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
从配置文件中获取您的网卡名称。
cat /etc/netplan/50-cloud-init.yaml
在我的系统上,亚马逊将网卡名称设置为 ens5。
以 root 身份创建新文件:/etc/netplan/99-custom-dns.yaml
包含以下内容。
将 ens5 替换为您的网卡名称。
<前><代码>网络:
版本:2
以太网:
恩斯5:
名称服务器:
地址:[8.8.8.8]
dhcp4-覆盖:
使用 dns: false
重新启动
现在 sudo shutdown -r
验证。重新启动后,您可以尝试按名称 ping 某些内容
ping yahoo.com
执行 ping 操作,或者您可以查看以下输出:
这是 Amazon 帮助文档的链接,但它错过了有关您的网卡名称的重要详细信息:
https://aws.amazon.com/premiumsupport /知识中心/ec2-static-dns-ubuntu-debian/
Get your nic's name from a config file.
cat /etc/netplan/50-cloud-init.yaml
On my system, amazon sets the nic name to ens5.
As root create new file: /etc/netplan/99-custom-dns.yaml
with the following content.
Replace ens5 with your nic's name.
Reboot
sudo shutdown -r now
Verify. After the reboot you can try pinging something by name
ping yahoo.com
or you can view the output of:
Here's a link to the Amazon help doc, though it misses the nontrivial detail about your nic's name:
https://aws.amazon.com/premiumsupport/knowledge-center/ec2-static-dns-ubuntu-debian/