I ran into an issue recently where I could ping URL’s just fine, but when I ran the “yum update” command yum could not resolve anything. I would get error messages like the following:
[root@viviotech ~]# yum -y update Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=6&arch=x86_64&repo=os error was 14: PYCURL ERROR 6 - "Couldn't resolve host 'mirrorlist.centos.org'" Error: Cannot find a valid baseurl for repo: base
After a bit of digging, and absolutely no help from my friend Google, I asked one of the Vivio technicians about it and he said he’d seen it on other servers – specifically servers with VirtualMin.
Take a look at the resolve.conf file:
nameserver 127.0.0.1 nameserver 188.8.131.52 nameserver 184.108.40.206
See how VirtualMin adds the 127.0.0.1 address first? Apparently YUM will ONLY check the very first entry in the /etc/resolve.conf file when it looks for the server to resolve IP Addresses. In this case, the local DNS resolver was not configured to use forwarders, so the YUM process would ask the local DNS server where to find “mirrorlist.centos.org”, and when the local resolver didn’t know, YUM would simply report an error instead of looking at the other resolvers in the /etc/resolve.conf list. This is why I could ping URL’s just fine, but YUM could not find them.
The solution to this was to simply place the 127.0.0.1 entry at the bottom of the /etc/resolv.conf file, like so:
nameserver 220.127.116.11 nameserver 18.104.22.168 nameserver 127.0.0.1
After that, everything worked great.
IMPORTANT: The above examples of the /etc/resolv.conf file use the IP Addresses of the Google Public DNS.