======================================= FreeBSD - Using Jails & VMs Concurrently ======================================= This example shows how to configure the host with guests using public and private interfaces. A network interface can only be a member of one bridge. If you try to use igb0 in a bridge for jails and also in a bridge for vms, you will get a rash. The solution is to create a single shared bridge with epairs and taps as members. The jails will use epairs and vms will use taps. Set the ip on the bridge and not on igb. Use -lro -tso -txcsum -txcsum6 to improve speeds. NOTE: bhyve and virtualbox cannot be used concurrently because they require exclusive access to hardware virtualization (vt-x/amd-v). ======================================= ed /etc/rc.conf --------------------------------------- # 1. hardware links with no ips (igb0 = lan, igb1 = wan) ifconfig_igb0="up -tso -lro -txcsum -txcsum6" ifconfig_igb1="up -tso -lro -txcsum -txcsum6" # 2. virtual switches (0 = lan, 1 = wan) cloned_interfaces="bridge0 bridge1 tap0 tap1" # 3. lan switch with host ip ifconfig_bridge0="inet 192.168.69.70 netmask 255.255.255.0 addm igb0 addm tap0 up" # 4. wan switch to wire with no ip (no direct public access to the host) ifconfig_bridge1="addm igb1 addm tap1 up" # 5. default gateway defaultrouter="192.168.55.1" gateway_enable="YES" # 6. jail jail_enable="YES" jail_list="fido" # 7. ipfw for jails firewall_enable="YES" firewall_type="open" # 8. virtualbox vboxnet_enable="YES" vboxheadless_enable="YES" vboxheadless_user="root" vboxheadless_machines="devuan windows" vboxheadless_devuan_name="devuan" vboxheadless_windows_name="windows" --------------------------------------- service devfs restart service netif restart service routing restart ======================================= ed /etc/jail.conf --------------------------------------- fido { vnet; # 1. virtual cable for lan exec.prestart = "ifconfig epair11 create up"; exec.prestart += "ifconfig bridge0 addm epair11a"; # lan # 2. virtual cable for wan exec.prestart += "ifconfig epair12 create up"; exec.prestart += "ifconfig bridge1 addm epair12a"; # wan # both 'b' wire ends go inside the jail rc.conf vnet.interface = "epair11b"; vnet.interface += "epair12b"; # shutdown exec.poststop = "ifconfig bridge0 deletem epair11a"; exec.poststop += "ifconfig bridge1 deletem epair12a"; exec.poststop += "ifconfig epair11a destroy"; exec.poststop += "ifconfig epair12a destroy"; } ======================================= virtualbox --------------------------------------- # set nic1 bridged to the lan tap VBoxManage modifyvm "devuan" --nic1 bridged --nictype1 virtio --bridgeadapter1 tap0 # set nic2 bridged to the wan tap VBoxManage modifyvm "devuan" --nic2 bridged --nictype2 virtio --bridgeadapter2 tap1 ======================================= bhyve --------------------------------------- bhyve -c 2 -m 4G -H \ -s 0,hostbridge \ -s 1,lpc \ -s 2,virtio-net,tap0 \ -s 3,virtio-net,tap1 \ -s 4,ahci-hd,/export/bhyve/brio.img \ -l com1,stdio \ brio ======================================= done =======================================