vm-bhyve
vm-bhyve copied to clipboard
The ip address of the switch is missing.
I am using 13.0-RELEASE-p4 and vm-bhyve v1.4.2 (rev. 104002)
When starting the system the bridge interface vm-public is up with an ip address of 192.168.8.1
$ ifconfig vm-public
vm-public: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 56:e5:cd:fa:96:d6
inet 192.168.8.1 netmask 0xffffff00 broadcast 192.168.8.255
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
groups: bridge vm-switch viid-4c918@
nd6 options=9<PERFORMNUD,IFDISABLED>
Switch settings:
$ doas vm switch list
NAME TYPE IFACE ADDRESS PRIVATE MTU VLAN PORTS
public standard vm-public 192.168.8.1/24 no - - -
$ doas vm switch info public
------------------------
Virtual Switch: public
------------------------
type: standard
ident: vm-public
vlan: -
physical-ports: -
bytes-in: 0 (0.000B)
bytes-out: 0 (0.000B)
$ cat /vm/.config/system.conf
switch_list="public"
type_public="standard"
addr_public="192.168.8.1/24"
When I start the virtual machine with the config
$ cat /vm/alpine/alpine.conf
loader="grub"
cpu=1
memory=512M
disk0_type="virtio-blk"
disk0_name="disk0.img"
grub_install0="linux /boot/vmlinuz-lts initrd=/boot/initramfs-lts alpine_dev=cdrom:iso9660 modules=loop,squashfs,sd-mod,usb-storage,sr-mod"
grub_install1="initrd /boot/initramfs-lts"
grub_run0="linux /boot/vmlinuz-lts root=/dev/vda3 modules=ext4"
grub_run1="initrd /boot/initramfs-lts"
uuid="684ee514-a473-11eb-846f-2cea7f10fdde"
network0_type="virtio-net"
network0_switch="public"
network0_mac="58:9c:fc:0b:71:d0"
ip address is missing on the vm-public interface
$ doas vm start alpine
Starting alpine
* found guest in /vm/alpine
* booting...
$ ifconfig vm-public
vm-public: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
ether 56:e5:cd:fa:96:d6
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 8 priority 128 path cost 2000000
groups: bridge vm-switch viid-4c918@
nd6 options=9<PERFORMNUD,IFDISABLED>
and I cannot connect to my vm. I have to add the address manually. How can this be fixed?
You should add you physical interface to this bridge like that: vm switch add public <you-if-name>
. It's mentioned in Quickstart: https://github.com/churchers/vm-bhyve/wiki/Quickstart
Some more virtual switches info: https://github.com/churchers/vm-bhyve/wiki/Virtual-Switches
Since bridge does not work with wlan interfaces, I use nat from this documentation https://github.com/churchers/vm-bhyve/wiki/NAT-Configuration
Ok, so this may be different problem. I have never used this setup so maybe @churchers could chime in.
Hi all!
I can confirm this issue. Following the steps mentioned in [1], both when starting the VM and when shutting it down, the IP of the bridge is lost and it is necessary to execute again vm switch address public <IP>
.
But I'm not sure if this is a vm-bhyve
bug or just a Bhyve feature because I've noticed similar behavior using the /usr/share/examples/bhyve/vmrun.sh
script. In this case I have used the procedure described in [2] in the order indicated and every time I start the virtual machine some network configurations are lost so I am forced to manually execute again:
# ifconfig bridge0 inet 10.0.4.1/24 up
# sysctl net.inet.ip.forwarding=1
net.inet.ip.forwarding: 0 -> 1
[1] https://github.com/churchers/vm-bhyve/wiki/NAT-Configuration [2] https://adventurist.me/posts/00304
I question why you would even want an IP address on the bridge, just adding your 10 gigabit ethernet card to it, and letting vm-bhyve handle adding tap devices to it should be enough. Vlans should be handled on the switch itself as I've never seen a point to do a software vlan with virtualized guests.
Me-too comment. As soon as the vm is started, bridge's IP address is gone, and guests's access to the network with it, Once added again via vm switch address public <IP/mask>
everything is back to normal.
As per "why you would even want an IP address on the bridge" I am running this vm on a gateway already full of NICs and want an isolated network, why add hardware when you don't have to?
I will show you how I do it where I don't have any problems with IPV6 or anything making sure bridge has auto_linklocal set. I try to keep it standard with br0 so when going back between KVM on Linux with virsh on older hosts that don't support bhyve and FreeBSD it has some similarities. I really suggest you do it this way as the FreeBSD handbook suggests always assigning IP to the bridge then adding devices, also if you change your networking config to use say a lag0 port at some point its just a simple change in /etc/rc.conf instead:
/etc/rc.conf:
#let vm-bhyve create tap devices instead so they get destroyed when not in use
cloned_interfaces="bridge0"
ifconfig_br0="addm ix0 up description services"
ifconfig_bridge0_name="br0"
ifconfig_br0_alias0="inet 192.168.0.1 netmask 255.255.255.0"
ifconfig_br0_ipv6="inet6 fc00:192:168:1::1/64 accept_rtadv auto_linklocal"
ifconfig_ix0="up -rxcsum -tso -txcsum -lro -vlanhwtso"
#manually create switch named "services" with vm-bhyve
vm switch create -t manual -b br0 services
#example guest configuration using our manual switch:
loader="uefi"
#graphics="yes"
xhci_mouse="yes"
cpu=8
cpu_sockets=2
cpu_cores=4
memory=8G
network0_type="virtio-net"
network0_switch="services"
#change to "nvme" if we get better server
disk0_type="virtio-blk"
disk0_name="disk0.img"
uuid="5caa73a4-72de-11ed-83f8-e4534bf64f00"
network0_mac="58:9c:fc:0a:18:2d"
@syleishere thanks you. this plus dnsmasq got my vm getting an ip