Skip to content

Instantly share code, notes, and snippets.

@HikariKnight
Last active March 6, 2022 14:01
Show Gist options
  • Save HikariKnight/c2ffeef1d656dfbaf8dc610a55aa6143 to your computer and use it in GitHub Desktop.
Save HikariKnight/c2ffeef1d656dfbaf8dc610a55aa6143 to your computer and use it in GitHub Desktop.
pxeboot.mas file to include in /usr/share/zentyal/stubs/dhcp/subnet.mas for when you use fog server for pxe booting
<%doc>
This template generates a better tftp filenames based on architecture
for PXE booting.
Place this file in /usr/share/zentyal/stubs/dhcp
Include it by adding
<& pxeboot.mas, options => \%options &>
into the "if ($options{filename}) {" section of subnet.mas and comment out the
filename "<% $options{filename} %>"; line
</%doc>
<%args>
%options
</%args>
% if ($options{filename}) {
# Detect if UEFI/BIOS and use the right boot image
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) = "00002" {
# EFI client 32 bit Type1
filename "i386-efi/<% $options{filename} %>";
}
elsif substring (option vendor-class-identifier, 15, 5) = "00006" {
# EFI client 32 bit Type2
filename "i386-efi/<% $options{filename} %>";
}
elsif substring (option vendor-class-identifier, 15, 5) = "00007" {
# EFI client 64 bit Type1
filename "<% $options{filename} %>";
}
elsif substring (option vendor-class-identifier, 15, 5) = "00008" {
# EFI client 64 bit Type2
filename "<% $options{filename} %>";
}
elsif substring (option vendor-class-identifier, 15, 5) = "00009" {
# EFI client 64 bit Type3
filename "<% $options{filename} %>";
}
else {
# default to EFI 64 bit
filename "<% $options{filename} %>";
}
}
% }
@HikariKnight
Copy link
Author

@faaziz just keep in mind the file might have to be re-included after major updates or updates to zentyal-dhcp since they dont have any proper way to include files in for this specific thing :)

hence the gist on my end

@faziz
Copy link

faziz commented Mar 6, 2022

Quick question on the file path being set to ipxe.efi, where exactly is this file located?

@HikariKnight
Copy link
Author

the "file path" is in my example essentially tftp://192.168.10.250/ipxe.efi
but if the client is using 32bit EFI then it is tftp://192.168.10.250/i386-efi/ipxe.efi
if the client is using bios pxe then it is tftp://192.168.10.250/undionly.kpxe

these are the paths fogserver uses by default as per the fogserver wiki on how to configure your dhcp server to forward pxe requests to fogserver

@faziz
Copy link

faziz commented Mar 6, 2022

Thank you. I managed to get to the Fog menu, but I didn't have to make any change to the Zentyal subnet.mas file. I am wondering what is it that your changes are for? Forgive me for my ignorance, I am new around this space.

@HikariKnight
Copy link
Author

my changes are in order to make both bios pxe and efi pxe working not just one of the 2 as pointed out in my last message there are 3 different files used

bios pxe, 64bit ipxe, 32bit ipxe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment