dnsmasq: Dynamic dhcp-boot based on hostname requesting
by marymac39 from LinuxQuestions.org on (#4T0JK)
Hi All,
TL;DR: When a client requests its boot file, need to serve a boot file with the requesting clients hostname or IP or MAC appended to the end via dnsmasq.
Hopefully easy question on using dnsmasq to serve a dynamic boot file to requesting clients based on the requesting clients IP or hostname.
Use case: Provisioning multiple hosts at the same time with different versions/archs of RHEL via network booting using dnsmasq. Have some background scripts putting boot files in particular places prior to install, but need to leverage dnsmasq to serve the desired boot file to the host requesting it.
Plan so far: Given hostname "test.system.one", appropriate boot file would be placed in tftproot with "-test.system.one" appended to file name. When this client requests its boot file from dnsmasq, I would like to be able to have dnsmasq realize the hostname requesting it, and serve the boot file with that hostname appended to it. Could be IP or MAC as well, anything unique to that machine. Basically, is there a way in a dnsmasq config to reference the IP/hostname/MAC via a variable?
Currently, I have dnsmasq configured to serve different boot files based on the client-arch option 93 to differentiate between legacy and EFI BIOS systems:
# Legacy BIOS
dhcp-match=set:bios,option:client-arch,0
# 64 bit x86 EFI
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-boot=tag:bios,"pxelinux.0"
dhcp-boot=tag:efi-x86_64,"BOOTX64.EFI"
I would like to keep this setup but enhance it. Given that I may have multiple machines to provision simultaneously, I would like to pre-populate tftproot with all of their boot files (with hostname appended) and then have dnsmasq pre-configured to append the hostname to the boot file it serves with the dhcp-boot option.
Any ideas? I realize this may not be the best way to realize my use case, but it is a setup I have inherited and need to augment in the manner described above if possible. Thank you.


TL;DR: When a client requests its boot file, need to serve a boot file with the requesting clients hostname or IP or MAC appended to the end via dnsmasq.
Hopefully easy question on using dnsmasq to serve a dynamic boot file to requesting clients based on the requesting clients IP or hostname.
Use case: Provisioning multiple hosts at the same time with different versions/archs of RHEL via network booting using dnsmasq. Have some background scripts putting boot files in particular places prior to install, but need to leverage dnsmasq to serve the desired boot file to the host requesting it.
Plan so far: Given hostname "test.system.one", appropriate boot file would be placed in tftproot with "-test.system.one" appended to file name. When this client requests its boot file from dnsmasq, I would like to be able to have dnsmasq realize the hostname requesting it, and serve the boot file with that hostname appended to it. Could be IP or MAC as well, anything unique to that machine. Basically, is there a way in a dnsmasq config to reference the IP/hostname/MAC via a variable?
Currently, I have dnsmasq configured to serve different boot files based on the client-arch option 93 to differentiate between legacy and EFI BIOS systems:
# Legacy BIOS
dhcp-match=set:bios,option:client-arch,0
# 64 bit x86 EFI
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-boot=tag:bios,"pxelinux.0"
dhcp-boot=tag:efi-x86_64,"BOOTX64.EFI"
I would like to keep this setup but enhance it. Given that I may have multiple machines to provision simultaneously, I would like to pre-populate tftproot with all of their boot files (with hostname appended) and then have dnsmasq pre-configured to append the hostname to the boot file it serves with the dhcp-boot option.
Any ideas? I realize this may not be the best way to realize my use case, but it is a setup I have inherited and need to augment in the manner described above if possible. Thank you.