Enable TFTP boot from the router

  1. 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/'
      #option nonwildcard     1
      #list interface         br-lan
      #list notinterface      lo
      option 'enable_tftp' '1' 1
      option 'tftp_root' '/tftpboot' 1


    add these lines


    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. 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:


  3. 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:

      include /lib/network
      config_load dhcp
      config_foreach dnsmasq dnsmasq
      config_foreach dhcp_host_add host
      config_foreach dhcp_boot_add boot
      config_foreach dhcp_mac_add mac

    ... and reboot