How do prevent yum from retrieving mirrorlist

yum

No, this is not a duplicate of disable YUM mirrorlist checking That question was solved by preventing update of all metadata. This is not what I want to do.

I am trying to build images behind a corporate firewall which restricts outside access. I have internal mirrors, to which I point the installer during kickstart. That part works. Image reboots. I have disabled all repos (even tried deleting the existing .repo files), and laid down a custom repo file pointing to our internal mirrors. I've put "enabled = 0" in the fastestmirror.conf file (verified it works, yum doesn't say it's loading the plugin any more), BUT I'm still getting this error, and yum bails out:

Could not retrieve mirrorlist http://mirrorlist.centos.org/?release=7&arch=x86_64&repo=os&infra=stock error was 14: curl#7 - "Failed to connect to 2604:1580:fe02:2::10: Network is unreachable"

Well, yes, I know it is…that's why I disabled fastest mirror. I don't use the mirror list any more, because I've disabled all default repos.

I don't want to disable caching of metadata (nor do I want to extend its life, as was done in the above solution): I want metadata from our repos to be retrieved, but I don't want it to try to access the mirror list; there is no need.

Why is it still trying to access the mirror list? How can I disable that?

Best Answer

I think this article will solve your issue here is the most relevant part first:

This should be where the mirror is:

baseurl=file:/share/CentOS/$releasever/os/$basearch/

If you want it not to look at all:

  • Comment out the repo's
  • Remove the baseurl's
  • Move the whole file to a .bak version and delete the original.

Set up /etc/yum.repos.d/CentOS-Base.repo like:

[base]
name=CentOS-$releasever - Base
baseurl=file:/share/CentOS/$releasever/os/$basearch/
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
protect=1
priority=1
enabled=1
[updates]
name=CentOS-$releasever - Updates
baseurl=file:/share/CentOS/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
protect=1
priority=1
enabled=1
[extras]
name=CentOS-$releasever - Extras
baseurl=file:/share/CentOS/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
protect=1
priority=1
enabled=1
[centosplus]
name=CentOS-$releasever - Plus
baseurl=file:/share/CentOS/$releasever/centosplus/$basearch/
exclude=kernel*
gpgcheck=1
enabled=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
protect=0
priority=1
[contrib]
name=CentOS-$releasever - Contrib
baseurl=file:/share/CentOS/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
protect=0
priority=3

From Here: https://wiki.centos.org/HowTos/CreateLocalMirror

Related Question