If you are getting an error when using the “yum” command on your CentOS 7, this is likely the issue.
~# yum update
Loaded plugins: fastestmirror
Determining fastest mirrors
Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was
14: curl#6 - "Could not resolve host: mirrorlist.centos.org; Unknown error"
...
Cannot find a valid baseurl for repo: base/7/x86_64
As of July 2024, on CentOS 7, you will need to switch to Vault archive repositories: in /etc/yum.repos.d/CentOS-Base.repo
To do this, you will need to rename all repo files, You can do this by simply running the following,
sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo
sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo
sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*
If needed, you may need to run,
yum clean all