The PXE filename hack

There are situations where no decent DHCP server can/shall/may be used. This may be especially true in “hostile” environments of NT-servers. In those environments, the ISC-configuration

  if substring (option vendor-class-identifier, 0, 9) = "Etherboot"  {
    filename "/kernel.nbi";
  } else {
    filename "/etherboot.zpxe";
  }

can not be used to distinguish between the first stage part (which would be a PXE ROM, for example) and the second stage part (which would be Etherboot, running as PXE 2nd-stage-loader) downloading their respective file.

Of course, this patch can be used too if you are too lazy (..etc..) to configure your dhcp-daemon properly. It is NOT RESTRICTED TO WIN NT users - John Newbigin asked for it, and it can clearly be used with *any* dhcp daemon that etherboot supports at all.

Now, the trick is that Etherboot as 2nd stage program examines the “filename” it receives from the DHCP server, and in case that ends in .zpxe, those 5 characters are stripped off. Thus, you could have etherboot in the file rtl8139.zpxe and the kernel to be loaded by Etherboot in the file rtl8139 (which might also be a softlink to the real file - to make things clearer when returning to that setup months later).

An alternative solution, proposed by Paolo Salvan, is to use Etherboot with the “alternate port” patch (thus Etherboot will run DHCP on port 1067/1068) - but that requires a second DHCP server.

 --- main.c      Tue Oct 14 10:21:56 2003
 +++ main-changed.c      Tue Oct 14 10:19:28 2003
  -393,6 +393,12 
  #endif
         ip.s_addr = arptable[ARP_SERVER].ipaddr.s_addr;
         name = fname;
 +#ifdef ZPXE_SUFFIX_STRIP
 +       while ( *name != 0 ) {
 +               if ( memcmp(name, ".zpxe", 6 ) == 0 ) {*name=0;} else {++name;}
 +       }
 +       name = fname;
 +#endif
         url_port = -1;
         len = 0;
         while(fname[len] && fname[len] != ':') {

This patch has been part of only certain Etherboot versions (look out for the ZPXE_SUFFIX_STRIP config file option) - it is considered to be bad style. People would better get decent DHCP servers. However as it seems to help several people, it should at least be documented.

Another possible solution has been proposed by Eric W. Biederman:

 A solution that works with the current etherboot is to use a filename like:

 tftp:///etherboot.zpxe

 The in your /tftpboot/ directory have a subdirectory named ``tftp:''

 PXE will load files from the tftp: subdirectory because it does not
 interpret the filename and etherboot will load the file with the same
 name from just /tftpboot  because it recognizes the filename as a url. 

This is not future-proof as filename management, especially when supporting more than the standard TFTP protocol, probably will break this.