Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dnsmasq - different tftp-root for each macaddress

Is it possible to address different tftp-roots inside dnsmasq.conf?

Something like: IF MAC=19-4B-90-DA-1C-C3 THEN tftp-root=/tftpbootAB

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

I couldn't find this in the manual.

I only found something like: dhcp-match=set:bios,option:client-arch,0 dhcp-boot=tag:efi-x86_64,"efi64/syslinux.efi"

But not for the line with tftp-root

like image 920
baeckerman83 Avatar asked Nov 01 '25 03:11

baeckerman83


1 Answers

I was also looking for this and have found the solution in man dnsmasq. There is an option:

--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.

The snippet in /etc/dnsmasq.conf then looks like this (example):

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

Then create the directories:

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

and put the boot files you want for the specific device (mac address) into its subdirectory.

like image 137
Ingo Avatar answered Nov 04 '25 05:11

Ingo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!