DNF URL Priority

I keep a local mirror of the Fedora repos on my LAN to save some bandwith when I do updates of my various lab test VMs. For those test VMs, I just set the baseurl directive to point to my LAN repo server and comment out the default metalink directive.

I’m wanting to expand the use of my LAN repo server to the other Fedora computers in my home; however, still be able to patch them when I’m off the LAN. Ideally I’d want to have both a baseurl and metalink directive active. The idea is dnf would try the baseurl first (which points to my LAN’s repo server), and if that fails, follow the metalink to Fedora’s mirrors.

Doing some tests (I <3 tcpdump), I found when both baseurl and metalink are defined, dnf will use the metalink url still. Is there a way to configure dnf to do this behavior of try the baseurl first then go to the metalink?

I could probably setup some kind of proxy that would direct traffic to the metalink back to my LAN repo servers, but I’m hoping there’s a way to configure dnf to do my bidding.

FYI, the results of dnf --version

  Installed: dnf-0:4.16.1-1.fc38.noarch at Mon 12 Jun 2023 02:28:03 AM GMT
  Built    : Fedora Project at Tue 30 May 2023 07:51:54 AM GMT

  Installed: rpm-0:4.18.1-3.fc38.x86_64 at Sun 07 May 2023 03:40:34 AM GMT
  Built    : Fedora Project at Wed 26 Apr 2023 05:35:27 AM GMT

Duplicate the repo-files adding some local prefix/suffix and specify a lower cost.


That would make sense. Thanks for the suggestion!

1 Like