How to configure yum server repository using iso dvd

If you are not already aware of "YUM" (Yellowdog Updater, Modified) is used for installing rpms.
Yum allows automatic updates, package and dependency management, on RPM-based distributions. Ideally yum is used to get direct updates from Red Hat Satellite Network but we can also configure it to use RHEL DVD as the source to install the rpms.

Below steps are validated on Red Hat Enterprise Linux 7

Mount the RHEL 7 installation dvd on a mount point
# mount -o loop /tmp/rhel-server-7.3-x86_64-dvd.iso /mnt
mount: /dev/loop0 is write-protected, mounting read-only
If the DVD is mounted over virtual media
# /mount /dev/sr0 /mnt
Here "0" in sr0 is a variable and can vary if there is another USB/DVD mounted to the same node.

Create a new file under /etc/yum.repos.d
# vim /etc/yum.repos.d/rhel.repo
[InstallMedia]
name=Red Hat Enterprise Linux 7.3
baseurl=file:///mnt
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release
Add the above content and save the file

You can also disable the gpgcheck by using the below config
[InstallMedia]
name=Red Hat Enterprise Linux 7.3
baseurl=file:///mnt
gpgcheck=0
enabled=1
Clear the related caches
# yum clean all
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Cleaning repos: InstallMedia
Cleaning up everything
List the repositories which are enabled
# yum repolist all
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
InstallMedia                                             | 4.1 kB  00:00:00
(1/2): InstallMedia/group_gz                             | 136 kB  00:00:00
(2/2): InstallMedia/primary_db                           | 3.9 MB  00:00:00
repo id                     repo name                              status
InstallMedia                Red Hat Enterprise Linux 7.3           enabled: 4,751
repolist: 4,751

Now you can start using 'yum'
# yum install <package_name>

I hope the article was useful.