PXE legacy & efi co-existence

Hi !
I'm experimenting with network boot.
I can start debian with nfs root using legacy PXE (pxelinux.0), it works fine.

Now I'd like to add support for UEFI PXE.
From what I read I need syslinux.efi and special conditional configuration for DHCP.

Something like this :

class "pxeclient" {
    match if substring (option vendor-class-identifier, 0, 9) = "PXEClient";

    if substring (option vendor-class-identifier, 15, 5) = "00000" {
        # BIOS client 
        filename "undionly.kpxe";
    }
    elsif substring (option vendor-class-identifier, 15, 5) = "00006" {
        # EFI client 32 bit
        filename   "ipxe32.efi";
    }
    else
        # default to EFI 64 bit
        filename   "ipxe.efi";
    }

How to configure similar behavior for openwrt/dnsmasq ?

This does not seem to be well documented but looking into /etc/init.d/dnsmasq I found solution

config match
        option networkid 'set:bios'
        option match '60,PXEClient:Arch:00000'
config match
        option networkid 'set:efi64'
        option match '60,PXEClient:Arch:00009'
config match
        option networkid 'set:efi64'
        option match '60,PXEClient:Arch:00007'
config boot
        option filename         'tag:bios,bios/pxelinux.0'
        option serveraddress    '192.168.1.1'
        option servername       'router'
config boot
        option filename         'tag:efi64,efi64/syslinux.efi'
        option serveraddress    '192.168.1.1'
        option servername       'router'

This is how its done for iPXE.
Its special tricky case.
If client is NOT iPXE then dhcp should provide path to executable
if client IS iPXE then dhcp provides path to initial config file for iPXE

config match
        option networkid 'set:bios'
        option match '60,PXEClient:Arch:00000'
config match
        option networkid 'set:efi64'
        option match '60,PXEClient:Arch:00009'
config match
        option networkid 'set:efi64'
        option match '60,PXEClient:Arch:00007'
config userclass
        option networkid 'set:ipxe'
        option userclass 'iPXE'
config boot
        option filename         'tag:bios,tag:!ipxe,bios/undionly.kpxe'
        option serveraddress    '192.168.1.1'
        option servername       'router'
config boot
        option filename         'tag:bios,tag:ipxe,bios/ipxe/boot.ipxe'
        option serveraddress    '192.168.1.1'
        option servername       'router'
config boot
        option filename         'tag:efi64,tag:!ipxe,efi64/ipxe.efi'
        option serveraddress    '192.168.1.1'
        option servername       'router'
config boot
        option filename         'tag:efi64,tag:ipxe,efi64/ipxe/boot.ipxe'
        option serveraddress    '192.168.1.1'
        option servername       'router'
1 Like

I'm really sorry not to be able to help with your issue bolvan but I haven't graduated to efi boot yet

But you have succeeded where I am failing to boot distros, if you could look at my post here and suggest anything that would be much appreciated: