You are not logged in.

#1 2018-04-02 23:05:18

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

[OpenBSD 6.3] Connecting Debian guests in vmm(4)

This guide shows how to connect to the internet from a Debian virtual machine running under OpenBSD's vmm(4) hypervisor with a wireless connection in the host.

Installing Debian

Unfortunately, the Debian ISO images do not support a serial console boot so to install a Debian virtual system emulators/qemu is required — my BunsenLabs guide can actually be used in OpenBSD, the commands are almost the same:

https://forums.bunsenlabs.org/viewtopic.php?id=1546

^ The only difference is that the -enable-kvm flag cannot be used because there is no such module in OpenBSD, the installation will be *very* slow because of this.

This should result in an installed Debian system, for the rest of this guide it is presumed to exist at ~/vmm/stretch.img

The system will have to be configured to boot to a serial console and open a TTY there, this guide shows how to add the necessary GRUB parameters:

https://www.hiroom2.com/2016/06/07/debi … l-console/

Configuring the Virtual Machine

First enable the daemon to start at boot and bring it up:

# rcctl enable vmd
# rcctl start vmd

Then configure forwarding:

# echo 'net.inet.ip.forwarding=1' >> /etc/sysctl.conf
# sysctl net.inet.ip.forwarding=1

Open up the firewall:

# echo 'match out on iwn0 inet from vether0:network to any nat-to (iwn0)' >> /etc/pf.conf
# pfctl -f /etc/pf.conf

^ I've used "iwn0" there, substitute the actual name of the interface required (use `ifconfig` to list all interfaces).

And finally set up a vether(4) for the VM's tap0 interface:

# echo 'inet 10.0.0.1 255.255.255.0' > /etc/hostname.vether0
# sh /etc/netstart vether0

This sets up a vether0 interface on the host machine with a 10.0.0.0/24 subnet which can later be bridged to the guest's tap0 interface, the vether0 address (10.0.0.1) will then act as the gateway.

The Debian stretch VM can now be started:

# vmctl start stretch -L -d ~/vmm/stretch.img -m 1G

Check with

Puffy:~$ vmctl status
   ID   PID VCPUS  MAXMEM  CURMEM     TTY        OWNER NAME
    1 50338     1    1.0G    341M   ttyp2        root  stretch
Puffy:~$

This shows the VM and gives an ID number (first column on the left, "1" in this case), use the ID to connect:

# vmctl console $id

^ Replace $id with the actual ID number.

Inside the VM the tap0 interface should be exposed as enp3s0 and can be added to /etc/network/interfaces, like this:

auto enp0s3
iface enp0s3 inet static
    address 10.0.0.2
    netmask 255.255.255.0
    gateway 10.0.0.1

Once that file is saved, set a nameserver:

[stretch] # echo 'nameserver 8.8.8.8' > /etc/resolv.conf

Then use `ifup enp0s3` to bring the connection up.

The final step is to bridge tap0 & vether0 in the OpenBSD host:

# ifconfig bridge0 add vether0 add tap0 up

There should now be an internet connection in the Debian guest.

Autostarting the VM

These stanzas in /etc/vm.conf will bring the VM up and attach the bridge at every boot:

vm stretch {
    memory 1G
    disk "/home/${user}/vmm/stretch.img"
    interface { switch "localnet" }
    owner "${user}"
}

switch "localnet" {
    interface bridge0
}

^ Replace "${user}" with the actual username.

And finally add the hostname file to start the bridge at boot:

# echo 'add vether0 add tap0' > /etc/hostname.bridge0

That's it!

Reboot and enjoy smile

Last edited by Head_on_a_Stick (2018-04-03 20:57:42)


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

#2 2018-04-03 20:58:35

Head_on_a_Stick
Member
From: London
Registered: 2015-09-29
Posts: 8,759
Website

Re: [OpenBSD 6.3] Connecting Debian guests in vmm(4)

Figured out the switch & bridge configuration (it was in the man page, what a surprise), the guide is now complete glasses


“Et ignotas animum dimittit in artes.” — Ovid, Metamorphoses, VIII., 18.

Forum Rules   •   How to report a problem   •   Software that rocks

Offline

Board footer

Powered by FluxBB