RouterOS as a PXE (Net Boot) server

As more and more people switch to netbooks; the ability to provision Operating Systems and boot iso’s over the network becomes highly useful. It has become quite common to see CD/DVD ROM drives removed altogether in mobile and even some desktop machines.

Installing and booting machines using RouterOS as the bootp/tftp server is quite a simple process if you are familiar with PXE booting, but for those of you who are not, allow me to provide a basic guide along with a preset package for you to try this out yourself.

resource-rb1200

     

For now I’ve put together a package that includes a basic PXE boot menu and an Ubuntu netinstall image; all in under 22MB which means it can fit on most any Routerboard model.

To try this out, do the following:

  1. Download the mt-pxeboot.rar (link fixed!)
  2. Unzip the folder and copy the ‘tftp’ folder directly to your routerboard
  3. Open mt-config.txt, adjust the variables at the top to suit your local network configuration
  4. Paste the modified config into terminal on your router
  5. Connect up a machine that has PXE boot support and start it up, selecting option 2 in the pxe menu when prompted

Shown here is the setup script included in the rar:

#First copy the entire tftp directory to your MikroTik root directory
#Then edit these variables to suit your local network

:global network "192.168.1.0/24"
:global router "192.168.1.1"

########################################
#      Do not edit below this line     #
########################################

#Adding TFTP allowances for the provided range

/ip tftp
add ip-addresses="$network" real-filename=tftp/pxelinux.0 req-filename=pxelinux.0
add ip-addresses="$network" real-filename=tftp/bootmsg.txt req-filename=bootmsg.txt
add ip-addresses="$network" real-filename=tftp/memdisk req-filename=memdisk
add ip-addresses="$network" real-filename=tftp/pxelinux.cfg/default req-filename=pxelinux.cfg/default
add ip-addresses="$network" real-filename=tftp/mini.iso req-filename=mini.iso

#We assume there is an existing DHCP server setup, so just modifying the network config

/ip dhcp-server network
set [find address="$network"] boot-file-name=pxelinux.0 next-server="$router"

Adding the next-server  and boot-file options tell your PXE device where to look for files, and the specific boot file to start loading.

Once it has this it can download the files and depending on the configuration, run any number of liveboot or unattended installations.With more complex procedure you can even run up thin clients attached to network storage and so on. In the example you are presented with a menu, the default option allows the machine to continue to boot from disc after 20 seconds while the 2nd option starts the Ubuntu Netinstall image.

Alternatively, TFTP combined with DHCP options can also be used in the provisioning of many networked devices, the most common of which are VoIP phones.

Files:

  • mt-pxeboot.rar (21.2MB) – The RouterOS PXE boot package
  • tftpd – A standalone windows tftp server and client/dhcp/dns server for testing
Advertisement

15 thoughts on “RouterOS as a PXE (Net Boot) server

  1. Thank you for reading! I’ve been rather disabled for the past few weeks so it took a while but was an interesting and completely new subject for me. I’m sure I could write 3 or 4 posts on how it all works but hopefully this will be of benefit to a few people and encourage some to learn more about it themselves! 🙂

  2. Andrew,
    I tried to get this going with Debian but ran into significant issues.

    The machines I’m trying to install on are AMD Opteron 256’s so I got the amd64 version of the netboot from Debian. Since there are a lot more files in this, on the tftp server allowed files I just left the file field blank. I put the files in the root of the MT file structure.This seemed to work just fine. I would get the install screen but when i would proceed further it would crash with seemingly random errors.

    http://ftp.nl.debian.org/debian/dists/squeeze/main/installer-amd64/current/images/

    Any ideas?

  3. Does anyone knows how to configure mktk to assign an IP through DHCP (done) and then tell the PC the boot server’s IP?

  4. Awesome! Thank you! That arm looks like it was a terrible break. Hopefully it healed up nicely.

  5. Could you please tell me how to configure DHCP server @ mikrotik if my PXE server is located in an other PC @ my network? What should I do to forward PXE requests into valid PXE server @ my network?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.