PXE Network Boot with MicroTik Router and FreeNAS TFTP

Having done a fair amount of computer building and troubleshooting, I find it is helpful to have bootable media with common tools like Memtest. Even more convenient than finding that boot disk and retrieving it, we can boot off the network. The below walks through how to setup network boot with Memtest as an example, though once you have TFTP running you can add more to it (installers, etc).

I am using PXELINUX from the SysLinux project. There are download links on that site, and this is based on version 6.02.

We can start by building out the tftproot file system on the FreeNAS host (/mnt/storage is the root of my volume). The files below are all found within the Syslinux download.

$ ls -la /mnt/storage/tftproot/
-rw-r--r--  1 root  nobody   24040 May 27 17:26 chain.c32
-rw-r--r--  1 root  nobody  122044 May 27 17:26 ldlinux.c32
-rw-r--r--  1 root  nobody  186444 May 27 18:39 libcom32.c32
-rw-r--r--  1 root  nobody   24156 May 27 18:44 libutil.c32
-rw-r--r--  1 root  nobody    1252 May 27 18:38 localboot.c32
-rw-r--r--  1 root  nobody   10700 May 27 17:26 mboot.c32
-rw-r--r--  1 root  nobody   26568 May 27 17:26 menu.c32
-rw-r--r--  1 root  nobody   46545 Oct 13  2013 pxelinux.0
drwxr-xr-x  3 root  nobody       4 May 28 13:56 pxelinux.cfg
-rw-r--r--  1 root  nobody   27076 May 27 17:26 vesamenu.c32

Within the pxelinux.cfg directory, we have the default configuration file, and files/directories to serve over TFTP.

$ ls -la /mnt/storage/tftproot/pxelinux.cfg/
-rw-r--r--  1 root  nobody  107 May 28 15:33 default
drwxr-xr-x  2 root  nobody    3 May 27 12:52 memtest

$ ls -la /mnt/storage/tftproot/pxelinux.cfg/memtest/
-rw-r--r--  1 root  nobody  150024 Aug 23  2013 memtest

The default configuration file is rather basic:

DEFAULT menu.c32
TIMEOUT 300
ONTIMEOUT localboot.c32

LABEL Memtest
  KERNEL pxelinux.cfg/memtest/memtest

The memtest file came from their download page (be sure to grab the pre-compiled bootable binary). I did rename the .bin file to be simply memtest (based on reading http://wiki.seanmadden.net/networking/pxeboot/memtest_over_pxeboot).

The last bit of FreeNAS work is to configure TFTP within Services (directory=/mnt/storage/tftproot, allow new files=unchecked, port=69, username=nobody, umask=022, extra options=). You can then check the box for Start on boot in Services and click Start Now to start TFTP.

Now, the last thing to setup is DHCP on the MicroTik router for PXE. It did take a bit to get this working, because the MicroTik router has named configurations for Next Server and Boot File Name in its DHCP Network configuration, as well as Options (where one can specify things like code 66 for boot server and code 67 for boot file). I originally setup Options, and then added those (via DHCP Options) to the DHCP Network config, though that did not work. What did finally work was to instead specify the Next Server (192.168.88.217) and Boot File Name (pxelinux.0) on the DHCP Network configuration.