NEmu

Network Emulator for Mobile Universes

Tutorial - Setup a pfSense (FreeBSD) VFs

In order to build a virtual network with several pfSense (FreeBSD) virtual nodes, you may be interested in creating a customized root virtual file system what will be cloned after.

Configuration

First of all, you have to get an ISO image of a pfSense version. In this tutorial, we choose to use the version 2.1 but you can choose another one of course. Then, the NEmu script for your setup is this one:

InitNemu()

VHost('freebsd', 
 hds=[EmptyFs('pfsense.img', size='2G', type='raw', format='ext3')], 
 nics=[VNic()], cdrom='/tmp/pfsense-2.1-REALEASE.iso', display="sdl", vga="std",
 enable_kvm=None, localtime=None, k='fr', m=1024, cpu='core2duo')

VSlirp('slirp', net='192.168.0.0/24')

Link('freebsd', 'slirp')

StartNemu()

WaitNemu('freebsd')

StopNemu()

ExportFs('pfsense.img')

DelNemu()

The first line is the initialization of the NEmu session.

The VHost line is the configuration of our virtual machine, called freebsd, in which we are going to perform our pfSense installation. This virtual machine contains an empty virtual raw hard drive, called pfsense.img, of 2GB formatted in EXT 3. Our virtual node contains a single virtual network interface card, with a French keyboard, 1GB of RAM and an Intel Core 2 Duo processor. We choose to activate the KVM hardware acceleration in order to improve the performances of our virtual machine. The SDL library is used to display the window of the virtual machine. The localtime option enables a synchronization between the real and the virtual clock.

Then, we setup a VSlirp in order to enable an Internet connection on the sub-net 192.168.0.0/24.

Finally, we link the virtual node to the slirp.

That's all for the configuration !

The next lines are for:

At the end of the process, the new fresh installed virtual hard drive with our pfSense will be located in the current directory.

And action !

First of all, we download the version 2.1 of pfSense:

$ wget http://pfsense.mirrors.ovh.net/.../pfSense-LiveCD-2.1.iso.gz

Then, we start NEmu:

$ nemu --file script.py

Now you can install your pfSense as a normal real machine setup. When you will turn off the virtual machine, its virtual hard drive will be copied in your current directory. Then, the session will be deleted.