# Jails for services



## gpatrick (Jul 28, 2009)

There are some services which I prefer to run with FreeBSD because of the number of utilities available, while some services will run on Solaris.  

I'm not sure if anyone knows about Sun's Crossbow project which allows virtual networking inside a computer, thus making the network is the computer.  Using Crossbow I can create virtual NIC's, routers, and switches, without having to have additional hardware.  Solaris also has zones which are kind of like FreeBSD's jails.

I want to use FreeBSD in VirtualBox on a Solaris 10 host.  However, because of memory usage I can't run a number of VirtualBoxes each with their own FreeBSD guest OS, which means I want to run one FreeBSD guest in VirtualBox and on that FreeBSD guest I want to run a few jails.  

Each jail will have it's own IP address and have its own virtual NIC.  The virtual interface should be seen by FreeBSD as a real physical interface.  Each of the virtual interfaces used by the FreeBSD jail will go to a virtual switch.  

Would this work with FreeBSD, otherwise I will go with Solaris zones (which I may do with bind anyway)?

Example:

FreeBSD host in VirtualBox (which sees all 4 virtual nic's)
FreeBSD host doesn't have any NIC configured, only jails.

```
/----------------------------------------------------------------\
| FreeBSD jail -- squid                 | virtual nic 10.0.2.130 |
|--------------------------------------------------------------- |
| FreeBSD jail -- ns1                   | virtual nic 10.0.2.131 |
|----------------------------------------------------------------|
| FreeBSD jail -- ns2                   | virtual nic 10.0.2.132 |
|----------------------------------------------------------------|
| FreeBSD jail -- mail                  | virtual nic 10.0.2.135 |
\----------------------------------------------------------------/
```


----------



## SirDice (Jul 28, 2009)

I have no VB experience but if the FBSD guest recognises the virtual interfaces there shouldn't be any problems.


----------



## vivek (Jul 28, 2009)

FreeBSD jails do not use concept of virtual interface. You can simply assign an IP and it will be allocated inside jails. You can no ip, IPv4/Ipv6 or multiple IP with FreeBSD 7.2. FreeBSD 8.0 current will come with more features and a new VM stack.


----------



## gpatrick (Jul 28, 2009)

If no virtual interface is used then how would it communicate with a firewall and route packets?


----------



## aragon (Jul 28, 2009)

Jails have no control over the firewall and the routing table.  Not yet at least.  Keep an eye on the vimage project.


----------



## gpatrick (Jul 29, 2009)

Are you aware of a release date for vimage?  

If they can indeed release it for production then I would certainly look into replacing my OpenSolaris with FreeBSD.  But until vimage is released for production use I'll have to stay with OpenSolaris because of its network virtualization features.


----------



## aragon (Jul 29, 2009)

I haven't seen a release date attached to vimage.  I do know a lot of the scaffolding is written and in 8.0.  In fact it is already possible to create multiple routing tables and attach jails to their own routing tables (see setfib(1)).


----------



## gpatrick (Jul 29, 2009)

Currently I'm running a FreeBSD guest in VirtualBox on an OpenSolaris host for my firewall, but if vimage is put into production I would run jails on FreeBSD.  This would help immensely with performance and memory usage.  I need to run 6-7 FreeBSD guests in VirtualBox and that consumes memory which I could get by with less using FreeBSD jails.


----------



## dren (Jul 1, 2010)

I know this is old, but I think pf might do some of what you're wanting to accomplish.


----------

