apt-get 無法解析'tw.archive.ubuntu.com'
解決辦法:
將 nameserver 8.8.8.8 添加到 /etc/resolv.conf 中以查詢該服務器。
sudo vi /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 產生的,每次重開機後都會被重寫,必須從另外一個地方修改。
根據 使用 systemd-resolved 設定 DNS 域名解析 · Freedom Wolf 這篇,我們要修改的是 /etc/systemd/resolved.conf
sudo vi /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 的部份加上 1.1.1.1 8.8.8.8
# 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=1.1.1.1 8.8.8.8
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes
然後重新啟動服務
systemctl restart systemd-resolved查詢狀態
systemd-resolve --statusGlobal
DNS Servers: 1.1.1.1
8.8.8.8
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
internal
intranet
lan
local
private
test
.....
.....
可以發現 DNS Servers: 這排已經新增了 1.1.1.1 跟 8.8.8.8 兩個 server
再執行 apt update 即可正確解析 tw.archive.ubuntu.com
若還是無法解決,根據 Ubuntu 10.04 軟體套件庫 tw.archive.ubuntu.com 連不上之解決辦法 @ pit區 :: 痞客邦 :: 這篇,直接把 tw.archive.ubuntu.com 改成 archive.ubuntu.com:
打開 /etc/apt/sources.list:
sudo vi /etc/apt/sources.list輸入替換指令:
:%s/tw.archive.ubuntu.com/ archive.ubuntu.com重新執行 sudo apt-get update 即可。
Notes:
有時會需要用到系統的DNS 查詢工具來直接查詢,看看是 DNS 的問題還是該網站的問題,可以使用指令:
nslookup -type=any facebook.com 8.8.8.8一般來說,會出現如下回應:
Server: 8.8.8.8
Address: 8.8.8.8#53
Non-authoritative answer:
facebook.com text = "v=spf1 redirect=_spf.facebook.com"
facebook.com nameserver = a.ns.facebook.com.
facebook.com text = "google-site-verification=wdH5DTJTc9AYNwVunSVFeK0hYDGUIEOGb-RReU6pJlY"
facebook.com text = "9v6vz6q1j6063bxtbrms7r9bd2cq1s29"
facebook.com nameserver = b.ns.facebook.com.
facebook.com text = "google-site-verification=A2WZWCNQHrGV_TWwKh6KHY90tY0SHZo_RnyMJoDaG0s"
facebook.com mail exchanger = 10 smtpin.vvv.facebook.com.
facebook.com
origin = a.ns.facebook.com
mail addr = dns.facebook.com
serial = 27341091
refresh = 14400
retry = 1800
expire = 604800
minimum = 300
facebook.com nameserver = c.ns.facebook.com.
facebook.com nameserver = d.ns.facebook.com.
Name: facebook.com
Address: 157.240.11.35
Name: facebook.com
Address: 2a03:2880:f10d:183:face:b00c:0:25de
Authoritative answers can be found from:
但若遇到不支援 ANY option 的 DNS server,如 1.1.1.1,則會出現:
nslookup -type=any facebook.com 1.1.1.1Server: 1.1.1.1
Address: 1.1.1.1#53
** server can't find facebook.com: NOTIMP
此時不要使用 ANY option 即可:
nslookup facebook.com 1.1.1.1Server: 1.1.1.1
Address: 1.1.1.1#53
Non-authoritative answer:
Name: facebook.com
Address: 31.13.87.36
Name: facebook.com
Address: 2a03:2880:f10d:183:face:b00c:0:25de
參考:
dns - nsupdate: What does the error NOTIMP mean? - Super User
DNS在線查詢工具 - Coding.Tools
台灣常用 DNS 伺服器推薦與整理 - Office 指南