# This file is part of LTSP, https://ltsp.org
# Copyright 2019 the LTSP team, see AUTHORS
# SPDX-License-Identifier: GPL-3.0-or-later

# Configure dnsmasq for LTSP
# Documentation=man:ltsp-dnsmasq(8)

# For additional local dnsmasq configuration like DNS blacklisting, it's
# recommended to use separate /etc/dnsmasq.d/local.conf files,
# so that they're not lost if you ever (re)run `ltsp dnsmasq`.

# port=0 disables the DNS service of dnsmasq
port=0

# enable-tftp enables the TFTP service of dnsmasq
enable-tftp

# FHS 2.3+ recommends /srv for tftp (debian #477109, LP #84615)
tftp-root=/srv/tftp

# Log lots of extra information about DHCP transactions
#log-dhcp

# IP ranges to hand out, usually on the internal LTSP subnet of 2-NIC setups
dhcp-range=192.168.67.20,192.168.67.250,12h

# If another DHCP server is present on the network, a proxy range may be used
# instead. This makes dnsmasq provide boot information but not IP leases.
#dhcp-range=set:proxy,192.168.0.0,proxy,255.255.255.0

# Specify the DNS server. 0.0.0.0 means the machine running dnsmasq.
# DNS_SERVER in ltsp.conf is preferred as it reaches proxy DHCP clients.
dhcp-option=option:dns-server,8.8.8.8,8.8.8.8

# Set some tags to be able to separate client settings later on.
# "39" means "recent ipxe-ok with menu support": http://ipxe.org/howto/dhcpd
#dhcp-match=set:ipxe-ok,175,39

# Based on logic in https://gist.github.com/robinsmidsrod/4008017
# iPXE sends a 175 option, checking suboptions
dhcp-match=set:ipxe-http,175,19
dhcp-match=set:ipxe-https,175,20
dhcp-match=set:ipxe-menu,175,39
# pcbios specific
dhcp-match=set:ipxe-pxe,175,33
dhcp-match=set:ipxe-bzimage,175,24
dhcp-match=set:ipxe-iscsi,175,17
# efi specific
dhcp-match=set:ipxe-efi,175,36
# combination
# set ipxe-ok tag if we have correct combination
# http && menu && iscsi ((pxe && bzimage) || efi)
tag-if=set:ipxe-ok,tag:ipxe-http,tag:ipxe-menu,tag:ipxe-iscsi,tag:ipxe-pxe,tag:ipxe-bzimage
tag-if=set:ipxe-ok,tag:ipxe-http,tag:ipxe-menu,tag:ipxe-iscsi,tag:ipxe-efi


dhcp-match=set:X86PC,option:client-arch,0
dhcp-match=set:X86-64_EFI,option:client-arch,7
# Due to rfc4578 errata, sometimes BC_EFI=9 is misused instead of X86-64_EFI=7:
dhcp-match=set:X86-64_EFI,option:client-arch,9
dhcp-mac=set:rpi,b8:27:eb:*:*:*
dhcp-mac=set:rpi,dc:a6:32:*:*:*
dhcp-mac=set:rpi,e4:5f:01:*:*:*

# In proxy DHCP mode, the server ONLY sends its IP and the following filename.
# Service types: man dnsmasq or https://tools.ietf.org/html/rfc4578#section-2.1
# PXE services in non proxy subnets sometimes break UEFI netboot, so tag:proxy.
pxe-service=tag:proxy,tag:!ipxe-ok,X86PC,"undionly.kpxe",ltsp/undionly.kpxe
pxe-service=tag:proxy,tag:!ipxe-ok,X86-64_EFI,"snponly.efi",ltsp/snponly.efi
pxe-service=tag:proxy,tag:ipxe-ok,X86PC,"ltsp.ipxe",ltsp/ltsp.ipxe
pxe-service=tag:proxy,tag:ipxe-ok,X86-64_EFI,"ltsp.ipxe",ltsp/ltsp.ipxe
pxe-service=tag:rpi,X86PC,"Raspberry Pi Boot   ",unused

# Specify the boot filename for each tag, relative to tftp-root.
# If multiple lines with tags match, the last one is used.
# See: https://www.syslinux.org/wiki/index.php?title=PXELINUX#UEFI
dhcp-boot=tag:!ipxe-ok,tag:X86PC,ltsp/undionly.kpxe
dhcp-boot=tag:!ipxe-ok,tag:X86-64_EFI,ltsp/snponly.efi
dhcp-boot=tag:ipxe-ok,ltsp/ltsp.ipxe

# Proxy DHCP clients don't receive any DHCP options like root-path.
# So we set root-path in the kernel cmdline from ltsp.ipxe.
#dhcp-option=option:root-path,ipxe-menu-item
address=/mss.server/192.168.67.1
