• Ubuntu 20.04 设置 DNS 的方法


     

    如题,Ubuntu 20.04 LTS 版本安装之后,发现偶尔报错 Temporary failure in name resolution,搜索一番之后大部分意见认为是系统的DNS设置不全面,建议重新设置一下DNS。

    按照网上的文章,直接修改的是/etc/resolv.conf ,原文内容如下:

    nameserver 127.0.0.53
    options edns0 trust-ad
    直接添加新的dns,例如:

    nameserver 8.8.8.8
    nameserver 114.114.114.114
    结果reboot重启之后,还是原来的内容不变,仔细查看才发现/etc/resolv.conf本身在第一行的注释里面已经写了“Do not edit"。经过查阅相关资料,找到如下方法可以修改Ubuntu20.04 LTS版本的DNS,

    首先修改 /etc/systemd/resolved.conf 文件,在其中添加dns信息,例如:

    DNS=8.8.8.8 114.114.114.114
    然后退出保存。

    然后以root身份在ubuntu终端中依次执行如下命令:

    systemctl restart systemd-resolved
    systemctl enable systemd-resolved

    mv /etc/resolv.conf /etc/resolv.conf.bak
    ln -s /run/systemd/resolve/resolv.conf /etc/
    再查看/etc/resolv.conf文件就可以看到新的dns信息已经写入其中了。

  • 相关阅读:
    如何编写vue的javascript代码结构
    二进制文件下载兼容写法
    swtich
    报错:Uncaught ReferenceError: JSENCRYPT_VERSION is not defined
    use application gateway to expose aks service over http/https
    quicksort和第k小元素问题
    quick sort
    高精度加法
    滑动窗口的最大值
    字典树
  • 原文地址:https://www.cnblogs.com/mouseleo/p/15693953.html
Copyright © 2020-2023  润新知