Proxy環境でubuntu18.04LTS Serverでapt updateを実施したらエラーになった件

Proxy環境でubuntu18.04LTS Serverでapt updateを実施したらエラーが発生しました

18.04LTS Serverをインストール後、apt updateを実施したらエラーでアップデート、アップグレードができませんでした。

発生したエラー

$ sudo apt update
[sudo] password for spdsk:
Err:1 http://archive.ubuntu.com/ubuntu bionic InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:2 http://security.ubuntu.com/ubuntu bionic-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:3 http://archive.ubuntu.com/ubuntu bionic-updates InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Err:4 http://archive.ubuntu.com/ubuntu bionic-backports InRelease
  Temporary failure resolving 'archive.ubuntu.com'
Reading package lists... Done
Building dependency tree
Reading state information... Done
128 packages can be upgraded. Run 'apt list --upgradable' to see them.
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-updates/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/bionic-backports/InRelease  Temporary failure resolving 'archive.ubuntu.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/bionic-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Some index files failed to download. They have been ignored, or old ones used instead.

Proxyの設定はインストール時に登録したので大丈夫かと思ったのですが、ダメだったようなので手動で追加してみます。

Proxyの設定を追加

/etc/environmentにProxyの設定を追記します。追加するのはproxyサーバのアドレスとポート番号です。認証が必要な場合は、認証情報も追加します。

$ sudo vi /etc/environment

http_proxy="http://proxy-:port/"
https_proxy="http://proxy-:port/"

再度、apt updateを実行

Proxy設定を追加後のapt updateは成功しました。

$ sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:2 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Get:4 http://archive.ubuntu.com/ubuntu bionic/universe Sources [9,051 kB]
Get:5 http://archive.ubuntu.com/ubuntu bionic/restricted Sources [5,324 B]
Get:6 http://archive.ubuntu.com/ubuntu bionic/main Sources [829 kB]
Get:7 http://archive.ubuntu.com/ubuntu bionic/multiverse Sources [181 kB]
Get:8 http://archive.ubuntu.com/ubuntu bionic/main Translation-en [516 kB]
Get:9 http://security.ubuntu.com/ubuntu bionic-security InRelease [83.2 kB]
Get:10 http://archive.ubuntu.com/ubuntu bionic/restricted amd64 Packages [9,184 B]
Get:11 http://archive.ubuntu.com/ubuntu bionic/restricted Translation-en [3,584 B]
Get:12 http://archive.ubuntu.com/ubuntu bionic/universe amd64 Packages [8,570 kB]
Get:13 http://security.ubuntu.com/ubuntu bionic-security/universe Sources [9,156 B]
Get:14 http://security.ubuntu.com/ubuntu bionic-security/main Sources [37.3 kB]
Get:15 http://security.ubuntu.com/ubuntu bionic-security/multiverse Sources [1,336 B]
Get:16 http://security.ubuntu.com/ubuntu bionic-security/main Translation-en [49.4 kB]
Get:17 http://security.ubuntu.com/ubuntu bionic-security/universe amd64 Packages [38.7 kB]
Get:18 http://archive.ubuntu.com/ubuntu bionic/universe Translation-en [4,941 kB]
Get:19 http://security.ubuntu.com/ubuntu bionic-security/universe Translation-en [22.8 kB]
Get:20 http://security.ubuntu.com/ubuntu bionic-security/multiverse amd64 Packages [1,440 B]
Get:21 http://security.ubuntu.com/ubuntu bionic-security/multiverse Translation-en [996 B]
Get:22 http://archive.ubuntu.com/ubuntu bionic/multiverse amd64 Packages [151 kB]
Get:23 http://archive.ubuntu.com/ubuntu bionic/multiverse Translation-en [108 kB]
Get:24 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Sources [2,676 B]
Get:25 http://archive.ubuntu.com/ubuntu bionic-updates/universe Sources [46.8 kB]
Get:26 http://archive.ubuntu.com/ubuntu bionic-updates/main Sources [148 kB]
Get:27 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages [266 kB]
Get:28 http://archive.ubuntu.com/ubuntu bionic-updates/main Translation-en [101 kB]
Get:29 http://archive.ubuntu.com/ubuntu bionic-updates/universe amd64 Packages [138 kB]
Get:30 http://archive.ubuntu.com/ubuntu bionic-updates/universe Translation-en [62.4 kB]
Get:31 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse amd64 Packages [3,772 B]
Get:32 http://archive.ubuntu.com/ubuntu bionic-updates/multiverse Translation-en [2,376 B]
Get:33 http://archive.ubuntu.com/ubuntu bionic-backports/universe Sources [1,160 B]
Get:34 http://archive.ubuntu.com/ubuntu bionic-backports/universe amd64 Packages [2,704 B]
Get:35 http://archive.ubuntu.com/ubuntu bionic-backports/universe Translation-en [1,136 B]
Fetched 25.5 MB in 47s (545 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
128 packages can be upgraded. Run 'apt list --upgradable' to see them.

apt upgradeを実行

apt updateが成功したので、apt upgradeを実行しました。

$ sudo apt upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
  apport apt apt-utils base-files bind9-host bsdutils cloud-init command-not-found
  command-not-found-data console-setup console-setup- curl dirmngr distro-info-data dnsutils
  ebtables fdisk file git git-man gnupg gnupg-l10n gnupg-utils gpg gpg-agent gpg-wks-client
  gpg-wks-server gpgconf gpgsm gpgv grub-common grub-pc grub-pc-bin grub2-common initramfs-tools
  initramfs-tools-bin initramfs-tools-core keyboard-configuration landscape-common
  language-selector-common libapt-inst2.0 libapt-pkg5.0 libbind9-160 libblkid1 libcurl3-gnutls
  libcurl4 libdns-export1100 libdns1100 libfdisk1 libgcrypt20 libirs160 libisc-export169 libisc169
  libisccc160 libisccfg160 liblwres160 liblxc-common liblxc1 libmagic-mgc libmagic1 libmount1
  libncurses5 libncursesw5 libnss-systemd libpam-systemd libperl5.26 libpng16-16
  libpolkit-agent-1-0 libpolkit-backend-1-0 libpolkit-gobject-1-0 libprocps6 libpython3-stdlib
  libsmartcols1 libssl1.0.0 libssl1.1 libsystemd0 libtinfo5 libudev1 libuuid1 -firmware
  -signed-generic lxcfs lxd lxd-client mdadm mount ncurses-base ncurses-bin ncurses-term
  netcat-openbsd netplan.io networkd-dispatcher nplan openssl perl perl-base perl-modules-5.26
  policykit-1 pollinate procps python-apt-common python3 python3-apport python3-apt
  python3-commandnotfound python3-cryptography python3-distupgrade python3-minimal
  python3-problem-report python3-software-properties python3-update-manager screen snapd
  software-properties-common sosreport squashfs-tools ssh-import-id systemd systemd-sysv
  ubuntu-release-upgrader-core udev unattended-upgrades update-manager-core update-notifier-common
  util- uuid-runtime wget wireless-regdb
128 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 126 MB of archives.
After this operation, 12.5 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 base-files amd64 10.1ubuntu2.1 [58.0 kB]

***長いので以下略***

Proxy設定を追加することで、正常にupgradeができました。

スポンサーリンク
spdsk-side
spdsk-side