Does dnsmasq support "client-arch code 93"?

Hi,

Trying to serve the correct ipxe boot file based on the client cpu architecture

My script is as follows, doesn't cause error, but it also doesn't do anything
dnsmasq still only serves the file specified in config dnsmasq option dhcp_boot

This is how it would be done with the ISC DHCPD server

option client-arch code 93 = unsigned integer 16;
  if exists user-class and option user-class = "iPXE" {
    filename "http://router.lan/ipxe.ipxe";
    } elsif exists client-arch {
         if option client-arch = 00:00 {
           filename "ipxe.i386.undionly.kpxe";
         } elsif option client-arch = 00:06 {
           filename "ipxe.i386.efi";
         } elsif option client-arch = 00:07 {
           filename "ipxe.x86_64.efi";
         } elsif option client-arch = 00:09 {
           filename "ipxe.x86_64.efi";
         } elsif option client-arch = 00:0a {
           filename "ipxe.arm32.efi";
         } elsif option client-arch = 00:0b {
           filename "ipxe.arm64.efi";
         }
      }

Old thread but I think it might help.

Do not modify /etc/dnsmasq.conf.

Move the dnsmasq confdir to /etc and create your custom files there.

uci set dhcp.@dnsmasq[0].confdir='/etc/dnsmasq.d'
uci commit dhcp
/etc/init.d/dnsmasq restart
2 Likes

Thanks, that put me on the right track, the syntax I was using is apparently incompatible with dnsmasq

I found the dnsmasq man page

From the example, I figure I need to put this somewhere

dhcp-match=set:x86-legacy,option:client-arch,0
dhcp-match=set:x86-uefi,option:client-arch,6
dhcp-match=set:x86_64-uefi,option:client-arch,7
dhcp-match=set:x86_64-uefi,option:client-arch,9
dhcp-match=set:arm32-uefi,option:client-arch,a
dhcp-match=set:arm64-uefi,option:client-arch,b
dhcp-match=set:ipxe,77,"iPXE"

dhcp-boot=tag:x86-legacy,ipxe.x86.undionly.kpxe,router.lan,192.168.1.1
dhcp-boot=tag:x86-uefi,ipxe.x86.efi,router.lan,192.168.1.1
dhcp-boot=tag:x86_64-uefi,ipxe.x86_64.efi,router.lan,192.168.1.1
dhcp-boot=tag:arm32-uefi,ipxe.arm32.efi,router.lan,192.168.1.1
dhcp-boot=tag:arm64-uefi,ipxe.arm64.snponly.efi,router.lan,192.168.1.1
dhcp-boot=tag:ipxe,http://router.lan/boot.ipxe,router.lan,192.168.1.1

I am hoping to find a way to accomplish this using only the luci web interface

I tried this but I think it's too optimistic (also I had the wrong filenames)

It wrote the following in /etc/config/dhcp

config boot
        list dhcp_option 'dhcp-match=set:x86-legacy,option:client-arch,0 dhcp-match=set:x86-uefi,option:client-arch,6 dhcp-match=set:x86_64-uefi,option:client-arch,7 dhcp-match=set:x86_64-uefi,option:client-arch,9 dhcp-match=set:arm32-uefi,option:client-arch,a dhcp-match=set:arm64-uefi,option:client-arch,b dhcp-match=set:ipxe,77,"iPXE"  dhcp-boot=tag:x86-legacy,undionly.kpxe,router.lan,192.168.1.1 dhcp-boot=tag:x86-uefi,ipxe.efi,router.lan,192.168.1.1 dhcp-boot=tag:x86_64-uefi,ipxe.efi,router.lan,192.168.1.1 dhcp-boot=tag:arm32-uefi,ipxe.efi,router.lan,192.168.1.1 dhcp-boot=tag:arm64-uefi,ipxe.efi,router.lan,192.168.1.1 dhcp-boot=tag:ipxe,http://router.lan/boot.ipxe,router.lan,192.168.1.1'

I had a look at my /etc/dnsmasq.conf file, but it's an example file and every line is commented out !?
So perhaps the dnsmasq settings are stored elsewhere other than /etc/dnsmasq.con or /etc/config/dhcp

The dnsmasq man page doesn't mention sections called "config boot" not a command called dhcp_option so I guess that's uci syntax only

I tried a different approach, this time each line is a separate item

This wrote in /etc/config/dhcp as follows

Unfortunately, that doesn't work either

and it's 04h30 so that's it for tonight, I'll give this another shot tomorrow

EDIT :
Just for kicks, I tried dumping the config text in /etc/dnsmasq.conf despite your recommendation

Boot ipxe clients correctly (serves http://router.lan/boot.ipxe)
I have a legacy pxe boot client, this got served the arm64 file ?!

commented out both arm32 and arm64, now it works on a x86_64 PC both legacy and uefi modes

and it's 04h56 , well I'll make this play nicer with openwrt tomorrow, at least it works now !

uci set dhcp.@dnsmasq[0].confdir='/etc/dnsmasq.d'
uci commit dhcp
/etc/init.d/dnsmasq restart

cat << "EOF" > /etc/dnsmasq.d/client_arch.conf
dhcp-match=set:x86-legacy,option:client-arch,0
dhcp-match=set:x86-uefi,option:client-arch,6
dhcp-match=set:x86_64-uefi,option:client-arch,7
dhcp-match=set:x86_64-uefi,option:client-arch,9
dhcp-match=set:arm32-uefi,option:client-arch,a
dhcp-match=set:arm64-uefi,option:client-arch,b
dhcp-match=set:ipxe,77,"iPXE"

dhcp-boot=tag:x86-legacy,ipxe.x86.undionly.kpxe,router.lan,192.168.1.1
dhcp-boot=tag:x86-uefi,ipxe.x86.efi,router.lan,192.168.1.1
dhcp-boot=tag:x86_64-uefi,ipxe.x86_64.efi,router.lan,192.168.1.1
dhcp-boot=tag:arm32-uefi,ipxe.arm32.efi,router.lan,192.168.1.1
dhcp-boot=tag:arm64-uefi,ipxe.arm64.snponly.efi,router.lan,192.168.1.1
dhcp-boot=tag:ipxe,http://router.lan/boot.ipxe,router.lan,192.168.1.1
EOF
/etc/init.d/dnsmasq restart

Your custom configuration will be located in /etc/dnsmasq.d/client_arch.conf

I've never used this menu, but what you're doing doesn't seem right to me.

The running config file is automatically generated:

cat /tmp/etc/dnsmasq.conf*

Not a problem. My recommendation was to not mess with the default config file if you have other options.