• 该方法适合老版本的ubuntu,新版本20.04以上的dns修改方法如下:

    1.修改 /etc/systemd/resolved.conf 文件,在其中添加dns信息,例如:DNS= 8.8.8.8 114.114.114.114
    # See resolved.conf(5) for details

    [Resolve]
    DNS= 8.8.8.8 114.114.114.114
    #FallbackDNS=
    #Domains=
    #LLMNR=no
    #MulticastDNS=no
    #DNSSEC=no
    #DNSOverTLS=no
    #Cache=no-negative
    #DNSStubListener=yes
    #ReadEtcHosts=yes
    保存后退出

    2. 以root身份运行命令
    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信息已经写入其中了

WirelessLink
Logo