Centos – getting “Curl (6) Could not resolve host” after I did a “yum -y update”

centoscurldnsinternetnetworking

I have a CentOS 7.3 machine that is a guest running on Oracle VirtualBox. The host is a Windows machine. I can ping 8.8.8.8 from the Linux server. The Linux server can ping itself by its hostname ping coolvm. As root I recently did a yum -y update command. That is when curl stopped working. FQDNs will not resolve.

If I try this:

curl -v http://www.google.com

I get this error:

  • Could not resolve host: www.google.com; Unknown error
  • Closing connection 0 curl: (6) COuld not resolve host: www.google.com; Unknown error

The commands nslookup, dig and host have not been installed. I cannot install new Yum packages because I get an error related to host resolution ("Resolving time out").

The /etc/resolv.conf file looks like this:

# Generated by NetworkManager
search localdomain
nameserver 8.8.8.8
nameserver 8.8.4.4

I tried rebooting the host machine (and thus the guest too). But that did not help me. Browsing the internet has not changed.

The interface for the main NIC in /etc/sysconfig/network-scripts/ has DNS server stanzas that have worked in the past. The interface file is standard and complete. I have not changed it since the yum -y update command.

How can I get FQDNs to resolve? I want to use the Lynx command. My repositories rely on FQDNs to resolve. I cannot use yum to install packages.

Update. I ran this command:

cat /etc/nsswitch.conf | grep -i hosts

I saw this:

#hosts:   db files nisplus nis dns
hosts:    files dns myhostname

Best Answer

Try running the command dhclient. I tried it and it worked for me.

Related Question