Chapter 2. m0n0wall Hacker's Guide

Table of Contents

2.1. Setting Up a Host Development Environment
2.2. PXE Booting
2.2.1. DHCP server
2.2.2. tftp server
2.3. Setting up m0n0wall on the host
2.3.1. The Kernel
2.3.2. The Modules
2.3.3. The root filesystem
2.3.4. For the impatient
2.3.5. The loader and pxe config
2.3.6. GO
2.4. NFS
2.5. Unpacking/Editing/Packing the Source
2.6. Writing a CF Image
2.7. Submitting Changes

Note

This chapter is somewhat dated, though much of it remains applicable. The most recent m0n0wall development documentation is the image building guide chapter.

This chapter is based on Rudi van Drunen's m0n0wall Hackers Guide, used with permission.

m0n0wall is open-source software: if it doesn't quite do what you want, you can change it yourself, or have someone else of your choice change it for you. This chapter describes how to do that.

Note that the instructions in this guide are meant as guidelines, your mileage may vary. Also, hacking low level things may seriously mess up your development system, target system, or other systems, please take care.

2.1. Setting Up a Host Development Environment

In order to get a development environment for m0n0wall you will need the target hardware and a host system. typically this will be a soekris NET45xx board and a FreeBSD 4.8-RELEASE (Intel x86) system.

You will be booting the m0n0wall from the host system, so no CF card is needed. The boot image is located on the host and changes in the kernel or root filesystem are easily made by hacking them on the host machine. Once ready, the root filesystem or kernel image can be created and put in the /tftpboot directory (as described below) and the target (soekris) can be booted from this image over the network.

Now you can test the image, make your desired changes on the host, rebuild the root and / or kernel and test again. If you are confident with the changes you made, you will be able to build an image for the CF card. This image can then be used to "firmware upgrade" the m0n0wall (when running from CF) as usual though the WEB user interface.

As you will be network (PXE (Preboot Execution Environment)) booting the soekris from your host system and be able to generate image files to load you will have to set up some environment on the host to support just that. First of all, be sure that you have a kernel running that contains the vnode driver. You will need this feature to be able to turn a file into a device. Add the following to your kernel config and rebuild the kernel:

pseudo-device   vn              # Vnode driver (turns a file into a device)

Instructions for rebuilding the kernel can be found in chapter 9 of the FreeBSD handbook.