# Enable TFTP booting The TUF AX4200 runs dnsmasq as its DHCP server. dnsmasq contains a built-in TFTP server and can hand out next-server/bootfile options, so the router itself can serve PXE/TFTP booting to LAN clients. Stock firmware gives no way to add dnsmasq options or open the TFTP firewall port, and neither survives a reboot. So the setup is: a startup script that patches the running configuration on every boot. The boot mechanism behind it (asusware.arm app mechanism) is described in [Install additional software](Network:AX4200:Install_additional_software). ## What is done on every boot The script `mnt/sda1/data/patch-and-restart-dnsmasq.sh` runs at boot (via the `S99patch-and-restart-dnsmasq` init script; see the [Install additional software](Network:AX4200:Install_additional_software) page for how that works) and does three things: 1. **Feed extra dnsmasq options from the USB stick:** it removes any existing `conf-dir=` line from `/etc/dnsmasq.conf` and appends ``` conf-dir=/tmp/mnt/sda1/data/dnsmasq.d ``` so dnsmasq additionally reads the drop-in config in `mnt/sda1/data/dnsmasq.d/`. This is where the TFTP/PXE options go (see below). Because `/etc` is on a tmpfs-like overlay, patching it from a script is the only way to make it happen at every boot. 2. **Open the TFTP firewall port on the LAN bridge** (`br0`): ``` iptables -A INPUT -i br0 -p udp --dport 69 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -p udp --sport 69 -m state --state ESTABLISHED -j ACCEPT ``` Without this, the stock firewall silently drops the TFTP requests from LAN clients. 3. **Restart dnsmasq** so the patched config takes effect: `killall -TERM dnsmasq`, wait 10 seconds, then start it again with `dnsmasq --log-async`. (The firmware's watchdog respawns it; the script starts it explicitly to be sure.) The script logs each step with `logger -t S99-patch-and-restart-dnsmasq` — check **Administration → System Log** after a reboot to confirm it ran. ## dnsmasq drop-in: /mnt/sda1/data/dnsmasq.d/dnsmasq.conf The drop-in read via `conf-dir=` enables dnsmasq's built-in TFTP server and hands out boot files via DHCP: ``` # Enable dnsmasq's built-in TFTP server enable-tftp # Root directory served via TFTP tftp-root=/tmp/mnt/sda1/data/tftpboot # BIOS boot file dhcp-boot=pxelinux.0 # EFI boot files (override for arch 7/9 clients) dhcp-match=set:efi-x86_64,option:client-arch,7 dhcp-match=set:efi-x86_64_9,option:client-arch,9 dhcp-boot=tag:efi-x86_64,grubnetx64.efi.signed dhcp-boot=tag:efi-x86_64_9,grubnetx64.efi.signed # Use only port 69 for both directions of the TFTP transfer tftp-single-port ``` - Boot images (pxelinux, grubnetx64.efi.signed, kernels, initrds) live under `mnt/sda1/data/tftpboot/`. - `tftp-single-port` keeps both directions of the transfer on UDP port 69 — that is what makes the simple two-rule firewall opening above sufficient (a compliant multi-port TFTP server would need a dynamic port range opened as well). The tradeoff is documented in the file: not strictly RFC-compliant, but rescues firewall/broken-client situations. - The same drop-in also carries the non-TFTP DNS customisations (local zones, `address=` overrides, `addn-hosts=` files on the USB stick) — it is the general dnsmasq config for this router, not just for TFTP. ## Relevant files on the router | Router path | Purpose | |---|---| | `/mnt/sda1/data/patch-and-restart-dnsmasq.sh` | The real script: patch dnsmasq config, open firewall, restart dnsmasq | | `/mnt/sda1/data/dnsmasq.d/dnsmasq.conf` | dnsmasq drop-in: TFTP/PXE options and general DNS customisations | | `/mnt/sda1/asusware.arm/etc/init.d/S99patch-and-restart-dnsmasq` | Symlink to the script above, so the firmware runs it at boot | | `/mnt/sda1/asusware.arm/lib/ipkg/info/patch-and-restart-dnsmasq.control` | `Enabled: yes` — without it the start script is skipped | | `/usr/sbin/app_init_run.sh` | Firmware script that runs the `/opt/etc/init.d/S*` scripts | | `/usr/sbin/app_get_field.sh` | Firmware script that reads the `Enabled:` field from the `.control` file | ## Notes - Keep the editable content on the USB stick (`data/`), not on `/opt`: the firmware copies init scripts to `/opt/.1` before running them, so direct edits inside the app directory have no effect until the next remount. - A `killall dnsmasq` briefly interrupts DHCP/DNS for the LAN; do this deliberately, not during heavy use. - To change what the clients boot, only the drop-ins in `data/dnsmasq.d/` need editing, then restart dnsmasq (or reboot).