Amazon EC2 Ubuntu 20 - DNS 解析不起作用

发布于 2025-01-15 00:15:28 字数 382 浏览 3 评论 0原文

我也发布了我的解决方案。我希望这可以为其他人节省很多时间。


我有一个运行 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灰色世界里的红玫瑰 2025-01-22 00:15:28
  1. 从配置文件中获取您的网卡名称。

    cat /etc/netplan/50-cloud-init.yaml

在我的系统上,亚马逊将网卡名称设置为 ens5。

  1. 以 root 身份创建新文件:/etc/netplan/99-custom-dns.yaml
    包含以下内容。
    ens5 替换为您的网卡名称。

    <前><代码>网络:
    版本:2
    以太网:
    恩斯5:
    名称服务器:
    地址:[8.8.8.8]
    dhcp4-覆盖:
    使用 dns: false

  2. 重新启动

    现在 sudo shutdown -r

  3. 验证。重新启动后,您可以尝试按名称 ping 某些内容

    ping yahoo.com

执行 ping 操作,或者您可以查看以下输出:

systemd-resolve --status
  1. 完成

这是 Amazon 帮助文档的链接,但它错过了有关您的网卡名称的重要详细信息:
https://aws.amazon.com/premiumsupport /知识中心/ec2-static-dns-ubuntu-debian/

  1. 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.

  1. As root create new file: /etc/netplan/99-custom-dns.yaml
    with the following content.
    Replace ens5 with your nic's name.

      network:
         version: 2
         ethernets:
             ens5:         
                 nameservers:
                         addresses: [8.8.8.8]
                 dhcp4-overrides:
                         use-dns: false
    
  2. Reboot

    sudo shutdown -r now

  3. Verify. After the reboot you can try pinging something by name

    ping yahoo.com

or you can view the output of:

systemd-resolve --status
  1. Done

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/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文