Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a FreeBSD10 host with bhyve and the following IP-configuration in rc.conf:

ifconfig_igb0="inet X.X.X.146 netmask 255.255.255.0 broadcast X.X.X.255"
defaultrouter="X.X.X.254"
cloned_interfaces="bridge0"
ifconfig_bridge0="addm igb0 up"

The tap device gets added via the vmrc scripts. I have another IPv4 Address from my hoster which is in another subnet: Y.Y.Y.176. The hoster gives me the following guide to configure bridged-networking with this IP: Bridged Networking

According to this guide I configured the guest (FreeBSD10) like this (the hoster provides me with a "virtual MAC" for the IP):

ifconfig_vtnet0="inet Y.Y.Y.176 netmask 255.255.255.255 ether 02:00:00:8c:46:32"
static_routes="net1 net2"
route_net1="-net X.X.X.254/32 Y.Y.Y.176"
route_net2="default X.X.X.254"

Before starting the VM I setup the bridge like this:

ifconfig bridge0 addm igb0 addm tap0 up

with tap0being the "host-side" of the VMs network adapter.

This does not work. I can't reach the gateway from within the VM and I can't reach the host from the VM. This makes sense to me, because there are no routes. It's unclear how this could even work.

share|improve this question
    
Please avoid using other people's public IP addresses in your examples. –  Michael Hampton Jun 6 at 14:40

2 Answers 2

You likely need to do:

ifconfig tap0 up

and/or add net.link.tap.up_on_open=1 to /etc/sysctl.conf to make it auto-up

Normally the tap interface doesn't come up until you give it an IP.

This should make the bridge work.

To configure the bridge in rc.conf:

cloned_interfaces="bridge0 tap0" ifconfig_bridge0="addm igb0 addm tap0 up"

you also need: if_bridge_load="YES" if_tap_load="YES"

in /boot/loader.conf so that tap can be created on the fly

See the official instructions I wrote here: http://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/virtualization-host-bhyve.html

share|improve this answer
    
Sorry I didn't mention it specifically - the bridge gets of course configured like you said. Question updated. Regarding the sysctl and the modules - I did that too. I followed the exact guide you're mentioning. If I route the subnet the "normal" way, I can get it to work - just the "use all IPs as host-addresses"-thing seems to make problems. –  Subito Jun 25 at 7:42
up vote 0 down vote accepted

This did not solve, but rather circumvent the problem:

I assigned igb0 on the host all the IPs with a /32 network-mask, instead of the VMs and assigned bridge0 the private IP 10.0.0.1/24, the vtnet0 interface in the VM gets assigned 10.0.0.2 with a default-gateway of 10.0.0.1 and I create a binat using pf.

The rc.conf on the host looks like this:

ifconfig_igb0="inet X.X.X.146 netmask 255.255.255.0 broadcast X.X.X.255"
defaultrouter="X.X.X.254"

ifconfig_igb0_alias0="inet Y.Y.Y.176/32"
ifconfig_igb0_alias1="inet Y.Y.Y.177/32"
ifconfig_igb0_alias2="inet Y.Y.Y.178/32"
ifconfig_igb0_alias3="inet Y.Y.Y.179/32"

cloned_interfaces="bridge0"
ifconfig_bridge0="inet 10.0.0.1/24"

And the pf.conf on the host:

vm_if1 = "Y.Y.Y.176"
vm_if2 = "Y.Y.Y.177"
vm_if3 = "Y.Y.Y.178"
vm_if4 = "Y.Y.Y.179"

slave = "10.0.0.4"

binat on igb0 from $slave to any -> $vm_if1
nat on igb0 from bridge0:network to any -> (igb0)

The VMs rc.conf is really easy:

ifconfig_vtnet0="10.0.0.2 netmask 255.255.255.0"
defaultrouter="10.0.0.1"

Now, whenever I provision a new VM, it needs a IP within the 10.0.0.0/24 range and I need to adjust the hosts pf.conf.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.