跳转至

使用 ISC dhcpd

ISC dhcpd 是大多数 Linux 发行版上的默认 DHCP 服务器。它可以很容易地配置为支持 iPXE。

ISC dhcpd 使用文件 /etc/dhcpd.conf 进行配置。你可以使用 filename 指令指示 iPXE 启动:

  filename "pxelinux.0";

  filename "http://boot.ipxe.org/demo/boot.php";

要从 SAN 启动,你必须使用 option root-path 指令而不是 filename

  filename "";
  option root-path "iscsi:iscsi.example.com::::iqn.1992-01.com.example.iscsi:target";

  filename "";
  option root-path "aoe:e0.0";

PXE 链式加载

A chain

要使用 PXE 链式加载,你需要设置 ISC dhcpd,使其向传统 PXE 客户端分发 undionly.kpxeipxe.efi 之一,然后只向 iPXE 客户端分发"真正的"启动配置。你可以通过告诉 ISC dhcpd 根据 DHCP 用户类使用不同的配置来做到这一点:

  option client-architecture code 93 = unsigned integer 16;
  if exists user-class and option user-class = "iPXE" {
      filename "http://my.web.server/real_boot_script.php";
  } elsif option client-architecture = 00:00 {
      filename "undionly.kpxe";
  } else {
      filename "ipxe.efi";
  }

这将确保 iPXE 镜像(undionly.kpxe)只在 DHCP 请求来自传统 PXE 客户端时分发。一旦 iPXE 被加载,DHCP 服务器将引导它从 http://my.web.server/real_boot_script.php 启动。你应该把 filename "http://my.web.server/real_boot_script.php" 替换为你希望 iPXE 启动的任何内容。例如,如果你想链式加载到 iPXE,然后从 iSCSI 目标启动,你可以使用:

  option client-architecture code 93 = unsigned integer 16;
  if exists user-class and option user-class = "iPXE" {
      filename "";
      option root-path "iscsi:iscsi.example.com::::iqn.1992-01.com.example.iscsi:target";
  } elsif option client-architecture = 00:00 {
      filename "undionly.kpxe";
  } else {
      filename "ipxe.efi";
  }

iPXE 特有的选项

有几个 DHCP 选项是 iPXE 特有的,标准的 ISC dhcpd 安装无法识别它们。要添加对这些选项的支持,请把以下内容放在你的 /etc/dhcpd.conf 的开头:

  option space ipxe;
  option ipxe-encap-opts code 175 = encapsulate ipxe;
  option ipxe.priority code 1 = signed integer 8;
  option ipxe.keep-san code 8 = unsigned integer 8;
  option ipxe.skip-san-boot code 9 = unsigned integer 8;
  option ipxe.syslogs code 85 = string;
  option ipxe.cert code 91 = string;
  option ipxe.privkey code 92 = string;
  option ipxe.crosscert code 93 = string;
  option ipxe.no-pxedhcp code 176 = unsigned integer 8;
  option ipxe.bus-id code 177 = string;
  option ipxe.san-filename code 188 = string;
  option ipxe.bios-drive code 189 = unsigned integer 8;
  option ipxe.username code 190 = string;
  option ipxe.password code 191 = string;
  option ipxe.reverse-username code 192 = string;
  option ipxe.reverse-password code 193 = string;
  option ipxe.version code 235 = string;
  option iscsi-initiator-iqn code 203 = string;
  # Feature indicators
  option ipxe.pxeext code 16 = unsigned integer 8;
  option ipxe.iscsi code 17 = unsigned integer 8;
  option ipxe.aoe code 18 = unsigned integer 8;
  option ipxe.http code 19 = unsigned integer 8;
  option ipxe.https code 20 = unsigned integer 8;
  option ipxe.tftp code 21 = unsigned integer 8;
  option ipxe.ftp code 22 = unsigned integer 8;
  option ipxe.dns code 23 = unsigned integer 8;
  option ipxe.bzimage code 24 = unsigned integer 8;
  option ipxe.multiboot code 25 = unsigned integer 8;
  option ipxe.slam code 26 = unsigned integer 8;
  option ipxe.srp code 27 = unsigned integer 8;
  option ipxe.nbi code 32 = unsigned integer 8;
  option ipxe.pxe code 33 = unsigned integer 8;
  option ipxe.elf code 34 = unsigned integer 8;
  option ipxe.comboot code 35 = unsigned integer 8;
  option ipxe.efi code 36 = unsigned integer 8;
  option ipxe.fcoe code 37 = unsigned integer 8;
  option ipxe.vlan code 38 = unsigned integer 8;
  option ipxe.menu code 39 = unsigned integer 8;
  option ipxe.sdi code 40 = unsigned integer 8;
  option ipxe.nfs code 41 = unsigned integer 8;

加快 DHCP 速度

PXE 规范要求 iPXE 在启动前等待 ProxyDHCP 服务器的回复。如果你没有使用 ProxyDHCP 服务器,这会造成几秒钟的不必要延迟。你可以使用以下命令消除这种延迟:

  option ipxe.no-pxedhcp 1;

(如果你正在使用 ProxyDHCP 服务器,请不要这样做;这将导致 iPXE 忽略 ProxyDHCP 服务器发送的任何内容!)

测试特定特性

你可以使用特性指示选项来确定 iPXE 是否支持特定特性。例如,

  if exists ipxe.fcoe {
      option root-path "fcp:20:00:52:54:00:aa:b7:01:0";
  }

只会向启用了 FCoE 支持的 iPXE 客户端分发 FCoE 根路径。