[CentOS-mirror] How can I be a internal mirror?

Wed Mar 7 18:23:52 UTC 2012
Jeff Fisher <jeff at lfchosting.com>

> At the moment, if you want to ensure that you use your local
> mirror, you need to edit the .repo files in /etc/yum.repos.d to
> change baseurl to point specifically to your repository (and
> comment out the mirrorlist line).  Otherwise, YUM gets a list of
> random mirrors in your country, which may still be very far away.

Another option which might be easier depending your local set up and how 
many machines you have is what I've done :)

On your local caching nameservers:

zone "mirrorlist.centos.org" IN {
         type master;
         file "localmirror.zone";
         allow-update { none; };
         allow-transfer { XXX.XXX.XXX.XXX; };
};

and in localmirror.zone beyond your usual SOA/NS records, put in an A 
record that points to an http server that you control.

And a simple index.php

<?php

$base = "/var/ftp/pub";

if (isset($_GET["release"]) && isset($_GET["arch"]) && 
isset($_GET["repo"])) {
         $partial_path = sprintf("centos/%s/%s/%s", $_GET["release"], 
$_GET["repo"], $_GET["arch"]);

         if (!file_exists(sprintf("%s/%s/repodata", $base, 
$partial_path))) {
                 echo $_GET["release"] . " is not a valid release or 
hasnt been released yet\n";
                 exit;
         }

         echo sprintf("http://mirror.example.com/%s/\n", $partial_path);
         exit;
}

It will also catch machines that you don't have an easy way to modify 
the repo files on.

Jeff