centos7 yum報"could not resolve host: xxx"

centos7使用yum報"could not resolve host: mirrorlist.centos.org; Unknown error"問題的解決

一開始覺得是yum源的問題,而後發現網絡聯不通,網上搜索了一下這個錯誤,也是說網絡問題。
最後參考了centos使用yum報錯"Could not resolve host: mirrorlist.centos.org; 未知的錯誤"這篇博客,解決了該問題。centos

如下是解決問題的步驟:

查看本機網卡,查看網卡狀態網絡

nmcli d

下面是修改後的狀態:
image.png
個人網卡狀態原來是disconnected
而後我嘗試重啓網絡服務centos7

systemctl restart network

發現網卡仍是disconnectedspa

而後切換到/etc/sysconfig/network-scripts/目錄下,打開"ifcfg-主網卡名"文件,我這裏是ifcfg-enp0s3:
image.png.net

我這裏的ONBOOT配置是原來是no,把它改成yes,而後再重啓網絡服務就行了rest

systemctl restart network

這裏說一下經常使用的配置:

  • 動態配置
BOOTPROTO=dhcp

ONBOOT=yesblog

  • 靜態配置
BOOTPROTO=static

ONBOOT=yesip

相關文章
相關標籤/搜索