Arch Linux安装完成后无法上网,报错: Temporar
2024-05-01 本文已影响0人
从零开始学ArchLinux
昨天在Hyper-V虚拟机上将ArchLinux安装完成后,今天登录之后,发现ping archlinux.org网站报错: Temporary failure in new resolution,如下:
ping archlinux.org

下边开始分析问题。
首先弄明白问题的意思,问题提示翻译为中文为:名称暂时解析失败,那应该是DNS问题,我直接ping一个IP地址试试:
# 百度的IP地址:39.156.66.10
ping 39.156.66.10

还是失败,意思是“网络不可达”,这说明网络有问题,那么开始查询网络问题。
首先查看本地的网络设备是否启用:
ip link

那么启用eth0网络设备,之后查看确认是否启用成功:
ip link set eth0 up
ip link

再次查看是否可以ping百度地址:
ping 39.156.66.10

考虑网络服务的原因,查看是否启动:
systemctl status systemd-networkd.service

启用网络服务,并查看是否启用成功:
systemctl start systemd-networkd.service
systemctl status systemd-networkd.service

ping百度地址,查看连接是否可以正常:
ping 39.156.66.10

现在考虑网络配置文件是否正确, 查看网络配置文件:
ls -l /etc/systemd/network/

复制一个默认的网络配置文件到/etc/systemd/network/,并重启网络服务:
cp /usr/lib/systemd/network/89-ethernet.network.example /etc/systemd/network/89-ethernet.network
systemctl restart systemd-networkd.service

再次ping百度IP:
ping 39.156.66.10

试一试ping域名:
ping baidu.com

查看域名解析服务是否启动:
systemctl status systemd-resolved.service

启用域名解析服务,重启网络服务,并再次尝试ping域名:
systemctl start systemd-resolved.service
systemctl restart systemd-network.service
ping baidu.com

终于配置网络成功了,最后不要忘记配置网络服务、域名解析服务开机启动:
systemctl enablesystemd-network.service
systemctl enable systemd-resolved.service

最后,重启(reboot)虚拟机,测试网络是否正常:
ping archlinux.org

接下来,准备安装ssh服务,在宿主机Windows中安装一个ssh客户端,连接ArchLinux系统,这样就不用直接在虚拟机上输入命令了,更不用截图虚拟机了,可以提高记录学习过程的效率。