pypxe / PyPXE

Pure Python PXE (DHCP-(Proxy)/TFTP/HTTP/NBD) Server
MIT License
547 stars 125 forks source link

Does not work with UEFI Boot #167

Open Horkyze opened 6 years ago

Horkyze commented 6 years ago

On Intel NUC, I had to switch to "Legacy Boot", in order to make it boot.

Should it work with UEFI Boot?

icb- commented 5 years ago

Yes, UEFI should work. I don't have a system to test UEFI PXE, so I'll need your help debugging this.

Can you share what error messages you get from your NUC, your PyPXE configuration settings, and debug output from PyPXE (add --debug all to your arguments. It will be very long.)

ef83 commented 5 years ago

I'm also facing EFI\UEFI issues, I believe at least one of the errors is finding the proper architecture file name. Earlier, the DHCP request options are moved into self.options[client_mac], not in self.leases[client_mac]['options']

` if not self.ipxe or not self.leases[client_mac]['ipxe']:

http://www.syslinux.org/wiki/index.php/PXELINUX#UEFI

            if client_mac in self.options.keys() and 93 in self.options[client_mac] and not self.force_file_name:
            #if 'options' in self.leases[client_mac] and 93 in self.leases[client_mac]['options'] and not self.force_file_name:
                print str("this is an option")
                [arch] = struct.unpack("!H", self.**options**[client_mac][93][0])
                filename = {0: 'pxelinux.0', # BIOS/default
                            6: 'syslinux.efi32', # EFI IA32
                            7: 'syslinux.efi64', # EFI BC, x86-64
                            9: 'syslinux.efi64'  # EFI x86-64
                            }[arch]`
icb- commented 5 years ago

@ef83, can you post your full command and debug logs? (add --debug dhcp to your command options)

With debug logging enabled, the parsed options are printed between <--BEGIN OPTIONS--> and <--END OPTIONS-->.

ef83 commented 5 years ago

I've been testing with some other PXE server software and they're working using my same media\kernels\boot loaders.
I'm getting the proper options, but if you look at these lines of code, you'll see you move out the options to it's own property. https://github.com/pypxe/PyPXE/blob/master/pypxe/dhcp.py#L115

Therefore, at this line of code, you should be using self.options not self.lease https://github.com/pypxe/PyPXE/blob/master/pypxe/dhcp.py#L283

So far I've fixed that code on my local setup but that only gets me to the proper bootloader based on the architecture.

2656 1492 2019-06-10 18:10:00,684 DEBUG <--BEGIN OPTIONS--> 2656 1492 2019-06-10 18:10:00,684 DEBUG {97: ['\x00B\x00r\x08\x14n\xa8n\xc6_(m\x1f\xaa\x0f%'], 53: ['\x01'], 55: ['\x01\x02\x03\x04\x05\x06\x0c\r\x0f\x11\x12\x16\x17\x1c()*+236:;<BCa\x80\x81\x82\x83\x84\x85\x86\x87'], 57: ['\x05\xb8'], 60: ['PXEClient:Arch:00009:????:??????'], 93: ['\x00\t'], 94: ['\x01\x03\x00']} 2656 1492 2019-06-10 18:10:00,684 DEBUG <--END OPTIONS-->

I've identified the issue, at least with my clients, and I'm trying to understand why. I think it has to do with the client side in EFI mode. Basically when you are sending the DHCP offer, it's being sent to some derived broadcast address. https://github.com/pypxe/PyPXE/blob/master/pypxe/dhcp.py#L41

I have some custom logging but here is my environment: 2396 2364 2019-06-11 12:02:24,473 INFO DHCP Server IP: 192.168.234.10 2396 2364 2019-06-11 12:02:24,489 INFO DHCP Server Port: 67 2396 2364 2019-06-11 12:02:24,505 INFO Lease Range: 192.168.234.1 - 192.168.234.15 2396 2364 2019-06-11 12:02:24,505 INFO Subnet Mask: 255.255.255.0 2396 2364 2019-06-11 12:02:24,520 INFO Router: 192.168.234.10 2396 2364 2019-06-11 12:02:24,520 INFO DNS Server: 8.8.8.8 2396 2364 2019-06-11 12:02:24,520 INFO Broadcast Address: 192.168.234.255 2396 2364 2019-06-11 12:02:24,536 INFO File Server IP: 192.168.234.10 2396 2364 2019-06-11 12:02:24,536 INFO Default File Name: pxelinux.0 2396 2364 2019-06-11 12:02:24,552 INFO ProxyDHCP Mode: False 2396 2364 2019-06-11 12:02:24,552 INFO Using iPXE: False 2396 2364 2019-06-11 12:02:24,552 INFO Using HTTP Server: False

SO here you'll see, the offers are being sent to the broadcast of [192.168.234.255] and that does not work. If I send it to the subnet broadcast of 255.255.255.255 then it is working just fine and I'm able to at least load my boatloaders.

icb- commented 5 years ago

Ok, first part, try see if the fix-architecture branch of my fork fixes the architecture detection.

Second part is harder to pin down. 255.255.255.255 won't work on systems with interfaces on multiple broadcast domains, but computing the subnet broadcast address generally works. If it doesn't for you, you can override the computed broadcast address with --dhcp-broadcast.