DNSmasq SCCM Legacy BIOS and UEFI PXE Coexistence

I had a lot of trouble finding information on how to set this up. Finally got it working today. Hope this helps the community.

Running openwrt on a Ubiquiti EdgeRouter X and wanted to avoid setting up an additional dhcp server in my lab seeing as dnsmasq is already providing dns and dhcp.

add the following line to /etc/dnsmasq.conf

pxe-prompt="Booting PXE Client", 0

dhcp-vendorclass=bios,PXEClient:Arch:00000
dhcp-vendorclass=efi32,PXEClient:Arch:00002
dhcp-vendorclass=efi32-1,PXEClient:Arch:00006
dhcp-vendorclass=efi64,PXEClient:Arch:00007
dhcp-vendorclass=efi64-1,PXEClient:Arch:00008
dhcp-vendorclass=efi64-2,PXEClient:Arch:00009

dhcp-boot=net:bios,smsboot\x64\wdsnbp.com,,20.0.0.254

dhcp-boot=net:efi32,smsboot\x86\wdsmgfw.efi,,20.0.0.254
dhcp-boot=net:efi32-1,smsboot\x86\wdsmgfw.efi,4,20.0.0.254

dhcp-boot=net:efi64,smsboot\x64\wdsmgfw.efi,,20.0.0.254
dhcp-boot=net:efi64-1,smsboot\x64\wdsnbp.com,,20.0.0.254
dhcp-boot=net:efi64-2,smsboot\x64\wdsmgfw.efi,,20.0.0.254

note: for some reason the dhcp settings have no effect and be ignored without the "pxe-prompt=" line

Make sure u have a deployment available with the proper boot image to fix: PXE boot hangs on "Contacting server"

If u are trying to boot a 64 bit only uefi device which in my case was a gen 2 hyper v virtual machine, make sure the task sequence u are making available is using a 64 boot image or pxe boot will fail with: Windows Deployment Services encountered an error: Error Code: 0x102

Bonus:

How to Forward Active Directory Queries through DNSMASQ:

add the following line to /etc/dnsmasq.conf

server=20.0.0.253
srv-host=_ldap._tcp.dc_msdcs.dc.sandbox.local, 20.0.0.253
srv-host=ldap._tcp.gc._msdcs.dc.sandbox.local, 20.0.0.253
srv-host=_kerberos._tcp.dc._msdcs.dc.sandbox.local, 20.0.0.253
srv-host=ldap._tcp.pdc._msdcs.dc.sandbox.local, 20.0.0.253

setup dns forwarding:

gui:

network -> dhcp and dns -> general settings -> dns forwardings: /sandbox.local/20.0.0.253

shell:

uci add_list dhcp.@dnsmasq[0].server="/sandbox.local/20.0.0.253"
uci commit dhcp
/etc/init.d/dnsmasq restart

note: set the primary dns on your domain controller to use your routers dns in my case: 20.0.0.1


My Network:

Vlan 0 (Lan): 10.0.0.0/24, access to lab and iot networks
Vlan 20 (Lab): 20.0.0.0/24, access to iot network
Vlan 30 (IOT): 30.0.0.0/24, access to internet only

root@openwrt:~# cat /etc/openwrt_release
DISTRIB_ID='OpenWrt'
DISTRIB_RELEASE='19.07.4'
DISTRIB_REVISION='r11208-ce6496d796'
DISTRIB_TARGET='ramips/mt7621'
DISTRIB_ARCH='mipsel_24kc'
DISTRIB_DESCRIPTION='OpenWrt 19.07.4 r11208-ce6496d796'
DISTRIB_TAINTS=''