查看ubuntu版本

cat /etc/issue
Ubuntu 18.04.6 LTS \n \l

resolved.conf配置示例

vim /etc/systemd/resolved.conf

配置dns信息

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
DNS=223.6.6.6 223.5.5.5 8.8.8.8 114.114.114.114
FallbackDNS=8.8.8.8
#Domains=
LLMNR=yes
MulticastDNS=yes
#DNSSEC=allow-downgrade
#DNSOverTLS=no
Cache=yes
#DNSStubListener=yes
#ReadEtcHosts=yes

重启systemd-resolved服务

systemctl restart systemd-resolved

查看dns信息

systemd-resolve --status | grep 'DNS Servers' -A2