You are on page 1of 36

INSTALL PFSENSE+LUSCA-CACHE IN VIRTUALBOX AND

USE A SEPARATE VIRTUAL DRIVE AS ITS CACHE

pfSense is an another type of protection for our vulnerable network. A modular router that can be
customize base on your network needs. It has the ability to act as a router or a firewall, or even
your cache server which means all your youtube, facebook, and other sites has being temporarily
saved in a storage and soon if someone in your LAN access the same website it can instantly
retrive or view without the irony of web page reload or to buffer the video again. That's why
your internet might become faster
than your previous setup when you use pfSense. But dont worry with the right settings that suites
your needs, your cache storage will not be full. Cache settings can be customized to overwrite
cache objects if the disk are full, so that your browsing, and live streaming experience will not be
affected. And the best of all, it is free because it is an opensource software.
Now this tutorial describes how to install PFSense and Lusca+Cache in Virtual Box. I prefer to
use VirtualBox because I often use it for Virtualization.
First, you need to setup a pfSense Virtual Environment. Let say you have an existing network
setup and you don't want to disrupt the current network connectivity. It's like you have this kind
of setup.

Basic network setup, w/o pfSense

Then you need to do something like this,

In this case, pfSense is only an option. Use or not to use pfSense scenario.

Or, you totally remove your traditional router and replaced by pfSense(Hardware Mode)
But this time, we will only setup and configure the second one. The "optional" pfSense
infrastructure. Since we have the existing network setup that we do not want to disrupt the
existing network. And at the same time we just want to test it first before bringt it to production
environment.
First, download pfSense-LiveCD-2.0.3-RELEASE-i386...iso
Note: latest pfSense build has a bug (I already test it), it happens after you install lusca-cache
package the proxy server gui doesn't show. Thats why I stick to the version 2.0.3.

Now, setup a pfSense Virtual Machine in your VirtualBox, Go to Settings, then Storage
You may notice that I have two virtual disk, which I will use as Primary Drive(8gb) for pfSense
and Secondary Drive(40gb) for Lusca-cache storage.

Then setup the network for WAN and LAN interface


Go to Network tab, then
Adapter 1 for your WAN Interface
Set it Bridge Adapter where it Attached to
Select your WAN Interface where the internet connection from your host machine is
connected
Click the small arrow to collapse the Advance section
Set Promiscuous Mode to Deny to disallow packets in and out your host and virtual
machine
Tick the Cable connected check box, it should be in check state
Then click OK

Adapter 2 for your LAN Interface


Set it Internal Network where it Attached to
Select your LAN Interface where the internet connection from your host machine is
connected
Click the small arrow to collapse the Advance section
Set Promiscuous Mode to Allow VMs to allow packets in and out your virtual
machines
Tick the Cable connected check box, it should be in check state
Then click OK

Then power on your pfSense virtual machine

While booting, pfSense will show an installation option. Press I on your keyboard

Then the Installation Wizard appears, Select Accept these Settings

Select Install pfSense

Select storage to install pfSense. Here we need to select ad0 for pfSense Installation

Select Format this Disk

Select Use this Geometry

Format ad0 disk

Then, Partition disk

Select Accept and Create

Select Yes, partition ad0

Press enter to select OK, to continue

Select Accept and Install Bootblocks

Select OK

Select 1st partition to install pfSense

Select OK. WARNING! All data in primary partition will be deleted. Be sure you don't have
important files in it. And you know what you are doing

Select OK to proceed

Now in partitioning we don't need to modify it just select Accept and Create

Wait until the installation has been completed

Select Symmetric multiprocessing... Then press enter

Now we need to press Esc on your keyboard many times until you are back on the main intall
page.

When you are back on the main install page, select Install pfSense then press enter

Now for lusca-cache we need select ad1 (40gb)

Select Format this Disk to format ad1 (40gb) storage for lusca-cache

Select Use this Geometry

Select Format ad1 to proceed formatting, then it will show a loading screen very quickly

Select Partition Disk

Select Accept and Create by using down arrow

Select Yes, partition ad1

The wizard will prompt you that the disk was successfully partitioned, then press enter to
continue

Then it will want you to install bootblocks. You should just skip this step

Then select a Partition to format

The wizard will prompt you to that it will erase all data. Hit OK to continue

Then it will prompt you again that it was formatted

Then you need to delete the default swap partition

And change mount point to /var/squid/cache or /cache, its up to you where do you want to put
the cache storage but be sure you are aware of that

Select Accept and Create to format the partition and begin the installation of pfSense

Because we deleted the swap partition and do not install pfSense, the installation will be
confused and comes back with an error. But don't worry this is normal, you just need to
proceed. Select OK to continue

Then press, Cancel

Press enter again to continue

At this point you need to keep on pressing Esc button or Select Return to Select task until you
are back to the main install page.

Select 'reboot' and once its rebooted, then remove the CD

After the virtual machine restarted, wait until pfSense has been done loading

Skip vlan setup

Assign WAN interface

Assign LAN interface, then select Y to enable DHCP on LAN, then if you asked for OPT1 then
just press enter to continue

Then you should be asked if you want to proceed, just type y and press enter

At this point you are now in the main menu of pfSense which you have privileges to setup other
features like enabling ssh (14). But for this instance, I need to change the LAN IP address of
pfSense to 192.168.5.1. So I we need to type 2 for Set interface(s) IP address

Type number 2 to configure LAN interface

Type the LAN IP address you wish to specify, then press enter

Then type its subnet bit count, which is 24 = 255.255.255.0

Then enable DHCP server on LAN

Type the start address of client address range. Start = 192.168.5.100

Then type the end address of the client address range. End = 192.168.5.150

Type y to revert to HTTP as the webConfigurator

Now since you have setup the NICs and IP addresses now,

Now we will going to configure the pfSense using the web gui, Go to your Virtual Box Manager,
select the appropriate client vm you will use to test your internet connection. In this instance I
will be using Windows XP Service pack 3 for testing purposes. Then press Settings button

Then go to Network tab, Adapter 1, then select Attached to Internal Network. We need to this for
us to avoid affecting the external network because we need to enable the pfSense DHCP on the
LAN side to test if its working.

Then power on your Windows VM, then you should see from your Local Area Connection
Status window, that Windows has been given an IP address of 192.168.5.100 by the pfSense
LAN DHCP.
To do this, your Windows network connection should be set as obtain ip address from dhcp
server.

Now we may configure pfSense, fire up your google chrome or any web browser you like, and
type the default gateway(router) ip address which is the pfSense 192.168.5.1
Type admin as Username
and pfsense as Password
Then press enter to login

Then you should be redirected to the pfSense configuration wizard, click Next

Next, customized your Hostname and Domain name

Set your timezone. Then, click Next

Then, Browse down and click Next

Click Next to proceed

Set your desired admin password and click Next

Then wait for it finishes loading configuration

Then after it loads, click the here link

Then you should redirected inside the pfSense web gui. where the Dashboard will be the default
Main Page. Notice your WAN interface already acquired its IP address from your existing router.

Then test your internet connection.

Then lets mount the second disk. Go to your fpSense gui, press 8 on your keyboard to enter the
shell where you can type in commands. We need to mount the second disk the ad1 to be use for
lusca-cache storage.

Then, type newfs /dev/ad1s1a or


Replace the '/dev/ad1s1a' with the proper name of your hard drive and the slice on your hard
drive

This should show on your screen

Then edit fstab by typing vi /etc/fstab or ee /etc/fstab and add the following lines:
/dev/ad1s1a
/cache
ufs
rw
1 1

Press Esc to leave editor, and press enter

And press enter again to save changes

Then changes has been save successfully, now type mount -a to mount the cache drive

An error will show saying No such file or directory, so we just need to mkdir /cache to create
new folder/directory to the root(/) directory

Then it will show nothing but it already created the /cache directory. Then type mount -a again
and it will show nothing again

But if you type df -h you may see it is now mounted. It should look like this

Now in your Windows client go to your pfSense web gui and go to Diagnostics, Command
Prompt and copy paste this code:
fetch http://pfsense-cacheboy.googlecode.com/svn/trunk/script/package.sh && chmod +x
package.sh && ./package.sh
Then, click Execute

You should see this message, informing you that it's done

Then go to System, Package Manager, and Click Available Packages


Press Ctr+F on your keyboard to search for lusca-cache
Then click the + button to add/install lusca-cache
Click OK to continue if you've been asked by Chrome to install it

When the installation successfully completed, it should look like this

Now go to Services, Proxy Server.


On the general tab, Tick the Transparent proxy check box
and Click save button below

Here on this tab, Select Hard disk cache system to coss + aufs.
Then modify Coss Hard disk cache size to 100 and for Hard disk cache size to 38000. It
depends on your configuration of virtual machine specs like HDD space, since we have only
40gb cache storage we need to allocate 38000 in terms of mega bytes.
For COSS Hard disk cache location it would be /cache/coss. (if lusca doesn't create coss
directory automatically, just mkdir coss inside /cache)
And for Hard disk cache location it would be /cache
Maximum object size, higher than you declared value would not be cached but lower than
declared will be cached. Its up to you how many you want to allocate. But for this instance we
will just allocate 1gb which is 1024mb for the Maximum object size
Then click save

Now, since I prefer to choose to increase the download speed I decide to set 6024 for Overall
bandwith throttling.
Click Save to save the settings

Then Go to Status at the Main Toolbar then click on Services to start the service

Then, Congratulation.. You have successfully installed and run the PFSense with Lusca-Cache.
Now what?
Go ahead and test it, if theres no changes in your internet performance you may tweak the
settings and play with it freely until you achieve your satisfaction. But remember, you must think
that there are many consideration that causes your internet connection to slow down, and I
cannot list here one by one for this post is only about the subject.

You might also like