How to configure/setup a PXE server on RHEL 10 ?

Solution Verified - Updated

Environment

  • Red Hat Enterprise Linux 10

Issue

  • How to configure/setup a PXE server for RHEL 10 ?
  • How to configure a RHEL 10 server as a PXE server for RHEL 10 client installations ?

Resolution

Prerequesites

RHEL 10.0 DVD ISO is being used in this example to host the repository

  • Download the This content is not included.RHEL 10.0 DVD from Customer Portal

  • Decide the network configuration required for PXE server for your environment.
    In the example below, the PXE server will provide DHCP service, TFTP service and HTTPD service on the same server.

    • DHCP : Needed for IP address assignmment and to provide location of the bootloader file
    • TFTP : Host the bootloader and boot configuration during boot for BIOS/UEFI.
    • HTTPD : Host the repository and make it available for installation. (Optional : Also provide bootloader and boot configuration for HTTP boot in case of UEFI clients.)

    |Parameter|Value|
    |---------|---------|
    | Network Interface| enp7s0|
    | Network ID| 192.168.10.0/24|
    | DHCP Server IP| 192.168.10.1/24|
    | Subnet Range| 192.168.10.100 - 192.168.10.200|
    | Gateway| 192.168.10.1|
    | TFTP Server| 192.168.10.1|
    | DNS Server| 192.168.10.1|
    | HTTPD Server| 192.168.10.1|
    | Installation Repository| http://192.168.10.1/dvd/|


Configuration

  1. Install the DHCP server, TFTP server and HTTPD server. RHEL 10 uses kea for DHCP.

    # dnf install kea tftp-server httpd
    
  2. Configure KEA DHCP server.
    The file content of /etc/kea/kea-dhcp4.conf should contain the below content for our configuration above.

    {                                                          
      "Dhcp4": {                                               
        "interfaces-config": {
          "interfaces": [ "enp7s0" ]
        },     
        "subnet4": [
          {                                                    
            "id": 1,                                                                                                      
            "subnet": "192.168.10.0/24",
            "pools": [
              {     
                "pool": "192.168.10.100 - 192.168.10.200"
              }                 
            ],                 
            "option-data": [
              {                                                
                "space": "dhcp4", 
                "name": "routers",
                "code": 3,     
                "data": "192.168.10.1"
              },
              {
                "space": "dhcp4", 
                "name": "domain-name-servers",
                "code": 6,                                                                                                
                "data": "192.168.10.1"
              }
            ]
          }
        ],
        "client-classes": [
          {
            "name": "uefi PXE Clients",
            "test": "substring(option[60].hex,0,9) == 'PXEClient' and option[93].hex == 0x0007",
            "next-server": "192.168.10.1",
            "boot-file-name": "/uefi/BOOT/BOOTX64.EFI"
          },
          {
            "name": "bios PXE Clients",
            "test": "substring(option[60].hex,0,9) == 'PXEClient' and option[93].hex == 0x0000",
            "next-server": "192.168.10.1",
            "boot-file-name": "/bios/grub2/i386-pc/core.0"
          },
          {
            "name": "uefi HTTP Clients",
            "test": "substring(option[60].hex,0,10) == 'HTTPClient' and option[93].hex == 0x0007",
            "option-data": [
              {
                "space": "dhcp4", 
                "name": "vendor-class-identifier",
                "code": 60,
                "data": "HTTPClient"
              }
            ],
            "next-server": "192.168.10.1",
            "boot-file-name": "http://192.168.10.1/uefi/BOOT/BOOTX64.EFI"
          }
        ],
        "loggers": [
        {
            "name": "kea-dhcp4",
            "output-options": [
                {
                    "output": "/var/log/kea/kea-dhcp4.log"
                }
            ],
            "severity": "INFO",
            "debuglevel": 0
        }
      ]
      }
    }
    
  3. Mount the RHEL 10 DVD and for copying the boot related files and provide installation source in /var/www/html

    # mkdir -v /mnt/dvd
    # mount -v /root/rhel-10.0-x86_64-dvd.iso /mnt/dvd
    # ln -s /mnt/dvd /var/www/html/dvd
    
  4. Place boot files in the TFTP root directory which by default is located at /var/lib/tftpboot

    # cp -av /mnt/dvd/boot /var/lib/tftpboot/bios
    # cp -av /mnt/dvd/EFI /var/lib/tftpboot/uefi
    # cp -av /mnt/dvd/images /var/lib/tftpboot/images
    
  5. Modify the existing boot configuration to point create a new PXE boot entry.
    For BIOS,

    • Modify the BIOS grub configuration file /var/lib/tftpboot/bios/grub2/grub.cfg and add/modify PXE boot menuentry as below.

      menuentry 'PXE Install Red Hat Enterprise Linux 10.0' --class fedora --class gnu-linux --class gnu --class os {
              linux /images/pxeboot/vmlinuz inst.stage2=http://192.168.10.1/dvd/ quiet
              initrd /images/pxeboot/initrd.img
      }
      
    • Additinally for BIOS,the boot configuration file /var/lib/tftpboot/bios/grub2/grub.cfg should be placed in the same directory as the bootloader file /var/lib/tftpboot/bios/grub2/i386-pc/core.0 , so create a symlink for the grub.cfg in the same directory as core.0

      # ln -s ../grub.cfg /var/lib/tftpboot/bios/grub2/i386-pc/
      

    For UEFI,

    • Modify the UEFI grub configuraiton file /var/lib/tftpboot/uefi/BOOT/grub.cfg and add/modify the PXE boot menuentry as below

      menuentry 'PXE Install Red Hat Enterprise Linux 10.0' --class fedora --class gnu-linux --class gnu --class os {
              linuxefi /images/pxeboot/vmlinuz inst.stage2=http://192.168.10.1/dvd/ quiet
              initrdefi /images/pxeboot/initrd.img
      }
      
    • Additonally for UEFI, make sure we have read permission for all the UEFI bootloader and configuration files.

      # chmod -R a+rX /var/lib/tftpboot/uefi/BOOT/
      
  6. Optional: You may copy these files from /var/lib/tftpboot to /var/www/html for performing HTTP boot using UEFI if your firmware supports it.

    # cp -av /var/lib/tftpboot/{uefi,images} /var/www/html/
    
  7. Enable firewall ports and set restore the SELinux context (if required)

    # firewall-cmd --add-service=tftp --permanent
    # firewall-cmd --add-service=http --permanent
    # firewall-cmd --reload
    # restorecon -FRv /var/lib/tftpboot /var/www/html
    
  8. Enable all the services.

    # systemctl enable --now kea-dhcp4
    # systemctl enable --now tftp.socket
    # systemctl enable --now httpd
    

Troubleshooting

  • DHCP :

    • To troubleshoot DHCP related issues with the kea-dhcp4 service, refer the logs in /var/log/kea/kea-dhcp4.log
    • The verbosity of these logs can be increased by setting severity and debuglevel under the loggers in the kea configuration.
  • TFTP :

    • TFTP service logs will be logged to system journal and is accessible when running journalctl -t in.tftpd
    • Verbosity of these logs can be increased by editing the ExecStart line in the /usr/lib/systemd/system/tftp.service file by adding -v (can be added multiple times) for increasing the verbosity of the in.tftpd process. Make sure to run systemctl daemon-reload after changing the service file and restart the tftp.socket process.
  • HTTPD :

    • HTTPD access and error logs will be present inside /var/log/httpd for any issue related to HTTPD

Also refer the RHEL 10 Network Installation documentation for more information.

SBR
Components
Category

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.