How to setup fastest mirror in Dnf

Dnf by default does not choose the fastest mirror, but this can be changed by editing the dnf.conf file.

The dnf.conf file is in /etc/dnf/dnf.conf.

Edit the file

sudo nano /etc/dnf/dnf.conf

Once the file opens the content should look something like this.

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=False
skip_if_unavailable=True

Let’s add fastmirror to the config and enable it.

Add below the line skip_if_unavaiable=True the following.

fastestmirror=1

The dnf.conf should look like this.

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=False
skip_if_unavailable=True
fastestmirror=1

Save the file.

Run the following command.

sudo dnf clean all

Now fastmirror is enabled you can download anything, for this example I will download Zeal an offline document browser.

sudo dnf install zeal

There is the output.

[darryl@linuxvm ~]$ sudo dnf install zeal
[sudo] password for darryl: 
determining the fastest mirror (94 hosts).. done.--  B/s |   0  B     --:-- ETA
Fedora 32 openh264 (From Cisco) - x86_64        2.2 kB/s | 5.1 kB     00:02    
Fedora Modular 32 - x86_64                      1.1 MB/s | 4.9 MB     00:04    
Fedora Modular 32 - x86_64 - Updates            896 kB/s | 3.5 MB     00:04    
Fedora 32 - x86_64 - Updates                    2.1 MB/s |  18 MB     00:08    
Fedora 32 - x86_64                              3.7 MB/s |  70 MB     00:19    
Dependencies resolved.
================================================================================
 Package               Arch   Version                             Repo     Size
================================================================================
Installing:
 zeal                  x86_64 0.6.1-5.fc32                        fedora  473 k
Installing dependencies:
 pcre2-utf16           x86_64 10.35-3.fc32                        updates 212 k
 qt-settings           noarch 32.0-3.fc32                         fedora  9.3 k
 qt5-qtbase            x86_64 5.14.2-5.fc32                       updates 3.4 M
 qt5-qtbase-common     noarch 5.14.2-5.fc32                       updates  11 k
 qt5-qtbase-gui        x86_64 5.14.2-5.fc32                       updates 5.8 M
 qt5-qtdeclarative     x86_64 5.14.2-1.fc32                       updates 3.9 M
 qt5-qtlocation        x86_64 5.14.2-2.fc32                       updates 3.0 M
 qt5-qtsensors         x86_64 5.14.2-1.fc32                       updates 228 k
 qt5-qtwayland         x86_64 5.14.2-3.fc32                       updates 1.1 M
 qt5-qtwebchannel      x86_64 5.14.2-1.fc32                       updates  97 k
 qt5-qtwebkit          x86_64 5.212.0-0.46.alpha4.fc32            updates  13 M
 qt5-qtx11extras       x86_64 5.14.2-1.fc32                       updates  35 k
 xcb-util-image        x86_64 0.4.0-14.fc32                       fedora   19 k
 xcb-util-keysyms      x86_64 0.4.0-12.fc32                       fedora   14 k
 xcb-util-renderutil   x86_64 0.3.9-15.fc32                       fedora   17 k
 xcb-util-wm           x86_64 0.4.1-17.fc32                       fedora   31 k
Installing weak dependencies:
 gstreamer1-plugins-good-qt
                       x86_64 1.16.2-2.fc32                       fedora   46 k
 libyui-mga-qt         x86_64 1.0.3-0.20.gitb508e88.20140119.fc32 fedora   42 k
 libyui-qt             x86_64 2.47.1-17.fc32                      fedora  321 k
 libyui-qt-graph       x86_64 2.44.6-7.fc32                       fedora   57 k

Transaction Summary
================================================================================
Install  21 Packages

Total download size: 32 M
Installed size: 106 M
Is this ok [y/N]: 

You can now successfully have Dnf downloading packages from the mirror with the lowest latency.

You can join the Reddit discussion here.

Leave a Comment