Hey guys, this is a really old post, and sorry if it is against the rule revive a necro post. But, this is the first search link that appears and this thread is really good.
So I have decided to post here to, since my issue is the same and I cant get networking woking on my bhyve. I'll appropriate the troubleshoot that the freebsd wizzards provided here to relate my issue, since it a little diferent but end in the same problem.
So, first off, I've got into Freebsd in the last weekend and I got a very little fresh install FreeBSD as a personal environment. I am using it as a personal PC for study reasons and I plan to stick a little with that OS to learn some of it features, and eventually revive a old computer of mine as a personal server. I don't know if it is important but I am using i3wm as window manager, pkg as the main installer of the tools I am using.
I have instaled bhyve, bhyve-vm, firmware, grub2-bhyve, and everything needed to run a VM. I did got to start my vm, and I am using vncviewer to connect to a archlinux iso that I want to install as a vm for use somethings that are not easily done in freeBSD and other development purposes. I've read some parts of the handbook, wiki and other tutorials.
I've got bhyve working with the quick example at
https://wiki.freebsd.org/bhyve,
also I've used
https://www.cyberciti.biz/faq/how-to-install-linux-vm-on-freebsd-using-bhyve-and-zfs/ to create a .sh to quickly build a vm without vm-bhyve, and for last,
i'am stickying with this tutorial:
https://klarasystems.com/articles/from-0-to-bhyve-on-freebsd-13-1/ that provided a cool template to run a vm with vm-bhyve.
So, in a nutshell, I am using the .template provided by klarasystems to install my vm-bhyve, and I'll post it down here if you guys think that is important and something could be changed (i also got some questions about the arch template that I'll ask here too).
Code:
# If you want to pull a graphical console, you'll need the UEFI loader,
# no matter what OS you're installing on the guest.
loader="uefi"
graphics="yes"
xhci_mouse="yes"
# If not specified, cpu=n will give the guest n discrete CPU sockets.
# This is generally OK for Linux or BSD guests, but Windows throws a fit
# due to licensing issues, so we specify CPU topology manually here.
cpu=2
cpu_sockets=1
cpu_cores=2
# Remember, a guest doesn’t need extra RAM for filesystem caching--
# the host handles that for it. 4G is ludicrously low for Windows on hardware,
# but it’s generally more than sufficient for a guest.
memory=4G
# put up to 8 disks on a single ahci controller. This avoids the creation of
# a new “controller” on a new “PCIe slot” for each drive added to the guest.
ahci_device_limit="8"
# e1000 works out-of-the-box, but virtio-net performs better. Virtio support
# is built in on FreeBSD and Linux guests, but Windows guests will need
# to have virtio drivers manually installed.
#network0_type="e1000"
network0_type="virtio-net"
network0_switch="public"
# bhyve/nvme storage is considerably faster than bhyve/virtio-blk
# storage in my testing, on Windows, Linux, and FreeBSD guests alike.
disk0_type="nvme"
disk0_name="disk0.img"
# This gives the guest a virtual "optical" drive. Specifying disk1_dev=”custom”
# allows us to provide a full path to the ISO.
disk1_type="ahci-cd"
disk1_dev="custom"
disk1_name="/zroot/bhyve/virtio-win.iso"
# windows expects the host to expose localtime by default, not UTC
utctime="no"
Well, he created it for a windowns server, but suits linux and bsd os as well.
I have also, changed the disk1_name to the relative arch.iso I am trying to install and this is the only change I've done to this .template.
You guys can ask me why I didnt use the arch template provided by vm-bhyve, and I've tried with that too, and I'll paste it down here too for some explaining and questioning purposes:
Code:
loader="grub"
cpu=1
memory=512M
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0.img"
grub_install0="linux /arch/boot/x86_64/vmlinuz archisobasedir=arch archisolabel=ARCH_201611 ro"
grub_install1="initrd /arch/boot/x86_64/archiso.img"
When I did run this .template, the grub menu dosent boot automatically to the iso, and also complains that /arch/boot/x86_64/vmlinuz archisobasedir=arch dosen't exists.
I dont think that the templates is the main reasons of my problem, but I didn´t quite understand how those disk1_* and grub_* arguments really work and what they are meant for. If you guys find interesting to talk a little about it, i'll really enjoy that information.
Well, given that, I am building the vm enviroment as the OP did:
Code:
pkg install vm-bhyve
# Well, I haven´t configured zsf pool on my install but i dont think this is the issue.
# zfs create zroot/vm
sysrc vm_enable="YES"
sysrc vm_dir="/my/bhyve/path/"
vm init
cp /usr/local/share/examples/vm-bhyve/* /my/bhyve/path/
vm switch create public
# I've tried that but was it throws a warning and you guys says it's not recommend, I've skipped that
# vm switch nat public on
# I have made that addition, equaling to klarasystems tutorial:
vm switch add public wlan0
vm iso arch.iso
#uefi is the template that i provided you guys up in this post
vm create -t uefi -s 50G testvm
vm [-f] install testvm arch.iso
# instead of vm console, i am using vncviewer, but both ways end in the same problem
vm console testvm
Now, as @
SirDice had recomend, my
vm switch info public
output:
Code:
local: _netgraph,: bad variable name
------------------------
Virtual Switch: public
------------------------
type: standard
ident: vm-public
vlan: -
physical-ports: wlan0
bytes-in: 197648 (193.015K)
bytes-out: 5265452 (5.021M)
thre is that _netgraph issue, i've checked on vm-bhyve git and it is not really a issue I think.
In diference to the OP, I am gotting bytes-in and bytes-out! Also, if I start the vm the output of info is:
Code:
local: _netgraph,: bad variable name
------------------------
Virtual Switch: public
------------------------
type: standard
ident: vm-public
vlan: -
physical-ports: wlan0
bytes-in: 201656 (196.929K)
bytes-out: 5270992 (5.026M)
virtual-port
device: tap0
vm: arch
So the network is really being provided to the vm, I guess.
Now some points that the op had bringed:
- disabling pf
- removing an IP alias (second IP)
- uninstalling vm-bhyve, removing all network interfaces created, reboot, reinstall
I can ping the guest from the host machine but not vice versa. The host cannot even see the gateway.
I don´t have pf installed yet.
I don´t think I have a IP alias (and I guess ifconfig output will confirm that)
I did try unnistall and recreating things, and the situation is really diferent as you guys are seing.
And for last, I tried this ping thing, but I don't know if it really worked out.
(Well, the .template i am using provide the guest at localhost:5900 and pinging it dont really work, how can i know for sure the guest and host IP?)
if the situation is about ping from guest to the inet address provided by ifconfig in my host, when I try that it says:
ping: Connect: Network is unreachable
And maybe that is a issue that I am missing something, Idk for sure!
When op did:
Code:
$ cat /zroot/vm/testvm/testvm.conf
loader="grub"
cpu=4
memory=2048M
network0_type="virtio-net"
network0_switch="public"
disk0_type="virtio-blk"
disk0_name="disk0.img"
uuid="3366b5df-08d4-11e7-a9e7-448a5b29dff9"
I guess it provided to him the template he used, in adition, creating a uuid. My output of that is the same, it provides me a uuid and also a network0_mac.
OP did also a
$ cat /etc/pf.conf
and a
cat /zroot/vm/.config/pf-nat.conf
but again, i haven´t looked into this pf thing yet, so those files dosen't exist in my PC. The guys in thread also talked about
gateway_enable="YES"
and NAT things but I dont really know what this is about. (yes, I dont know alot of networks, but I hope to get a little better from now on)
Now there is thoose asked outputs:
ifconfig
sysctl net.link.bridge net.link.tap net.inet.ip.forwarding
pfctl -s nat
pfctl -s rules
pfctl -vs Interfaces
Code:
~ > ifconfig
wlan0: ..omited...
vm-public: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 36:ae:c9:d3:39:68
id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
root id 00:00:00:00:00:00 priority 32768 ifcost 0 port 0
member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 5 priority 128 path cost 2000000
member: wlan0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
ifmaxaddr 0 port 2 priority 128 path cost 138888
groups: bridge vm-switch viid-4c918@
nd6 options=9<PERFORMNUD,IFDISABLED>
tap0: flags=8943<UP,BROADCAST,RUNNING,PROMISC,SIMPLEX,MULTICAST> metric 0 mtu 1500
description: vmnet/arch/0/public
options=80000<LINKSTATE>
ether 58:9c:fc:10:e5:0c
groups: tap vm-port
media: Ethernet autoselect
status: active
nd6 options=29<PERFORMNUD,IFDISABLED,AUTO_LINKLOCAL>
Opened by PID 42985
Code:
~ > sysctl net.link.bridge net.link.tap net.inet.ip.forwarding
net.link.bridge.ipfw: 0
net.link.bridge.allow_llz_overlap: 0
net.link.bridge.inherit_mac: 0
net.link.bridge.log_stp: 0
net.link.bridge.pfil_local_phys: 0
net.link.bridge.pfil_member: 1
net.link.bridge.ipfw_arp: 0
net.link.bridge.pfil_bridge: 1
net.link.bridge.pfil_onlyip: 1
net.link.tap.debug: 0
net.link.tap.devfs_cloning: 1
net.link.tap.up_on_open: 1
net.link.tap.user_open: 0
net.inet.ip.forwarding: 0
Code:
~ > pfctl -s nat
pfctl: /dev/pf: No such file or directory
~ > pfctl -s rules
pfctl: /dev/pf: No such file or directory
~ > pfctl -vs Interfaces
pfctl: /dev/pf: No such file or directory
Well I guess this is it. I dont really know what's goin on or if I just missed some important part of running the bhyve. I just want it for localnetwork purposes. Can you guys please help me? Thanks for reading into here.