Ubuntu 18.* 系列刚安装好系统,修改成国内apt源报错解决
root@linux:/etc/apt# cat sources.list
#deb cdrom:[Ubuntu 18.04.2 LTS _Bionic Beaver_ - Release amd64 (20190210)]/ bionic main restricted
# See https://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb https://mirros.163.com/ubuntu/ bionic main restricted
# deb-src https://mirros.163.com/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb https://mirros.163.com/ubuntu/ bionic-updates main restricted
# deb-src https://mirros.163.com/ubuntu/ bionic-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb https://mirros.163.com/ubuntu/ bionic universe
# deb-src https://mirros.163.com/ubuntu/ bionic universe
deb https://mirros.163.com/ubuntu/ bionic-updates universe
# deb-src https://mirros.163.com/ubuntu/ bionic-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb https://mirros.163.com/ubuntu/ bionic multiverse
# deb-src https://mirros.163.com/ubuntu/ bionic multiverse
deb https://mirros.163.com/ubuntu/ bionic-updates multiverse
# deb-src https://mirros.163.com/ubuntu/ bionic-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb https://mirros.163.com/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src https://mirros.163.com/ubuntu/ bionic-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb https://archive.canonical.com/ubuntu bionic partner
# deb-src https://archive.canonical.com/ubuntu bionic partner
deb https://mirrors.163.com/ubuntu bionic-security main restricted
# deb-src https://mirrors.163.com/ubuntu bionic-security main restricted
deb https://mirrors.163.com/ubuntu bionic-security universe
# deb-src https://mirrors.163.com/ubuntu bionic-security universe
deb https://mirrors.163.com/ubuntu bionic-security multiverse
# deb-src https://mirrors.163.com/ubuntu bionic-security multiverse
这里修改成163源,然后,就各种尴尬卡顿报错
root@linux:/etc/apt# apt-get update
Hit:1 https://mirrors.163.com/ubuntu bionic-security InRelease
Err:2 https://mirros.163.com/ubuntu bionic InRelease
Could not connect to mirros.163.com:443 (223.87.179.191). - connect (111: Connection refused)
Err:3 https://mirros.163.com/ubuntu bionic-updates InRelease
Unable to connect to mirros.163.com:https:
Err:4 https://mirros.163.com/ubuntu bionic-backports InRelease
Unable to connect to mirros.163.com:https:
Reading package lists... Done
W: Failed to fetch https://mirros.163.com/ubuntu/dists/bionic/InRelease Could not connect to mirros.163.com:443 (223.87.179.191). - connect (111: Connection refused)
W: Failed to fetch https://mirros.163.com/ubuntu/dists/bionic-updates/InRelease Unable to connect to mirros.163.com:https:
W: Failed to fetch https://mirros.163.com/ubuntu/dists/bionic-backports/InRelease Unable to connect to mirros.163.com:https:
W: Some index files failed to download. They have been ignored, or old ones used instead.
有莫有看到,163网站地址给解析成了锤子 223.87.179.191。
解决办法就是直接在source.list文件中的mirrors.163.com换成163源的ip地址,怎么搞到它的地址呢?用nslookup命令
root@linux:~# nslookup mirrors.163.com
Server: 127.0.0.53
Address: 127.0.0.53#53
Non-authoritative answer:
Name: mirrors.163.com
Address: 59.111.0.251
然后修改source.list文件
root@linux:/etc/apt# cat sources.list
#deb cdrom:[Ubuntu 18.04.2 LTS _Bionic Beaver_ - Release amd64 (20190210)]/ bionic main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://59.111.0.251/ubuntu/ bionic main restricted
# deb-src http://59.111.0.251/ubuntu/ bionic main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://59.111.0.251/ubuntu/ bionic-updates main restricted
# deb-src http://59.111.0.251/ubuntu/ bionic-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team. Also, please note that software in universe WILL NOT receive any
## review or updates from the Ubuntu security team.
deb http://59.111.0.251/ubuntu/ bionic universe
# deb-src http://59.111.0.251/ubuntu/ bionic universe
deb http://59.111.0.251/ubuntu/ bionic-updates universe
# deb-src http://59.111.0.251/ubuntu/ bionic-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://59.111.0.251/ubuntu/ bionic multiverse
# deb-src http://59.111.0.251/ubuntu/ bionic multiverse
deb http://59.111.0.251/ubuntu/ bionic-updates multiverse
# deb-src http://59.111.0.251/ubuntu/ bionic-updates multiverse
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
deb http://59.111.0.251/ubuntu/ bionic-backports main restricted universe multiverse
# deb-src http://59.111.0.251/ubuntu/ bionic-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository.
## This software is not part of Ubuntu, but is offered by Canonical and the
## respective vendors as a service to Ubuntu users.
# deb http://archive.canonical.com/ubuntu bionic partner
# deb-src http://archive.canonical.com/ubuntu bionic partner
deb http://59.111.0.251/ubuntu bionic-security main restricted
# deb-src http://59.111.0.251/ubuntu bionic-security main restricted
deb http://59.111.0.251/ubuntu bionic-security universe
# deb-src http://59.111.0.251/ubuntu bionic-security universe
deb http://59.111.0.251/ubuntu bionic-security multiverse
# deb-src http://59.111.0.251/ubuntu bionic-security multiverse
注意,不要用https,还会报错。接着,apt-get update 测试一下
root@linux:/etc/apt# apt-get update
Hit:1 http://59.111.0.251/ubuntu bionic InRelease
Hit:2 http://59.111.0.251/ubuntu bionic-updates InRelease
Hit:3 http://59.111.0.251/ubuntu bionic-backports InRelease
Get:4 http://59.111.0.251/ubuntu bionic-security InRelease [88.7 kB]
Get:5 http://59.111.0.251/ubuntu bionic-security/main amd64 Packages [296 kB]
Get:6 http://59.111.0.251/ubuntu bionic-security/main i386 Packages [216 kB]
Get:7 http://59.111.0.251/ubuntu bionic-security/main Translation-en [106 kB]
Get:8 http://59.111.0.251/ubuntu bionic-security/main amd64 DEP-11 Metadata [204 B]
Get:9 http://59.111.0.251/ubuntu bionic-security/main DEP-11 48x48 Icons [29 B]
Get:10 http://59.111.0.251/ubuntu bionic-security/main DEP-11 64x64 Icons [29 B]
Get:11 http://59.111.0.251/ubuntu bionic-security/restricted amd64 Packages [4,296 B]
Get:12 http://59.111.0.251/ubuntu bionic-security/restricted i386 Packages [4,280 B]
Get:13 http://59.111.0.251/ubuntu bionic-security/restricted Translation-en [2,192 B]
Get:14 http://59.111.0.251/ubuntu bionic-security/universe amd64 Packages [131 kB]
Get:15 http://59.111.0.251/ubuntu bionic-security/universe i386 Packages [127 kB]
Get:16 http://59.111.0.251/ubuntu bionic-security/universe Translation-en [74.2 kB]
Get:17 http://59.111.0.251/ubuntu bionic-security/universe amd64 DEP-11 Metadata [20.8 kB]
Get:18 http://59.111.0.251/ubuntu bionic-security/universe DEP-11 48x48 Icons [12.2 kB]
Get:19 http://59.111.0.251/ubuntu bionic-security/universe DEP-11 64x64 Icons [50.4 kB]
Get:20 http://59.111.0.251/ubuntu bionic-security/multiverse i386 Packages [3,900 B]
Get:21 http://59.111.0.251/ubuntu bionic-security/multiverse amd64 Packages [3,748 B]
Get:22 http://59.111.0.251/ubuntu bionic-security/multiverse Translation-en [1,952 B]
Get:23 http://59.111.0.251/ubuntu bionic-security/multiverse amd64 DEP-11 Metadata [2,464 B]
Get:24 http://59.111.0.251/ubuntu bionic-security/multiverse DEP-11 48x48 Icons [29 B]
Get:25 http://59.111.0.251/ubuntu bionic-security/multiverse DEP-11 64x64 Icons [2,638 B]
Fetched 1,149 kB in 11s (109 kB/s)
Reading package lists... Done
root@linux:/etc/apt#
搞定,but,为嘛Ubuntu18要抽风解析不出这些域名,就算我直接修改/etc/hosts文件,它依然要解析成其他地址。估计是apt的毛病。因为,其他软件(需要域名解析)都正常。