Skip to content

Instantly share code, notes, and snippets.

@dreamcat4
Created May 5, 2016 09:55
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dreamcat4/fe899a9baecb5fed3a3e3749dfd8e61e to your computer and use it in GitHub Desktop.
Save dreamcat4/fe899a9baecb5fed3a3e3749dfd8e61e to your computer and use it in GitHub Desktop.
user=root
# disable dns server
port=0
# enable tftp server
enable-tftp
tftp-root=/pxe
# dhcp proxy mode. do not act as the authoratitive dhcp server
dhcp-range=192.168.0.1,proxy,255.255.0.0
# send disable multicast and broadcast discovery, and to download the boot file immediately
dhcp-option=vendor:PXEClient,6,2b
# set tag ENH if request comes from iPXE (iPXE user class)
# dhcp-match=set:ENH,175 # alternative way, look for option 175
dhcp-userclass=set:ENH,iPXE
#Here, I define netboot types
#dhcp-vendorclass=set:BIOS,PXEClient:Arch:00006
#dhcp-vendorclass=set:UEFI,PXEClient:Arch:00007
# when dhcp-range mode=proxy, the filename to download. here the .0 is ommited as it gets auto-added
# if request comes from firmware, load iPXE via TFTP
#pxe-service=tag:!ENH,tag:BIOS,X86PC, PC-DOS: Chainload Boot - iPXE, undionly.kpxe
#pxe-service=tag:!ENH,tag:UEFI,X86-64_EFI, UEFI: Chainload Boot - iPXE, ipxe.efi
#pxe-service=tag:!ENH,X86-64_EFI, UEFI: Chainload Boot - iPXE, ipxe.efi
pxe-service=tag:!ENH,X86PC, PC-DOS: Chainload Boot - iPXE, undionly.kpxe
# if request comes from iPXE, direct it to boot from boot.ipxe
# dhcp-boot=tag:ENH,http://192.168.69.69/boot.ipxe
#pxe-service=tag:ENH,tag:BIOS,X86PC, PC-DOS: boot.ipxe - iPXE, http://192.168.69.69/boot.ipxe
#pxe-service=tag:ENH,tag:UEFI,X86-64_EFI, UEFI: boot-uefi.ipxe - iPXE, http://192.168.69.69/boot-uefi.ipxe
#pxe-service=tag:ENH,X86-64_EFI, UEFI: boot-uefi.ipxe - iPXE, http://192.168.69.69/boot-uefi.ipxe
pxe-service=tag:ENH,X86PC, PC-DOS: boot.ipxe - iPXE, http://192.168.69.69/boot.ipxe
# optional settings
# move boot server and filename information out of dedicated fields into DHCP options.
# makes extra space in the DHCP packet for other options but can confuse old / broken clients
#dhcp-no-override
# secure: only serve files owned by the dnsmasq user (root)
#tftp-secure
# enable logging
log-queries
log-dhcp
@JunielKatarn
Copy link

Hi. I'm trying to get this to work in the following setting:

  • Linux server working as both DHCP, TFTP and HTTP servers using the same local address (192.168.143.1).
    • Contents of boot-uefi.ipxe are:
    #!ipxe
    
    shell
    
  • TFTP root contains ipxe.efi.
  • HTTP root contains boot-uefi.ipxe.
  • Client machine using UEFI, Secure Boot off, x64.

I copied most of your script with minimum modifications (omitting general config, which works fine for booting EFI loaders directly, including ipxe.efi via TFTP).

dhcp-option=vendor:PXEClient,6,2b

# dhcp-match=set:ENH,175 # alternative way, look for option 175
dhcp-userclass=set:ENH,iPXE

#Here, I define netboot types
#dhcp-vendorclass=set:UEFI,PXEClient:Arch:00007

# if request comes from firmware, load iPXE via TFTP
#pxe-service=tag:!ENH,tag:UEFI,X86-64_EFI, UEFI: Chainload Boot - iPXE, ipxe.efi
## non-vendor-tagged
pxe-service=tag:!ENH,X86-64_EFI, UEFI: Chainload Boot - iPXE, ipxe.efi

# if request comes from iPXE, direct it to boot from boot.ipxe
# dhcp-boot=tag:ENH,http://192.168.143.1:2004/boot-uefi.ipxe
#pxe-service=tag:ENH,tag:BIOS,X86PC, PC-DOS: boot.ipxe - iPXE, http://192.168.143.1:2004/boot.ipxe
#pxe-service=tag:ENH,tag:UEFI,X86-64_EFI, UEFI: boot-uefi.ipxe - iPXE, http://192.168.143.1:2004/boot-uefi.ipxe
## non-vendor-tagged
pxe-service=tag:ENH,X86-64_EFI, UEFI: boot-uefi.ipxe - iPXE, http://192.168.143.1:2004/boot-uefi.ipxe

As is, the client complains about not finding an operating system. Dnsmasq doesn't log anything.

Tried the following modifications:

  • Commenting out dhcp-option=vendor:PXEClient,6,2b.
    • The client fails to find an OS again. Dnsmasq logs the following:
      dnsmasq-dhcp: 848456621 available DHCP range: 192.168.143.3 -- 192.168.143.200
      dnsmasq-dhcp: 848456621 vendor class: PXEClient:Arch:00007:UNDI:003000
      dnsmasq-dhcp: 848456621 available DHCP range: 192.168.143.3 -- 192.168.143.200
      dnsmasq-dhcp: 848456621 vendor class: PXEClient:Arch:00007:UNDI:003000
      dnsmasq-dhcp: 848456621 available DHCP range: 192.168.143.3 -- 192.168.143.200
      dnsmasq-dhcp: 848456621 vendor class: PXEClient:Arch:00007:UNDI:003000
      dnsmasq-dhcp: 848456621 available DHCP range: 192.168.143.3 -- 192.168.143.200
      dnsmasq-dhcp: 848456621 vendor class: PXEClient:Arch:00007:UNDI:003000
      
  • Additionally, using the "alternate" method to set ENT instead of dhp-userclass.
    dhcp-match=set:ENH,175 # alternative way, look for option 175
    
    • Same result as before.
  • Additionally, uncommenting the following line:
    dhcp-boot=tag:ENH,http://192.168.143.1:2004/boot-uefi.ipxe
    
    • Same result.

Anything I may be missing?
Again, the rest of the config is also minimal and seems to play well with booting any EFI loader directly from TFTP.

@dreamcat4
Copy link
Author

dreamcat4 commented Sep 27, 2021 via email

@JunielKatarn
Copy link

I'm not sure here...

Understood. Thanks for your reply.

@tmatthews5511
Copy link

TFTP directory /tftpboot inaccessible: Permission denied <- I cannot solve this.

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