Ubuntu部分问题处理记录

18.04 出现/etc/resolv.confnameserver自动变成127.0.0.53

现象:修改了/etc/resolv.conf中的nameserver配置后重启自动变成127.0.0.53。

查看/etc/resolv.conf

cat /etc/resolv.conf 

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0

发现第一行就说明了这个文件由systemd-resolved进行管理,所以编辑这里无效

查看/etc/systemd/resolved.conf配置文件,发现并做任何DNS配置

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

DNS部分按以下格式修改并重启服务

DNS=223.5.5.5
FallbackDNS=114.114.114.114
systemctl daemon-reload
systemctl restart systemd-resolved
systemd-resolve --status

# 最终DNS配置的文件存放在/run/systemd/resolve/resolv.conf中,修改/etc/resolv.conf的软链接即可
rm -rf /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

20.04 更新后启动等待时间为30秒

修改/etc/default/grub中的GRUB_TIMEOUT=3发现仍不生效 查看/boot/grub/grub.cfg,发现是从/etc/grub.d/00_header中获取的

#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  set have_grubenv=true
...

/etc/grub.d/00_header中有一个GRUB_RECORDFAIL_TIMEOUT变量,如果没定义这个变量的值,那会定义一个30秒的默认值。

...
if [ "\${recordfail}" = 1 ] ; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
else
...
if [ \$grub_platform = efi ]; then
  set timeout=${GRUB_RECORDFAIL_TIMEOUT:-30}
  if [ x\$feature_timeout_style = xy ] ; then
    set timeout_style=menu
  fi
fi
...

将这两个默认值改小,然后执行update-grub命令,更新一下即可

最后更新于