在 Red Hat 7.9 中如何设置变量“pxe_default_server”?

在 Red Hat 7.9 中如何设置变量“pxe_default_server”?

我们有一台 RHEL 7.9 服务器,它充当为多个子网提供服务的 DHCP/TFTP (PXE) 服务器。以下是我们的 dhcpd.conf 文件的副本(DHCP/PXE 服务器是 XY145.98):

allow bootp;
allow booting;
max-lease-time 1200;
default-lease-time 900;

subnet X.Y.145.96 netmask 255.255.255.224 {
  option routers X.Y.145.126;
  range X.Y.145.100 X.Y.145.105;
  next-server X.Y.145.98;
  filename "pxelinux.0"
}

subnet X.Y.145.144 netmask 255.255.255.248 {
  option routers X.Y.145.145;
  range X.Y.145.146 X.Y.145.150;
  next-server X.Y.145.98;
  filename "pxelinux.0"
}

我们看到的问题是 grub.cfg 抓取的是变量的参数 IP,options routerpxe_default_server不是next-server参数本身。pxe_default_server然后使用 ( ) 来定义变量net_default_server参数,我们的 PXE 失败,因为它指向网关 IP,而不是 DHCP/PXE 服务器 IP。如果我们编辑 grub.cfg 文件以将参数硬编码pxe_default_server为等于 DHCP/PXE 服务器的 IP...我们可以正常启动并下载映像。我应该使用其他参数吗?

答案1

Grub 肯定感到困惑,但是你的 dhcpd.confg 有问题。

  1. 您有 2 个子网,但您在两个子网中都提供了相同的“下一个服务器”IP,这意味着对于一个子网,TFTP 服务器可能不可见,具体取决于您的布局。
  2. 您没有定义每个子网的“广播地址”
  3. 您甚至向非 PXE 启动客户端提供 PXE 数据。

请看此处的示例: https://www.redhat.com/sysadmin/pxe-boot-uefi

# DHCP Server Configuration File
#
#. see /usr/share/doc/dhcp*/dhcpd.conf.example
#
#. see dhcpd.conf(5) man page


option rfc3442-classless-static-routes code 121 = array of integer 8;
option ms-classless-static-routes code 249 = array of integer 8;
option space pxelinux;
option pxelinux.magic code 208 = string;
option pxelinux.configfile code 209 = text;
option pxelinux.pathprefix code 210 = text;
option pxelinux.reboottime code 211 = unsigned integer 32;
option architecture-type code 93 = unsigned integer 16;
subnet 192.168.1.0 netmask 255.255.255.0 {
   option routers 192.168.1.0;
   option subnet-mask 255.255.255.0;
   option broadcast-address 192.168.1.255;
}

subnet 192.168.2.0 netmask 255.255.255.0 {
   option routers 192.168.2.1;
   option subnet-mask 255.255.255.0;
   option broadcast-address 192.168.2.255;
   range 192.168.2.2 192.168.2.254;

   class "pxeclients" {
     match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
     next-server 192.168.1.10;
     if option architecture-type = 00:07 {
        filename "shim.efi";
        } else {
        filename "pxelinux/pxelinux.0";
     }
   }
}

subnet 192.168.3.0 netmask 255.255.255.0 {
   option routers 192.168.3.1;
   option subnet-mask 255.255.255.0;
   option broadcast-address 192.168.3.255;
   range 192.168.3.2 192.168.3.254;

   class "pxeclients" {
     match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";
     next-server 192.168.1.10;
     if option architecture-type = 00:07 {
        filename "shim.efi";
        } else {
        filename "pxelinux/pxelinux.0";
     }
   }
}

答案2

allow bootp;
allow booting;
max-lease-time 1200;
default-lease-time 900;

subnet X.Y.145.96 netmask 255.255.255.224 {
  option routers X.Y.145.126;
  option pxe-server-name X.Y.145.98;
  range X.Y.145.100 X.Y.145.105;
  next-server X.Y.145.98;
  filename "pxelinux.0";
}

subnet X.Y.145.144 netmask 255.255.255.248 {
  option routers X.Y.145.145;
  option pxe-server-name X.Y.145.98;
  range X.Y.145.146 X.Y.145.150;
  next-server X.Y.145.98;
  filename "pxelinux.0";
}

相关内容