Enable TFTP boot from the router

  1. Enabling the TFTP service of dnsmasq

    Configuring dnsmasq on OpenWRT has a few peculiarities. First, enable the dnsmasq internal TFTP server by editing /etc/config/dhcp:

      config dnsmasq
      option domainneeded     1
      option boguspriv        1
      option filterwin2k      '0'  #enable for dial on demand
      option localise_queries 1
      option local    '/lan/'
      option domain   'lan'
      option expandhosts      1
      option nonegcache       0
      option authoritative    1
      option readethers       1
      option leasefile        '/tmp/dhcp.leases'
      option resolvfile       '/tmp/resolv.conf.auto'
      #list server            '/mycompany.local/1.2.3.4'
      #option nonwildcard     1
      #list interface         br-lan
      #list notinterface      lo
      option 'enable_tftp' '1' 1
      option 'tftp_root' '/tftpboot' 1
      2
      <snip>
    	  

    1

    add these lines

    2

    Do not set dhcp_boot here. It needs to be set dependent on which client is asking: the NIC or the gPXE bootstrap. We cannot do that here, it must be done in dnsmasq.conf. If we do set it here, this setting will override the one made in dnsmasq.conf!

  2. Having dnsmasq send the rigth boot files

    When the machine boots and the PXE stack asks the DHCP server for a file to boot, it should be ordered to fetch undionly.kpxe. But when that file has been loaded into memory and it in turn asks the DHCP server which file to use for its configuration, it should be orderen to fetch script output from the HTTP server. We edit edit /etc/dnsmasq.conf (see theKelleys.org example) to accomplish that:

      <snip>
      dhcp-match=gpxe,175
      dhcp-boot=net:#gpxe,undionly.kpxe
      dhcp-boot=http://1.2.3.4/boot/boot.php
    	  

  3. Avoiding rearranging of information in DHCP replies

    Dnsmasq rearranges DHCP packages by default, but that is incompatible with gPXE. Running dnsmasq with then dhcp-no-override option cancels that behaviour, so we edit /etc/init.d/dnsmasq (see etherboot docs) and add the option:

      <snip>
      include /lib/network
      scan_interfaces
      config_load dhcp
    
      args="--dhcp-no-override"
      config_foreach dnsmasq dnsmasq
      config_foreach dhcp_host_add host
      config_foreach dhcp_boot_add boot
      config_foreach dhcp_mac_add mac
      <snip>
    	  

    ... and reboot