iocage, vnet0, and bridge0

amlamarra

Explorer
Joined
Feb 24, 2017
Messages
51
This is what got networking to work for me. In the FreeNAS beta GUI, I created a new jail and checked the box for "Vnet". That's it.
 

dureal99d

Contributor
Joined
Aug 3, 2017
Messages
156
Ive actually found it better and easier to use the cli. in this case this is fail proof for me:
Code:
iocage create -n "yourjailname" -r 11.1-RELEASE ip4_addr="vnet0|192.XXX.X.X/XX" defaultrouter="192.XXX.X.X" vnet="on" allow_raw_sockets="1" boot="on"


this command has been a saver for me and hopefully it works for all
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977
Hello,

i had the same problem but after a few research i have added 2 tunable in the rc.conf :
Code:
Variable : cloned_interfaces ; Value : bridge0
Variable : ifconfig_bridge0 ; Value : addm igb0 up
Thanks @Celena your fix saved me a lot of time and headaches trying to figure out why none of my jails worked after a reboot.

Has anyone filed a bug report on this?
 

Slovak

Explorer
Joined
Sep 10, 2013
Messages
62
Hello,

i had the same problem but after a few research i have added 2 tunable in the rc.conf :
Code:
Variable : cloned_interfaces ; Value : bridge0
Variable : ifconfig_bridge0 ; Value : addm igb0 up

Thank you for posting this, after upgrade to 11.1-U5 I experienced loss of network connectivity for my iocage jails. This solution resolved it.
 

kpfleming

Cadet
Joined
Nov 21, 2017
Messages
6
So best i can tell, bridge1 is the bridge for my functioning Warden jail, with epair1a and lagg0 as members. In that jail, the interface is epair1b.
In the iocage jail, the interface is epair0b. The bridge for this iocage is bridge0, which only has the member vnet0:4. When i try to add the lagg0 to bridge0, i get:

root@freenas:~ # ifconfig bridge0 addm lagg0
ifconfig: BRDGADD lagg0: Device busy

Is it possible to have lagg0 as a member of 2 different bridges?

No, that's not possible. However, your issue has a different cause, which I've run into as I have almost the the same configuration.

The issue is that the FreeNAS link aggregation configuration is *not* handled by setting rc.conf variables; instead the aggregations are created by a script which runs *after* rc.conf is done. As a result, anything you do in rc.conf (system tunables in FreeNAS) which attempts to refer to lagg0 or any other link aggregation fails because it doesn't exist at the point where rc.conf is running. This is a really tricky problem to solve, as it's based on the dependencies between various bits of configuration. It's even trickier for me, as I wanted to create VLAN subinterfaces on top of the aggregation, and then allow jails to use them.

In the end I stopped using bridges, and used a feature of the underlying jail system (the vnet.interface jail property) which allows the jail to steal an interface from the host at startup, and then return it at shutdown. No need for a bridge at all, then, if you have dedicated interfaces (physical or VLAN) for the jails to use.
 

fd0

Dabbler
Joined
Sep 11, 2013
Messages
19
No, that's not possible. However, your issue has a different cause, which I've run into as I have almost the the same configuration.

In the end I stopped using bridges, and used a feature of the underlying jail system (the vnet.interface jail property) which allows the jail to steal an interface from the host at startup, and then return it at shutdown. No need for a bridge at all, then, if you have dedicated interfaces (physical or VLAN) for the jails to use.

Could you share some info on this, how you achieved this?
TIA
 

kpfleming

Cadet
Joined
Nov 21, 2017
Messages
6
When you create the jail with the iocage command (CLI, not in the GUI), supply "vnet=on" and "vnet_interfaces='<interface_name>'". This won't stop iocage from creating bridge0 and vnet0 (some day I'll send a patch to fix that), but it will *move* the identified interface into the jail when it starts up, and (usually) remove it when the jail is shut down.

Instead of using the ip4_addr/ip6_addr properties, which won't be applied to the moved interface, just use normal networking configuration in /etc/rc.conf inside the jail. This could be fixed with a patch too, though, just needs some time which is in short supply. After the jail comes up, you'll see an unconfigured vnet0 interface which you can ignore.

The (usually) above is just a caveat of vnet mode in general; when you restart the jail (using 'iocage restart') the vnet stack is not always properly torn down, and as a result the interface you moved into the jail doesn't get moved back to the host... so it's gone. The only fix for this situation is to reboot the machine unfortunately.
 

diskdiddler

Wizard
Joined
Jul 9, 2014
Messages
2,377
Can anyone confirm if this problem persists? I've just logged a bug, because even under BETA1, my networking is entirely, suddenly dead for iocage.

Frustratingly, it WAS working fine on U5, now dead on BETA1 as well. Just stopped, update didn't fix?
 

j0hnby

Explorer
Joined
Apr 22, 2017
Messages
68
I still have to have the Tunables in to have the physical NIC added into the bridge. Although at the bridge does get created on it's own now. I thought it had been fixed in 11.2B1, but might have been reading the U6 info instead and presumed....fail
 

spotcatbug

Dabbler
Joined
Nov 6, 2017
Messages
43
Can anyone tell me what my tunables should look like if my network connection is an aggregation? The interface is named "lagg0". The problem is am finding is that if I replace the "igb0" above with "lagg0", I am unable to access the entire freenas system after reboot (until i reconfigure the interface from the local kb/monitor).

Finally! Someone with the same problem I have! I have warden and iocage jails and an aggregated network connection.

After much fiddling I now have a working "solution." Since I rarely need to restart my FreeNAS machine, it's all manual. It could be scripted, but I'm just doing it manually whenever I have to restart FreeNAS because it's all going to get sorted-out eventually, right?

Anyway, steps:
  1. Set your warden jails to not autostart.
  2. Reboot.
  3. Open a shell and do ifconfig -a. Notice your iocage jail's interface and a bridge interface. The bridge interface will have your iocage interface in it; however, lagg0 won't be in it, so...
  4. sudo ifconfig bridge0 addm lagg0 (at this point your iocage jail will work.)
  5. Now start each of your warden jails (at this point your warden jails will work.)
  6. ifconfig -a. Notice that all the jail interfaces are in bridge0 along with lagg0.
You have to do steps 4 and 5 whenever you reboot your FreeNAS machine.
 

Ceetan

Contributor
Joined
Apr 29, 2016
Messages
139
Code:
root@freenas-pmh:~ # cat /mnt/zfs/scripts/bridge0.sh
#! /bin/sh

PAUSE="10"
BRIDGE="bridge0"
INTERFACES="igb1 igb2 igb3"

(
	until /sbin/ifconfig | /usr/bin/grep -q "^${BRIDGE}:"; do sleep 2; done
	sleep ${PAUSE}

	for if in ${INTERFACES}
	do
		/sbin/ifconfig ${if} up
		/sbin/ifconfig ${BRIDGE} addm ${if}
	done
) &

exit 0
@Patrick M. Hausen Just to make sure I understand: This is used as a post init-scrip in default freeenas userspace?

What does the first line (starting with cat) do?
 

Linkman

Patron
Joined
Feb 19, 2015
Messages
219
@Patrick M. Hausen Just to make sure I understand: This is used as a post init-scrip in default freeenas userspace?

What does the first line (starting with cat) do?

The 'cat' command is what is echoing the contents of 'bridge0.sh' to the terminal. The actual script starts with '#! /bin/sh' and ends with the line 'exit 0'
 

nathank1989

Contributor
Joined
Aug 29, 2016
Messages
103
I am running 11.2-BETA1 and my iocage jails are wrecking havok on my NAS connectivity and my network as a whole.
My Ubiquiti UniFi system will start losing access to IP ranges because of some confusion from the NAS. I cannot reliably keep access to my jails, setting static specific interfaces loses my access entirely.

This is maddening since I know Warden jails worked for my use case, but want to start fresh on iocage so as not to worry about upgrading later.... but here I am pulling my hair out trying to achieve a basic goal.
 

Jailer

Not strong, but bad
Joined
Sep 12, 2014
Messages
4,977

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776

Zwck

Patron
Joined
Oct 27, 2016
Messages
371
how do you guys create your jails at the moment, in terms of network settings (Beta2)?
 

verysneaky

Dabbler
Joined
Jun 4, 2018
Messages
22
I just upgraded to 11.1-U6 to fix this issue, but it's still persisting. Anybody else having the same problem or am I doing something wrong?
 

j0hnby

Explorer
Joined
Apr 22, 2017
Messages
68
how do you guys create your jails at the moment, in terms of network settings (Beta2)?
Used to do it via the command line, but since B2 have used the web interface - it's much more slick. Still prefer to create a blank jail then add my own packages in manually, that's just me liking to know how things go together though.
 
Top