Problem scenario: Yum commands to install packages are not working. When you use "yum install coolpackage" you get an error like this:
'
http://mirror.centos.org/altarch/7/os/i386/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: mirror.centos.org; Unknown error"
Trying other mirror.
https://yum.dockerproject.org/repo/main/centos/7/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: yum.dockerproject.org; Unknown error"
Trying other mirror.
...
One of the configured repositories failed (Docker Repository),
...
failure: repodata/repomd.xml from dockerrepo: [Errno 256] No more mirrors to try.
https://yum.dockerproject.org/repo/main/centos/7/repodata/repomd.xml: [Errno 14] curl#6 - "Could not resolve host: yum.dockerproject.org; Unknown error"
'
You cannot use curl or wget properly. You try this command (with no quotes): "curl http://www.google.com"
But you get this error: "curl: (6) Could not resolve host: www.google.com; Unknown error"
What do you do?
Root cause: DNS resolution is not working for your Internet connectivity. You must configure a DNS server for your network interface.
Solution
1. cd /etc/sysconfig/network-scripts
2. Backup the interface file that governs the IP address with the default gateway. If you are not sure which file this is, follow these directions. For a standard CentOS 7.x server, the file will be ifcfg-enp0s3 file. Once this file is backed up, modify the original one.
3. Make sure these two stanzas exist in the file that governs the default gateway:
DNS1=8.8.8.8
DNS2=8.8.4.4
For example, the last four lines of this file /etc/sysconfig/network-scripts/ifcfg-enp0s3 may look like this:
DEVICE=enp0s3
DNS1=8.8.8.8
DNS2=8.8.4.4
ONBOOT=yes
Save the changes.
4. Run this command: service network restart
5. Now there should be no problem.