dnsmasq - 每个 macaddress 的不同 tftp-root

dnsmasq - different tftp-root for each macaddress

是否可以在 dnsmasq.conf 中处理不同的 tftp 根?

类似于: IF MAC=19-4B-90-DA-1C-C3 然后 tftp-root=/tftpbootAB

IF MAC=19-4B-90-DE-1C-B6 然后 tftp-root=/tftpbootCD

我在手册中找不到这个。

我只找到类似的东西: dhcp-match=set:bios,option:client-arch,0 dhcp-boot=tag:efi-x86_64,"efi64/syslinux.efi"

但不适用于带有 tftp-root 的线路

我也在找这个,并在 man dnsmasq 中找到了解决方案。有一个选项:

--tftp-unique-root[=ip|mac]
Add the IP or hardware address of the TFTP client as a path component on the end of the TFTP-root. Only valid if a tftp-root is set and the directory exists. Defaults to adding IP address (in standard dotted-quad format). For instance, if tftp-root is "/tftp" and client 1.2.3.4 requests file "myfile" then the effective path will be "/tftp/1.2.3.4/myfile" if /tftp/1.2.3.4 exists or /tftp/myfile otherwise. When "=mac" is specified it will append the MAC address instead, using lowercase zero padded digits separated by dashes, e.g.: 01-02-03-04-aa-bb Note that resolving MAC addresses is only possible if the client is in the local network or obtained a DHCP lease from us.

/etc/dnsmasq.conf 中的代码片段如下所示(示例):

enable-tftp
tftp-root=/tftpboot
tftp-unique-root=mac
pxe-service=0,"Raspberry Pi Boot"

然后创建目录:

~$ sudo mkdir -p /tftpboot/19-4b-90-da-1c-c3
~$ sudo mkdir -p /tftpboot/19-4b-90-de-1c-b6

并将特定设备(mac 地址)所需的引导文件放入其子目录中。