昨天购买了一个外国的服务器,为了“减少成本”,我没有配置ipv4,而只有ipv6。然后发现服务器用apt update无法连接镜像源进行更新。后来查了资料才发现,仅ipv6的服务器是无法解析并连接ipv4的域名或地址的,而大多数镜像源可能还是ipv4的,因此需要修改服务器的dns并配置ipv6镜像源。
1,配置服务器的DNS
打开/etc/resolv.conf这个文件,可以先将其中清空,然后加入下列内容设定dns:
#谷歌 IPv6 DNS
nameserver 2001:4860:4860::8888
nameserver 2001:4860:4860::8844#阿里云 IPv6 DNS
nameserver 2400:3200::1
nameserver 2400:3200:baba::1#Cloudflare IPv6 DNS
nameserver 2606:4700:4700::1111
nameserver 2606:4700:4700::1001
任选两个粘贴进去即可,国外的话推荐谷歌和Cloudflare。
2,配置IPv6镜像源
目前找到的就有清华大学镜像源、上海交大镜像源和中科大镜像源支持ipv6,下面贴出Debian 10的镜像配置,其余可以到镜像站官网查看帮助。
清华大学:
#清华大学IPv6-Debian10软件源
deb https://mirrors6.tuna.tsinghua.edu.cn/debian buster main contrib non-free
deb https://mirrors6.tuna.tsinghua.edu.cn/debian buster-updates main contrib non-free
deb https://mirrors6.tuna.tsinghua.edu.cn/debian buster-proposed-updates main contrib non-free
deb https://mirrors6.tuna.tsinghua.edu.cn/debian buster-backports main contrib non-free
deb-src https://mirrors6.tuna.tsinghua.edu.cn/debian buster main contrib non-free
deb-src https://mirrors6.tuna.tsinghua.edu.cn/debian buster-updates main contrib non-free
deb-src https://mirrors6.tuna.tsinghua.edu.cn/debian buster-proposed-updates main contrib non-free
deb-src https://mirrors6.tuna.tsinghua.edu.cn/debian buster-backports main contrib non-free#清华大学IPv6-Debian10安全更新源
deb https://mirrors6.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
deb-src https://mirrors6.tuna.tsinghua.edu.cn/debian-security buster/updates main contrib non-free
中科大:
#中科大IPv6-Debian10软件源
deb http://ipv6.mirrors.ustc.edu.cn/debian buster main contrib non-free
deb http://ipv6.mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
deb http://ipv6.mirrors.ustc.edu.cn/debian buster-proposed-updates main contrib non-free
deb http://ipv6.mirrors.ustc.edu.cn/debian buster-backports main contrib non-free
deb-src http://ipv6.mirrors.ustc.edu.cn/debian buster main contrib non-free
deb-src http://ipv6.mirrors.ustc.edu.cn/debian buster-updates main contrib non-free
deb-src http://ipv6.mirrors.ustc.edu.cn/debian buster-proposed-updates main contrib non-free
deb-src http://ipv6.mirrors.ustc.edu.cn/debian buster-backports main contrib non-free#中科大IPv6-Debian10安全更新源
deb http://ipv6.mirrors.ustc.edu.cn/debian-security buster/updates main contrib non-free
deb-src http://ipv6.mirrors.ustc.edu.cn/debian-security buster/updates main contrib non-free
上海交大:
#上海交通大学 IPv4+IPv6-Debian10软件源
deb https://mirror.sjtu.edu.cn/debian buster main contrib non-free
deb https://mirror.sjtu.edu.cn/debian buster-updates main contrib non-free
deb https://mirror.sjtu.edu.cn/debian buster-proposed-updates main contrib non-free
deb https://mirror.sjtu.edu.cn/debian buster-backports main contrib non-free
deb-src https://mirror.sjtu.edu.cn/debian buster main contrib non-free
deb-src https://mirror.sjtu.edu.cn/debian buster-updates main contrib non-free
deb-src https://mirror.sjtu.edu.cn/debian buster-proposed-updates main contrib non-free
deb-src https://mirror.sjtu.edu.cn/debian buster-backports main contrib non-free#上海交通大学 IPv4+IPv6-Debian10安全更新源
deb https://mirror.sjtu.edu.cn/debian-security buster/updates main contrib non-free
deb-src https://mirror.sjtu.edu.cn/debian-security buster/updates main contrib non-free
配置完DNS和镜像源,就可以使用apt update进行更新,然后安装软件了!