Ubuntu(Bionic)的DNS配置

有关Ubuntu 18.04的DNS设置似乎又发生了变化,导致我遇到了问题,所以记录一下。

将DNS设置固定为Google(8.8.8.8)的方法。

/etc/systemd/resolved.conf 可以用以下方式来翻译:
/etc/systemd/resolved.conf

#  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=8.8.8.8
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=udp

search=hoge.co.jp #searchはデフォルトでは書いてませんが、手動で書いてあげれば検索してくれるようです。(20180801追記)

DNS=已被注释掉,按照上述方式即可。

应用设置

systemctl restart systemd-resolved

确认可以通过以下方式进行。

systemd-resolve --status
cat /var/run/systemd/resolve/resolv.conf

好像是做成了。