In some cases it is useful to change the default RPM repository mechanism of using a dynamic mirrorlist to a fixed mirrorlist.
For example when policy is to not allow direct http to all hosts on the Internet from the internal servers setting fixed RPM repositories will allow you to open http(s) to a limited number of IP addresses for CentOS package updates.
For the Rocky Linux 8 default repositories:
egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/Rocky-*.repo
mkdir /root/yum.repos.d-backup/ cp -p /etc/yum.repos.d/*.repo /root/yum.repos.d-backup/
sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/Rocky-{AppStream,BaseOS,Debuginfo,Devel,Extras,HighAvailability,NFV,Plus,PowerTools,ResilientStorage,RT,Sources}.repo
sed -i 's/^#baseurl=http:\/\/dl.rockylinux.org\/\$contentdir/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/rocky/' /etc/yum.repos.d/Rocky-{AppStream,BaseOS,Debuginfo,Devel,Extras,HighAvailability,NFV,Plus,PowerTools,ResilientStorage,RT,Sources}.repo
egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/Rocky-*.repo
dnf clean all && dnf makecache
systemctl stop dnf-makecache.timer systemctl disable dnf-makecache.timer
Sources:
For the CentOS 8 default repositories:
egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/CentOS-*.repo
mkdir /root/yum.repos.d-backup/ cp -p /etc/yum.repos.d/*.repo /root/yum.repos.d-backup/
sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-Linux-{AppStream,BaseOS,ContinuousRelease,Devel,Extras,FastTrack,HighAvailability,Plus,PowerTools}.repo
sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-{AppStream,Base,centosplus,CR,Devel,Extras,fasttrack,HA,PowerTools}.repo
sed -i 's/^#baseurl=http:\/\/mirror.centos.org\/\$contentdir/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/CentOS/' /etc/yum.repos.d/CentOS-Linux-{AppStream,BaseOS,ContinuousRelease,Devel,Extras,FastTrack,HighAvailability,Plus,PowerTools}.repo
sed -i 's/^#baseurl=http:\/\/mirror.centos.org\/\$contentdir/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/CentOS/' /etc/yum.repos.d/CentOS-{AppStream,Base,centosplus,CR,Devel,Extras,fasttrack,HA,PowerTools}.repo
egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/CentOS-*.repo
dnf clean all && dnf makecache
systemctl stop dnf-makecache.timer systemctl disable dnf-makecache.timer
Sources:
For the EPEL repository installed with:
dnf install epel-release
egrep "^metalink|^baseurl|^#metalink|^#baseurl" /etc/yum.repos.d/epel*.repo
mkdir /root/yum.repos.d-backup/ cp -p /etc/yum.repos.d/epel*.repo /root/yum.repos.d-backup/
sed -i 's/^metalink/#metalink/' /etc/yum.repos.d/epel*.repo
sed -i 's/^#baseurl=https:\/\/download.fedoraproject.org\/pub\/epel/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/fedora-epel/' /etc/yum.repos.d/epel*.repo
sed -i 's/^#baseurl=http:\/\/download.fedoraproject.org\/pub\/epel/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/fedora-epel/' /etc/yum.repos.d/epel*.repo
egrep "^metalink|^baseurl|^#metalink|^#baseurl" /etc/yum.repos.d/epel*.repo
dnf clean all && dnf makecache
For the CentOS 7 default repositories:
egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/CentOS-*.repo
mkdir /root/yum.repos.d-backup/ cp -p /etc/yum.repos.d/*.repo /root/yum.repos.d-backup/
sed -i 's/^mirrorlist/#mirrorlist/' /etc/yum.repos.d/CentOS-{Base,CR,fasttrack}.repo
sed -i 's/^#baseurl=http:\/\/mirror.centos.org\/centos/baseurl=https:\/\/ftp.nluug.nl\/pub\/os\/Linux\/distr\/CentOS/' /etc/yum.repos.d/CentOS-{Base,CR,fasttrack}.repo
sed -i 's/^#baseurl=http:\/\/mirror.centos.org\/centos\/\$releasever/baseurl=https:\/\/vault.centos.org\/7.7.1908/' /etc/yum.repos.d/CentOS-{Base,CR,fasttrack}.repo
sed -i 's/enabled\=1/enabled\=0/' /etc/yum/pluginconf.d/fastestmirror.conf
egrep "^baseurl|^mirrorlist|^#baseurl|^#mirrorlist" /etc/yum.repos.d/CentOS-*.repo
yum clean all && yum makecache