Solved VirtualBox VM can't access jail using virtual switch.

Dear @ll,

Hopefully someone here can point me in the right direction.

I have a working bhyve configuration which allows me to spinup VMs (vm-bhyve). I use dnsmasq to assign an IP addr on-the-fly via DHCP and a DNS server, pf works great for NAT to access the broader network, and I have a jail providing a local repo via lighttpd attached to the virtual switch to speed up my test env. All working great!

However sometimes I need VirtualBox to test something, so I do the following:


# shutdown bhyve
$ service vm stop

# unload virtualization kernel module
$ kldunload vmm

# load VirtualBox kernel module
$ kldload vboxdrv

# launch VirtualBox Network support
$ service vboxnet onestart


So I launch VirtualBox, configure my VM, for Network Attached to: I select 'Bridged Adapter' and for Name: I select my bhyve virtual switch 'vm-public' and fire up the VM. VM requests an IP addr using DHCP which is provided by dnsmasq on vm-public, so all is fine. I can use ansible to do some basic configuration, however as soon as I want to access the repo provided by the jail I can't access it from the VirtualBox VM, and can't even ping the repo jail.


Code:
# Jail Configuration
Repo {
    # Path
    path = "/usr/jail/repo";

    # Network
    host.hostname = "repo.local";

    # VNet/VImage
    vnet;
    vnet.interface = "${epair}b";

    # production
    $id = "254";
    $ip = "172.16.254.${id}/24";
    $gateway = "172.16.254.1";
    $bridge = "vm-public";
    $epair = "epair${id}";

    # join interface vm-public
    exec.prestart  = "/sbin/ifconfig ${epair} create up";
    exec.prestart += "/sbin/ifconfig ${epair}a up descr jail:${name}";
    exec.prestart += "/sbin/ifconfig ${bridge} addm ${epair}a up";
    exec.start    += "/sbin/ifconfig ${epair}b ${ip} up";
    exec.poststop += "/sbin/ifconfig ${bridge} deletem ${epair}a";
    exec.poststop += "/sbin/ifconfig ${epair}a destroy";


    # Logging
    exec.consolelog = "/var/log/jail/${name}.log";
}

For whatever reason VBox VM traffic does not reach the repo (jail), when I fire up a bhyve VM I can access the repo (jail) without any issue.

Any help would be highly appreciated.

Thx in advance.

Edit:
The option Promiscuous Mode: has been set to Allow All for the VirtualBox VM.
 
As I don't require to have the jail it's own virtualized network stack, the following configuration just works:

Code:
# Jail Configuration
Repo {
    # Path
    path = "/usr/jail/repo";

    # Network
    host.hostname = "repo.local";
    ip4.addr = 172.16.254.1;

    # Logging
    exec.consolelog = "/var/log/jail/${name}.log";
}
 
Back
Top