1.4.7 Configuring DHCP and TFTP Services to Support PXE Clients

The server or servers that host the DHCP and TFTP services do not need to host the installation packages. The DHCP server defines the boot loader file and the TFTP server from which a client can download the boot-loader, installation kernel, and initial ram-disk files. The boot-loader files that the TFTP server hosts can optionally define the server from which a client can obtain the installation packages.

To configure the Dynamic Host Configuration Protocol (DHCP) and Trivial File Transfer Protocol (TFTP) services for PXE client installation requests:

  1. Configure the DHCP service on a server:

    1. Install the dhcp package.

      # yum install dhcp
    2. Edit /etc/dhcp/dhcpd.conf and configure an entry for the PXE clients, for example:

      allow booting;
      allow bootp;
      
      set vendorclass = option vendor-class-identifier;
      option pxe-system-type code 93 = unsigned integer 16;
      set pxetype = option pxe-system-type;
      
      option domain-name "mydom.com";
      
      subnet 10.0.0.0 netmask 255.255.255.0 {
        option domain-name-servers 10.0.0.1;
        option broadcast-address 10.0.0.255;
        option routers 10.0.0.1;
        default-lease-time 14400;
        max-lease-time 28800;
        if substring(vendorclass, 0, 9)="PXEClient" {
          if pxetype=00:06 or pxetype=00:07 {
              filename "efi/BOOTX64.efi";
          } else {
              filename "pxelinux/pxelinux.0";
          }
        }
        pool {
          range 10.0.0.101 10.0.0.200;
        }
        next-server 10.0.0.6;
      }
      
      host svr1 {
      hardware ethernet 08:00:27:c6:a1:16;
      fixed-address 10.0.0.253;
      option host-name "svr1";
      } 
      
      host svr2 {
      hardware ethernet 08:00:27:24:0a:56;
      fixed-address 10.0.0.254;
      option host-name "svr2";
      } 

      This example configures a pool of generally available IP addresses in the range 10.0.0.101 through 10.0.0.200 on the 10.0.0/24 subnet. Any PXE-booted system on the subnet uses the boot loader that the filename parameter specifies for its PXE type. The boot-loader file BOOTX64.efi for UEFI-based clients is located in the efi subdirectory of the TFTP server directory. The boot-loader file pxelinux.0 for BIOS-based clients is located in the pxelinux subdirectory.

      The next-server statement specifies the IP address of the TFTP server from which a client can download the boot-loader file.

      Note

      You should include a next-server statement even if you use the same server to host both DHCP and TFTP services. Otherwise, some boot loaders do not know how to obtain their configuration files, which causes them to reboot the client, to hang, or to display a prompt such as boot: or grub>.

      The static IP addresses 10.0.0.253 and 10.0.0.254 are reserved for svr1 and svr2, which are identified by their MAC addresses.

    3. If the server has more than one network interface, edit /etc/sysconfig/dhcpd and configure the interface on which the server should respond to DHCP requests, for example:

      DHCPDARGS="eth1"
    4. Start the DHCP service, and configure it to start after a reboot.

      # service dhcpd start
      # chkconfig dhcpd on

      If you make any changes to /etc/dhcp/dhcpd.conf, restart the dhcpd service. You do not need to restart the service if you change the content of boot loader configuration files.

    5. Configure the firewall to accept DHCP requests, for example:

      # iptables -I INPUT -i eth1 -p udp --dport 67:68 --sport 67:68 -j ACCEPT
      # service iptables save

      In this example, the server expects to receive requests on interface eth1.

  2. Configure the TFTP service on a server:

    1. Install the syslinux and tftp-server packages:

      # yum install syslinux tftp-server

      The syslinux package provides the pxelinux.0 boot loader, which BIOS-based PXE clients can use to load the Linux installation kernel (vmlinuz).

      UEFI-based PXE clients can use the BOOTX64.efi boot loader, which is available as EFI/BOOT/BOOTX64.efi from the Oracle Linux 6 Update 6 Media Pack DVD image.

    2. Edit /etc/xinetd.d/tftp and modify the disable and server_args attributes to enable xinetd to start the TFTP service (in.tftpd) and define the TFTP server directory, for example:

      service tftp
      {
          socket_type = dgram
          protocol    = udp
          wait        = yes
          user        = root
          server      = /usr/sbin/in.tftpd
          server_args = -s /var/lib/tftpboot
          disable     = no
          per_source  = 11
          cps         = 100 2
          flags       = IPv4
      }

      This example defines the TFTP server directory to be /var/lib/tftpboot, which is the default.

      When xinetd receives a TFTP request, it starts in.tftpd and directs the request to it.

      For more information about the configuration attributes, see the xinetd.conf(5) manual page.

    3. Create efi and pxelinux/pxelinux.cfg subdirectories of the TFTP server directory, for example:

      # mkdir -p /var/lib/tftpboot/efi
      # mkdir -p /var/lib/tftpboot/pxelinux/pxelinux.cfg

      These directories are used to contain the boot loader configuration files for UEFI and BIOS-based PXE clients respectively.

    4. Copy the BIOS boot-loader file to the pxelinux directory, the UEFI boot-loader and splash image files to the efi subdirectory, and the installation kernel and ram-disk image files to both subdirectories, for example:

      # cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/pxelinux/pxelinux.0
      # wget http://10.0.0.11/OSimage/OL6.6/EFI/BOOT/BOOTX64.efi \
        -O /var/lib/tftpboot/efi/BOOTX64.efi
      # wget http://10.0.0.11/OSimage/OL6.6/EFI/BOOT/splash.xpm.gz \
        -O /var/lib/tftpboot/efi/splash.xpm.gz
      # wget http://10.0.0.11/OSimage/OL6.6/isolinux/vmlinuz \
        -O /var/lib/tftpboot/efi/vmlinuz-OL6u6
      # wget http://10.0.0.11/OSimage/OL6.6/isolinux/initrd.img \
        -O /var/lib/tftpboot/efi/initrd-OL6u6.img
      # ln /var/lib/tftpboot/efi/vmlinuz-OL6u6 /var/lib/tftpboot/pxelinux/vmlinuz-OL6u6
      # ln /var/lib/tftpboot/efi/initrd-OL6u6.img /var/lib/tftpboot/pxelinux/initrd-OL6u6.img

      This example uses HTTP to obtain the BOOTX64.efi, splash.xpm.gz, vmlinuz, and initrd.img files from an installation server.

      To be able to install different operating system versions on PXE clients, vmlinuz and initrd.img are renamed as vmlinuz-OL6u6 and initrd-OL6u6.img. Alternatively, you could copy the kernel and ram-disk image files to subdirectories such as efi/OL6u6 and pxelinux/OL6u6.

    5. Create the default boot loader configuration file, for example efi/efidefault or pxelinux/pxelinux.cfg/default.

      For more information, see Section 1.4.9, “About Boot-Loader Configuration Files”.

    6. If SELinux is enabled in enforcing mode on your system and you configure a TFTP server directory other than /var/lib/tftpboot, use the semanage command to define the default file type of the TFTP server directory hierarchy as tftpdir_t and then use the restorecon command to apply the file type to the entire directory hierarchy, for example:

      # /usr/sbin/semanage fcontext -a -t tftpdir_t "/var/tftpboot(/.*)?"
      # /sbin/restorecon -R -v /var/tftpboot
      Note

      The semanage and restorecon commands are provided by the policycoreutils-python and policycoreutils packages.

    7. Start the xinetd service, and configure it to start after a reboot.

      # service xinetd start
      # chkconfig xinetd on

      If you make any changes to /etc/xinetd.d/tftp, restart the xinetd service. You do not need to restart the service if you change the content of boot loader configuration files.

    8. Configure the firewall to accept TFTP requests, for example:

      # iptables -I INPUT -i eth1 -p udp --dport 69 -j ACCEPT
      # service iptables save

      In this example, the server expects to receive requests on interface eth1.

For information about configuring and using kickstart to perform automated installation, see Chapter 3, Installing Oracle Linux by Using Kickstart.