1

I'm trying to configure a PXE setup, in which my Ubuntu Server 22.04.3 LTS would act as TFTP server + ProxyDHCP (current DHCP server has to remain untouched). I've googled a lot, and tried a lot of different configurations, but didn't succeed. Let me show you the current /etc/dnsmasq.conf content:

#to disable DNS server
port=0

#enable TFTP server and set its root path
enable-tftp
tftp-root=/free/pxe

#enable ProxyDHCP server. The address 192.168.1.2 corresponds to the subnet in which the ProxyDHCP server will act (I read somewhere that any address inside the IP subnet is valid for this)
#The address 192.168.1.2 is that of my Ubuntu Server.
interface=enp2s0
dhcp-range=192.168.1.2,proxy

#boot configuration files for PXE clients
# boot config for BIOS systems
dhcp-match=set:bios-x86,option:client-arch,0
dhcp-boot=tag:bios-x86,firmware/ipxe.pxe
# boot config for UEFI systems
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-match=set:efi-x86_64,option:client-arch,9
dhcp-boot=tag:efi-x86_64,firmware/ipxe.efi

Currently, the TFTP server is not working (tried with my Windows 10 as a TFTP client), and when trying to PXE boot, the error "No boot filename received" appears.

I can provide more information if requested.

Can anybody tell me how to correctly configure dnsmasq to fix TFTP and ProxyDHCP functionality?

2 Answers 2

2

This is the dnsmasq configuration I have used, modified to match what you provided. I put this in /etc/dnsmasq.d/pxe.conf

# Disable DNS Server
port=0

# Enable TFTP server
enable-tftp
tftp-root=/srv/tftp

# Enable DHCP logging
log-dhcp

# Respond to PXE requests for the specified network;
# run as DHCP proxy
dhcp-range=192.168.1.0,proxy,255.255.255.0

# match all pxe clients
dhcp-match=set:pxe,60,PXEClient
# set tag based on client-arch
dhcp-match=set:bios,option:client-arch,0
dhcp-match=set:efi-x86,option:client-arch,6
dhcp-match=set:efi-x86_64,option:client-arch,7
dhcp-match=set:efi-x86_64,option:client-arch,9
dhcp-match=set:efi-arm32,option:client-arch,10
dhcp-match=set:efi-arm64,option:client-arch,11

# match ipxe, which can help chainload
dhcp-match=set:ipxe,175

# bios
pxe-service=tag:pxe,tag:bios,X86PC,"Network Boot BIOS",ipxe.pxe,192.168.1.2

# uefi
pxe-service=tag:pxe,tag:efi-x86_64,x86-64_EFI,"Network Boot UEFI x86_64",ipxe.efi,192.168.1.2

# chainload ipxe
#pxe-service=tag:bios,tag:!ipxe,X86PC,"iPXE BIOS",ipxe.pxe,192.168.1.2
#pxe-service=tag:efi-x86_64,tag:!ipxe,x86-64_EFI,"iPXE UEFI",ipxe.efi,192.168.1.2
#pxe-service=tag:bios,tag:ipxe,X86PC,"iPXE BIOS script",script.ipxe,192.168.1.2

Notes

  • I have used this configuration on Ubuntu 20.04 (dnsmasq 2.90-0ubuntu0.20.04.1).
  • The dnsmasq logs are very useful for debugging. E.g. journalctl -b -u dnsmasq.service
  • ipxe worked with ProxyDHCP when I tested it, but it did not work if Secure Boot was enabled.
  • with ipxe you may need to chainload a script file. I added a commented out example.
  • There are alternative options to ipxe, and each has their own drawbacks. E.g. the last time I tested grub did not support ProxyDHCP. However, the Fedora version of grub has been patched to support ProxyDHCP.
3
  • Andrew, I have been testing based on your suggested config, and it works for UEFI! this is obviously a victory, but sadly the BIOS PXE is not working. Do you know why? (see the ----edit----) Regarding the chainload pxe section, it is not necessary since I compiled the ipxe.pxe and the ipxe.efi files to include the config/boot.ipxe stored in the TFTP directory. I did this following the guide at linuxhint guide. Thanks
    – Free
    Mar 5 at 21:35
  • Andrew, thanks to your ideas I got to the definite answer. FYI, in case you want to know, I saw two errors in your configuration: One is that it's not necessary to use dhcp-match entries to work together with the pxe-service entries. The pxe-service entries are sufficient, because of the CSA which are x86PC and X86-64_EFI and define the client architecture. The other thing (not sure, but) I think that they are case sensitive and X64PC is not correct and x86-64_EFI too, they should be x64PC and X86-64_EFI so maybe that was why I was still having errors. Thanks anyway, your answer really helpd
    – Free
    Mar 6 at 15:40
  • 1
    @Free thanks for posting your working solution. My recommendation was going to be check the dnsmasq logs. They will tell you if it responded to DHCP and what files are requested over tftp. This will tell you were in the process the problem was. Mar 7 at 1:39
1

After analyzing Andrew's post, reading documentation at archlinux wiki and man dnsmasq and testing myself, I got to the final solution which is working for both BIOS PXE and UEFI PXE. Content of the /etc/dnsmasq.d/pxe.conf file:

#to disable DNS server
port=0

#enable TFTP server and set its root path
enable-tftp
tftp-root=/free/pxe

# Enable DHCP logging
log-dhcp

#enable ProxyDHCP server. The address 192.168.1.0 corresponds to the subnet in which the ProxyDHCP server will act
dhcp-range=192.168.1.0,proxy,255.255.255.0

# bios
pxe-service=x86PC,"Network Boot BIOS",firmware/ipxe.pxe

# uefi
pxe-service=X86-64_EFI,"Network Boot UEFI x86_64",firmware/ipxe.efi

The key in this case was to use pxe-service entries instead of dhcp-match and dhcp-boot entries. Those are surely adequate to other cases, which may differ on the operating system or other things. I don't know, but just know that for this case, pxe-service entries worked fine.

In case someone needs to know this, the X86PC value and X86-64_EFI are the client system type, or CSA as mentioned in this man article: man dnsmasq.

Also, in this case, I didn't add the TFTP server address to the end of the pxe-service entry, because the TFTP server is the same host as the ProxyDHCP server, and obviously has the same address. But if it was a different one, you have to add the IP address of TFTP server at the end of the pxe-service statement, as described in the man article.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .