Skip to content

Instantly share code, notes, and snippets.

@HikariKnight
Last active March 6, 2022 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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} %>";
}
}
% }
@faaziz
Copy link

faaziz commented Mar 6, 2022

Hi,

Is there a guide I could use to understand how Zentyal and Fog server are tied together. Right now Zentyal is handling DHCP and DNS and I cannot move away from it since I am using it as domain controller.

From the script above it's not clear Fog server is running on a different host if that's the case how does Zentyal figure out where Fog server is installed?

Thanks,
Faisal

@HikariKnight
Copy link
Author

hi @faaziz thats because this script does nothing to this part, it only handles the file path for the "thin client/external tftp-server" option under the advanced tab in DHCP.

It hardcodes the bios boot image to be undionly.kpxe while the efi boot image name is gotten from the file path inputbox.

for your config just set the External TFTP-server Next Server option to Host then the IP for the fog server
image

@faaziz
Copy link

faaziz commented Mar 6, 2022

Thanks for the quick turnaround. I will give it shot.

@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