执行 yum 命令时报:
1 | Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock32 error was |
配置下网络即可。
查看网卡配置文件:
1
2$ cd /etc/sysconfig/network-scripts
$ ls1
2
3
4
5
6
7
8
9
10ifcfg-ens32 ifdown-post ifup-eth ifup-sit
ifcfg-ens32.bak ifdown-ppp ifup-ib ifup-Team
ifcfg-lo ifdown-routes ifup-ippp ifup-TeamPort
ifdown ifdown-sit ifup-ipv6 ifup-tunnel
ifdown-bnep ifdown-Team ifup-isdn ifup-wireless
ifdown-eth ifdown-TeamPort ifup-plip init.ipv6-global
ifdown-ib ifdown-tunnel ifup-plusb network-functions
ifdown-ippp ifup ifup-post network-functions-ipv6
ifdown-ipv6 ifup-aliases ifup-ppp
ifdown-isdn ifup-bnep ifup-routes第一个
ifcfg-ens32
就是网卡配置文件,不同机器略有不同:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.74
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
DNS1=8.8.8.8
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens32
UUID=fbe7146b-693d-4047-b73c-fd685a76337b
DEVICE=ens32
ONBOOT=yes备份
1
$ sudo cp /etc/sysconfig/network-scripts/ifcfg-ens32 /etc/sysconfig/network-scripts/ifcfg-ens32.bak
编辑
ifcfg-ens32
文件:针对动态配置,需要设置:
1
2
3
4
5BOOTPROTO=dhcp
ONBOOT=yes
``
- 针对静态配置,需要设置:BOOTPROTO=static
ONBOOT=yes1
同时静态配置还要设置固定 IP,网关,DNS:
IPADDR=192.168.1.74
GATEWAY=192.168.1.1
NETMASK=255.255.255.0
DNS1=8.8.8.81
2
- 重启网络服务并更新资源$ sudo systemctl restart network
$ sudo yum update
转载自 CentOS报错: Could not resolve host: mirrorlist.centos.org; Unknown error
如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理