How to Setup Local Yum/DNF Repository on RHEL 10


In this post, we will walk you through how to setup local Yum/DNF repository on RHEL 10 using it’s ISO image. You will also learn how to share this repository with client systems over the network using the HTTP protocol. This is one of the simplest and most reliable ways to maintain repo availability in secure or offline environments.

Why Create a Local Yum/DNF Repository?

A local repository comes in handy for several reasons:

  • Works even in air-gapped or restricted networks
  • Saves bandwidth by avoiding repeated package downloads
  • Provides consistent packages across all systems
  • Helps you maintain version control for your infrastructure
  • Allows faster patching and software installation

RHEL 10 comes with two package repositories:

  • BaseOS
  • Application Stream

BaseOS repository have all underlying OS packages where as Application Stream repository have all application related packages, developer tools and databases etc. Using Application stream repository, we can have multiple of versions of same application and Database.

Prerequisites

  • A RHEL 10 server (for hosting the repository)
  • RHEL 10 ISO file (downloaded from Red Hat Customer Portal)
  • Root or sudo access
  • Internet or access to internal Red Hat repos (optional if using only ISO)

Without any further delay, let’s deep dive into actual steps.

1) Mount the RHEL 10 ISO

In my setup, I attached the RHEL 10 ISO file directly to my RHEL 10 virtual machine and mounted it to the /mnt directory using the mount command.

$ sudo mount /dev/sr0 /mnt/

Mount RHEL 10 ISO File

If you have downloaded or copied the ISO file instead, you can use the following mount command to mount it manually on your system.

$ sudo mount -o loop rhel-10.0-x86_64-dvd.iso /mnt

2) Copy RPM Packages to the Local Repository Directory

Create a directory to store the repo files:

$ sudo mkdir -p /var/www/html/rhel10-repo

Copy all RPM packages from the ISO:

$ sudo cp -av /mnt/AppStream/ /var/www/html/rhel10-repo/
$ sudo cp -av /mnt/BaseOS/ /var/www/html/rhel10-repo/

3) Install createrepo Utility

createrepo generates metadata required for DNF/Yum to understand the repository.

Install it with:

$ sudo dnf install createrepo_c -y

Install Createrepo On RHEL 10

Next, generate metadata for both repos, run the command.

$ sudo createrepo /var/www/html/rhel10-repo/BaseOS/
$ sudo createrepo /var/www/html/rhel10-repo/AppStream/

Note: If you update packages later, just re-run

$ sudo createrepo --update.

4) Install Apache HTTP Server

To serve repository over HTTP, we need to install Apache web server, run the beneath command.

$ sudo dnf install httpd -y

Install Apache Web Server for Local Repo On RHEL 10

Next start the Apache service, run

$ sudo systemctl enable --now httpd

Allow HTTP service through firewall:

$ sudo firewall-cmd --add-service=http --permanent
$ sudo firewall-cmd --reload

Check if the repo is accessible:

http://<RHEL10-Server-IP>/rhel10-repo/

Access RHEL 10 Local Yum Repo Over HTTP

5) Configure Client Machines

On RHEL 10 client machines, create a repo file pointing to the HTTP server:

$ sudo tee /etc/yum.repos.d/rhel10-local.repo <<EOF
[local-BaseOS]
name=Local RHEL10 BaseOS
baseurl=http://192.168.1.36/rhel10-repo/BaseOS
enabled=1
gpgcheck=0

[local-AppStream]
name=Local RHEL10 AppStream
baseurl=http://192.168.1.36/rhel10-repo/AppStream
enabled=1
gpgcheck=0
EOF

Replace the IP address according to your setup.

Note: If RHEL 10 client machine is registered with any subscription, first unregistered it.

$ sudo subscription-manager unregister

Next, edit the file  ‘/etc/yum/pluginconf.d/subscription-manager.conf‘ , change the parameter ‘enabled=1‘ to ‘enabled=0‘.

Disable Subscription Manager RHEL 10 Client

Next, refresh the repo cache, run

$ sudo dnf clean all
$ sudo dnf makecache

Test installing a package:

$ sudo dnf repolist
$ sudo dnf install telnet -y

Installing Package Via Local Yum Repository On RHEL 10

Conclusion

That’s all for this guide! I hope you found it helpful and easy to follow. If you have any questions or run into any issues, feel free to drop them in the comments section below- I would be happy to help.

Setting up a local Yum/DNF repository on RHEL 10 using the installation ISO is a simple yet powerful approach, especially for offline setups or secure environments where internet access is restricted. By hosting the repository over HTTP, you get faster package installations, centralized control, and smoother management across multiple systems.

Whether you are working in a home lab, testing environment, or managing a large enterprise infrastructure, this method ensures consistent, reliable, and efficient software distribution across all your RHEL 10 machines.

Also Read: How to Upgrade RHEL 9 to RHEL 10 Step-by-Step Guide



Source link

Leave a Comment