Ubuntu 20.04 LTSで突然、apt update不可によるDNS設定変更


●事象:apt updateの接続不可
古いバージョンのためと思いアップグレードしようとしましたが、Ubuntuのバグです。

エラー:1 http://ppa.launchpad.net/openjdk-r/ppa/ubuntu focal InRelease
  'ppa.launchpad.net' が一時的に解決できません
エラー:2 http://jp.archive.ubuntu.com/ubuntu focal InRelease
  'jp.archive.ubuntu.com' が一時的に解決できません
エラー:3 http://security.ubuntu.com/ubuntu focal-security InRelease
  'security.ubuntu.com' が一時的に解決できません
エラー:4 https://dl.google.com/linux/chrome/deb stable InRelease
  'dl.google.com' が一時的に解決できません
エラー:5 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease
  'jp.archive.ubuntu.com' が一時的に解決できません
エラー:6 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease
  'jp.archive.ubuntu.com' が一時的に解決できません

●Ubutunのバグ箇所(2箇所)及び修正箇所(1箇所)
cat /etc/resolv.conf
ubuntuがデフォルトで設定しているnameserverのIPアドレスに問題がある。
***********************************************************
nameserver 127.0.0.53
options edns0 trust-ad
***********************************************************

シンボリックリンクの参照先が別のところになっている
ls -l /etc/resolv.conf
***********************************************************
# lrwxrwxrwx 1 root root 39 12月 13 23:01 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf
***********************************************************

下記は個別事象ですが、@nifty(下記は@niftyで指定されていたネームサーバー)を過去に設定していた場合、ネームサーバが廃止されている場合がある
cat /etc/netplan/50-cloud-init.yml
***********************************************************
# Let NetworkManager manage all devices on this system
network:
  wlp1s0:
    dhcp4: false
    dhcp6: false
    addresses: [xxx.xxx.xxx.xxx/24]
    gateway4: xxx.xxx.xxx.xxx
    nameservers:
      addresses: [202.248.37.74, 202.248.20.133,8.8.8.8, 8.8.4.4]
      search: [xxx.xxx]
    optional: true
    access-points:
      xxx:
        password: xxx
  version: 2
  renderer: NetworkManager
***********************************************************

●修正

1.pico /etc/systemd/resolve.conf
#DNS= ---> コメントアウトを外して、DNS=8.8.8.8
***********************************************************
#
#  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
#DNSOverTLS=no
#Cache=no-negative
#DNSStubListener=yes
#ReadEtcHosts=yes
***********************************************************

2.pico /etc/resolv.conf
nameserverを8.8.8.8のみに修正する
***********************************************************
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# 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 8.8.8.8
# nameserver 202.248.37.74
# nameserver 202.248.20.133
# Too many DNS servers configured, the following entries may be ignored.
nameserver xxx:xxx:xxx:xxx::xxx
nameserver xxx:xxx:xxx:xxx::xxx
search flets-east.jp iptvf.jp
***********************************************************

3.pico /etc/netplan/50-cloud-init.yml
202.248.37.74, 202.248.20.133, を削除する
(必要に応じて、8.8.8.8,8.8.4.4を追加する)
***********************************************************
# Let NetworkManager manage all devices on this system
network:
  wlp1s0:
    dhcp4: false
    dhcp6: false
    addresses: [xxx.xxx.xxx.xxx/24]
    gateway4: xxx.xxx.xxx.xxx
    nameservers:
      addresses: [8.8.8.8, 8.8.4.4]
      search: [xxx.xxx]
    optional: true
    access-points:
      xxx:
        password: xxx
  version: 2
  renderer: NetworkManager
***********************************************************

4.netplanを再適用、シンボリックリンクを外して張り直し、再起動し、確認
unlink /etc/resolv.conf
ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

netplan apply
systemctl restart systemd-resolved.service
systemctl status systemd-resolved.service
ls -l /etc/resolv.conf
***********************************************************
# lrwxrwxrwx 1 root root 32  1月 21 19:23 /etc/resolv.conf -> /run/systemd/resolve/resolv.conf
***********************************************************
apt update
apt upgrade

以上で問題なくapt update && apt upgradeを実行することができました
たまたま、キャリアのネットワーク障害も同時に発生していたのでビックリしました(笑)

  
 

コメント

このブログの人気の投稿

【更新:相互リンク許可】2025-2026シーズンのアースホッパーを考えたみた! & スノーバーズクラブ(八千穂高原スキー場シーズン券)を久々使ってみた結果

【NTTモデムの経年劣化による交換】VH-100「3」E「N」からVH-100「4」E「N」へ

Root化 for Galaxy S5 (SC-04F) ※自己責任