在 Ubuntu 22.04 中删除多余的 DNS 服务器

在 Ubuntu 22.04 中删除多余的 DNS 服务器

Ubuntu 22.04

原来的:

root@ubuntu:~# resolvectl
Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (ens5)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 12.34.56.78
       DNS Servers: 12.34.56.78 12.34.56.79

我做了什么:

  1. 在文件中添加nameservers条目/etc/netplan/01-netcfg.yaml
# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    ens5:
      dhcp4: yes
      nameservers:
        addresses: [8.8.8.8, 1.1.1.1]
netplan apply
  1. /etc/systemd/resolved.conf在文件中添加 DNS 服务器
[Resolve]
DNS=8.8.8.8 1.1.1.1
FallbackDNS=8.8.4.4
systemctl restart systemd-resolved
systemctl enable systemd-resolved

重启后:

root@ubuntu:~# resolvectl
Global
           Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
    resolv.conf mode: stub
  Current DNS Server: 8.8.8.8
         DNS Servers: 8.8.8.8 1.1.1.1
Fallback DNS Servers: 8.8.4.4

Link 2 (ens5)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 8.8.8.8
       DNS Servers: 8.8.8.8 1.1.1.1 12.34.56.78 12.34.56.79

如何删除DNS 服务器列表中的12.34.56.78和?12.34.56.79

相关内容