我正在尝试配置 PXE 设置,其中我的 Ubuntu Server 22.04.3 LTS 将充当 TFTP 服务器 + ProxyDHCP(当前 DHCP 服务器必须保持不变)。我用谷歌搜索了很多,并尝试了很多不同的配置,但没有成功。让我向您展示当前的 /etc/dnsmasq.conf 内容:
#to disable DNS server
port=0
#enable TFTP server and set its root path
enable-tftp
tftp-root=/free/pxe
#enable ProxyDHCP server. The address 192.168.1.2 corresponds to the subnet in which the ProxyDHCP server will act (I read somewhere that any address inside the IP subnet is valid for this)
#The address 192.168.1.2 is that of my Ubuntu Server.
interface=enp2s0
dhcp-range=192.168.1.2,proxy
#boot configuration files for PXE clients
# boot config for BIOS systems
dhcp-match=set:bios-x86,option:client-arch,0
dhcp-boot=tag:bios-x86,firmware/ipxe.pxe
# boot config for UEFI systems
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-match=set:efi-x86_64,option:client-arch,9
dhcp-boot=tag:efi-x86_64,firmware/ipxe.efi
目前,TFTP 服务器无法工作(尝试使用我的 Windows 10 作为 TFTP 客户端),并且在尝试 PXE 启动时,出现错误“未收到启动文件名”。
如果需要,我可以提供更多信息。
谁能告诉我如何正确配置 dnsmasq 来修复 TFTP 和 ProxyDHCP 功能?
这是
dnsmasq
我使用过的配置,经过修改以匹配您提供的配置。我把这个放进去/etc/dnsmasq.d/pxe.conf
笔记
dnsmasq 2.90-0ubuntu0.20.04.1
)。dnsmasq
对于调试非常有用。例如journalctl -b -u dnsmasq.service
ipxe
当我测试它时,它可以与 ProxyDHCP 一起使用,但如果启用了安全启动,它就不起作用。ipxe
需要链式加载脚本文件。我添加了一个注释掉的示例。ipxe
,每种方案都有各自的缺点。例如我上次测试时grub
不支持 ProxyDHCP。不过,Fedora 版本的 grub 已打补丁以支持 ProxyDHCP。在分析了 Andrew 的帖子、阅读了archlinux wiki和man dnsmasq上的文档并测试了自己之后,我得到了适用于 BIOS PXE 和 UEFI PXE 的最终解决方案。文件内容
/etc/dnsmasq.d/pxe.conf
:本例的关键是使用
pxe-service
条目而不是dhcp-match
和dhcp-boot
条目。这些对于其他情况来说肯定是足够的,这些情况可能因操作系统或其他原因而有所不同。我不知道,但只知道对于这种情况,pxe-service
条目工作得很好。如果有人需要知道这一点,
X86PC
值 和X86-64_EFI
是客户端系统类型,或本手册中提到的CSA:man dnsmasq。另外,在本例中,我没有将 TFTP 服务器地址添加到 pxe-service 条目的末尾,因为 TFTP 服务器与 ProxyDHCP 服务器是同一主机,并且显然具有相同的地址。但如果是不同的,则必须在 pxe-service 语句的末尾添加 TFTP 服务器的 IP 地址,如 man 文章中所述。