新建的CentOS虚拟机,装ftp服务器。报错。

[root@localhost ~]# yum -y install ftp vsftpd
Loaded plugins: fastestmirror, refresh-packagekit, security
Setting up Install Process
Loading mirror speeds from cached hostfile
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os&infra=stock error was
14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'"
Error: Cannot find a valid baseurl for repo: base

mirrorlist.centos.org IP 是 67.219.148.138

先備份 /etc/hosts
[root@xxx ~]#sudo cp /etc/hosts /etc/hosts.bak

加入對應表 host
[root@xxx ~]#sudo echo "67.219.148.138 mirrorlist.centos.org" >> /etc/hosts

記得要 ">>" 不然的話整個檔案覆蓋了

你先確認能否上網

[root@xxx ~]# ping www.net.cn
PING www.net.cn (42.120.158.5) 56(84) bytes of data.
64 bytes from 42.120.158.5: icmp_seq=1 ttl=36 time=38.5 ms
64 bytes from 42.120.158.5: icmp_seq=2 ttl=36 time=38.6 ms
64 bytes from 42.120.158.5: icmp_seq=3 ttl=36 time=38.8 ms