Jail settings in rc.conf with VNET

Hello,

I realize there is a similar topic on the main page by a different user I was just not sure how similar it is to what I'm trying to do so please bare with me.

I compiled my kernel with vimage (network virtualization project for freebsd) and was able to start two jails with a bridge on the main host, so I was able to establish communication between the two jails (using ping) and each jail would have its separate network stack.

I have done all of this using commands, what I want to know is how I can incorporate these commands into rc.conf so that the virtualization of network stack starts automatically rather than me having to enter these commands manually on startup.

Here are the commands I use to create the jails, the vnets and the whole configuration

Create a pair of interfaces
[CMD=]root# ifconfig epair create[/CMD]

Create jails with virtual network stacks
[CMD=]root# jail -c vnet name=jail1 host.hostname=jail1 path=/ persist[/CMD]
[CMD=]root# jail -c vnet name=jail2 host.hostname=jail2 path=/ persist[/CMD]

Assign one of the created interfaces to the network stack of the first jail
[CMD=]root# ifconfig epair0b vnet 1[/CMD]

Give it an IP address
[CMD=]root# jexec 1 ifconfig epair0b 192.168.1.2[/CMD]

Give the other interface an IP address
[CMD=]root# ifconfig epair0a 192.168.1.1[/CMD]

Create another pair of virtual interfaces
[CMD=]root# ifconfig epair create[/CMD]

Assign one interface to the network stack of the second jail
[CMD=]root# ifconfig epair1b vnet 2[/CMD]

Give it an IP address
[CMD=]root# jexec 2 ifconfig epair1b 192.168.1.3[/CMD]

Create a bridge to link traffic between the two virtual network stacks of the jails
[CMD=]root# ifconfig bridge create[/CMD]
[CMD=]root# ifconfig bridge0 addm epair0a addm epair1a up[/CMD]
[CMD=]root# ifconfig epair0a -alias[/CMD]
[CMD=]root# ifconfig bridge0 192.168.1.1[/CMD]
[CMD=]root# ifconfig epair1a up[/CMD]


now I have a connection between the jails each on its separate network stack. The guide I was following suggested I added vnet in the jail_flags portion of the rc.conf, yet it failed to give an example. I'm relatively new to FreeBSD, and don't really know my way around rc.conf. Any help would be appreciated.
 
OK...


To follow up on the previous subject, I managed to get the jail working but I can't seem to set the VNET parameter correctly. It appears to be that I can't pass the -c vnet into the jail__flags section of rc.conf to get the virtual environment to start correct because of the way /etc/rc.d/jail creates jails, it uses what appears to be "an old way" of creating them so it doesn't really understand the -c vnet command.

anyone have any idea how to fix this or propose a patch?
 
You should be able to pass flags to your jails within rc.conf using the following..


Code:
jail_<jname>_flags="-c"
Look at /etc/defaults/rc.conf for all the other jail options.


To be clear, I've never used flags with vnet jails; keep in mind vnet is still a work in progress.


Hope this helps!


EDIT: I am sorry, I missed your reply post - looks like you figured out the jail_flags option; however I have
Code:
jail_nameofjail="vnet"
to start the vnet stack on my jail - is that the option your looking for?
 
Thank you for your response. I was able to solve the problem using the information on this guide. The solution was to apply a patch (available on said page) and include

Code:
jail_nameofjail_vnet_enable="YES"
 
Back
Top