bhyve The missing piece - bhyve - LAN yes, Internet no.

Here's what I did to set up NAT and started a Win10 image.
IP addresses were set manually.

Code:
ifconfig tap9 create
sysctl net.link.tap.up_on_open=1
ifconfig bridge9 create
ifconfig bridge9 addm wlan0 addm tap9
ifconfig bridge9 up
cd /root
ifconfig bridge9 inet 10.0.0.1/24
#Above sets 10.0.0.1 on bridge9. Now inside your Guest set 10.0.0.2 or something in that segment

  bhyve -c 2 -m 4G -H -w \
  -s 0,hostbridge \
  -s 4,ahci-hd,os_disk.img \
  -s 5,virtio-net,tap0 \
  -s 6,hda,play=/dev/dsp1,rec=/dev/dsp0 \
  -s 29,fbuf,tcp=127.0.0.1:5900,wait \
  -s 30,xhci,tablet \
  -s 31,lpc \
  -l com1,stdio \
  -l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd \
  win10

My bridge9 is 10.0.2.1 and the guest OS is 10.0.2.2
Guest OS is successfully pinging the host bridge9 but cannot reach the internet.
I guess something needs to be done on the host to pass the packets. I tried with pf disabled as well.

Any ideas?
 
My bridge9 is 10.0.2.1 and the guest OS is 10.0.2.2
Your code says 10.0.0.1 and 10.0.0.2.

And, if you're binding directly to your LAN you don't need NAT at all. Don't assign an address to the bridge and just give your guest an IP address in the same range as your wlan0 interface. Your VM and your wlan0 are bridged, in other words, they're on the same layer 2 network.
 
you have to enable forwarding and nat on the host
also set default route on the guest
Actually I did do this as well:
sysctl net.inet.ip.forwarding=1
My default route for my wlan0 is set, example:
route add default 192.168.1.1

For default route on the guest I have used 10.0.0.1 as the GW and proper public DNS server settings as well.
 
Your code says 10.0.0.1 and 10.0.0.2.

And, if you're binding directly to your LAN you don't need NAT at all. Don't assign an address to the bridge and just give your guest an IP address in the same range as your wlan0 interface. Your VM and your wlan0 are bridged, in other words, they're on the same layer 2 network.
Oh yeah that's a typo. The host is 10.0.0.1 and the guest is 10.0.0.2
I have tried total bridge mode and it works for the ethernet alone, but I do not wish to expose this system directly on the network - hence a NAT.

I am migrating from vbox and it seems that under bhyve I cannot just have a flying nat (like Oracle VBox) that would cling to whatever network device ethernet ot wlan is available. So I thought I will just allocate wlan0. Please advise how do I get 10.0.0.2 guest reach the Internet via 10.0.0.1. It already pings it.
 
Actually I did do this as well:
sysctl net.inet.ip.forwarding=1
The preferred way is to set gateway_enable="YES" in rc.conf.

I have tried total bridge mode and it works for the ethernet alone, but I do not wish to expose this system directly on the network - hence a NAT.
Ok, that's fine. But then don't bridge(4) your VM to your wlan0 interface because that will directly connect it to your local network. Don't add wlan0 here:
Code:
ifconfig bridge9 addm wlan0 addm tap9
Don't attach the bridge to any external interface.

Then your pf.conf should have something like this:
Code:
nat on wlan0 from 10.0.0.0/24 to any -> (wlan0)
 
I apologize I must be hallucinating. Neither does my config, nor does your (ifconfig bridge9 addm tap9) work.
I was self-pinging (10.0.0.2) from and to the Win10 host maybe.. but I recall seeing both MAC addresses at the host.
I will retry from scratch again. If you have a good writeup I can read point me towards it. Many thanks.
 
Back
Top