vbox Virtualbox does not nat on openbsd guest

Hello, I have installed OpenBSD as vm. It works perfectly. I have some problem with the virtual nic. It only works in bridge bode. I'd like to use use it in nat mode and internal network (I mean a second nic).
I set the nic with NAT I boot openbsd it seems does not work. I mean none packets goes out of the vm. If run tcpdump on freebsd I can't see any packets. I ping on OpenBSD the gateway but reply something like "host is down". If I ping google "no route to host".
The vir interface is configure as static ip (192.168.0.5) of the lan of the gateway (192.168.0.1). Freebsd ip is 192.168.0.6.
On freebsd 13.1 I installed pf, then I tried to disable it but obviously the problem persist because there isn't any traffic.
Virtualbox is installed from packages and not ports. The freebsd is upgraded. Packages are upgraded.
on /etc/rc.conf I have
Code:
vboxnet_enable="YES"
on /boot/loader.conf I have
Code:
vboxdrv_load="YES"

My user is in the vboxusers group.
The file /dev/vboxnetctl is 0660 and root:vboxusers and I have the same permissions on /etc/devfs.conf

Also I have an other problem if I create a virtualnet. I click on "add" button to add a new vnet.. and it works. Vbox add a vnet named vboxnet01 with class 192.168.56.1/24 but if I change the class in 192.168.1.1/24 does not work and I receive E_ACCESSDENIED (0x80070005) error. I checked the following file log ~/.config/VirtualBox/VBoxSVC.log and I found the following two lines (copied by hand):

Bash:
NetIfAdpCtl: failed to create process for /usr/local/lib/virtualbox/VBoxNetAdpCtl: iStats=38 enmReason=1
Failed to EnableStaticIpConfig with rc=VERR_ACCESS_DENIED

I tried to run /usr/local/lib/virtualbox/VBoxNetAdpCtl as user and as root in the following way:
Code:
# ./VBoxNetAdpCtl vboxnet8 192.168.2.1 netmask 255.255.255.0
and I have a:
Code:
Permission denied
(even if I'm root). But it works as user or as root like this:
Code:
#./VBoxNetAdpCtl vboxnet6 add

Well. Just to summarize the problems are two:
1) NAT does not work
2) I can't modify any virtual network, just add.

Thanks very much for any help.
 
Try by configuring
  • the vboxnetX "Host-only" network in "Host Network Manager" (Ctrl + H), and disabled the DHCP server
  • in the VMs "Network" settings
    "Adapter 1" NAT
    "Adapter 2" "Host-only Adapter"
  • in the OpenBSD VMs guest network interface configuration hostname.if(5) files for each interface
    Adapter 1: DHCP
    Adapter 2: static IPv4 of the "Host-only"s subnet
See tutorial

Ignore the "Port-forwarding" chapter.

I ping on OpenBSD the gateway but reply something like "host is down". If I ping google "no route to host".
ping might not work due to NAT limitations (see below). But I can't tell for sure, haven't investigated it thoroughly.

Internet browsing from the VM, and i.e. ssh the VM from the host over the "Host-only" subnet assigned IP address is possible.

VirtualBox Manual 6.3.3. NAT Limitations
Rich (BB code):
 There are some limitations of NAT mode which users should be aware of, as follows:

    ICMP protocol limitations. Some frequently used network debugging tools, such as ping or traceroute, rely on the ICMP
protocol for sending and receiving messages. Oracle VM VirtualBox ICMP support has some limitations, meaning ping should
work but some other tools may not work reliably.

From the VMs log:
Code:
NAT: ICMP/ping not available (could not open ICMP socket, error VERR_ACCESS_DENIED)
 
Also I have an other problem if I create a virtualnet. I click on "add" button to add a new vnet.. and it works. Vbox add a vnet named vboxnet01 with class 192.168.56.1/24 but if I change the class in 192.168.1.1/24 does not work and I receive E_ACCESSDENIED (0x80070005) error.
You need to override the predefined range (see chapter 6.7. Host-Only Networking below).

Create file /usr/local/etc/vbox/networks.conf, set the range, execute ./VBoxNetAdpCtl ..., close and reopen VirtualBox Manager, open "Host Network Manager".
Code:
*  192.168.1.1/24
Mind the asterisk (*) at the beginning of the line

/usr/local/bin/virtualbox will read under /usr/local/etc/vbox configuration files;
Rich (BB code):
     30 if [ -d /etc/vbox ]; then
     31     >&2 cat <<-EOH
     32         WARNING: Directory /etc/vbox found, but ignored. VirtualBox
     33                  configuration files are stored in /usr/local/etc/vbox/.
     34         EOH
     35 fi


6.7. Host-Only Networking
On Linux, macOS and Solaris Oracle VM VirtualBox will only allow IP addresses in 192.168.56.0/21 range to be assigned to host-only adapters. For IPv6 only link-local addresses are allowed. If other ranges are desired, they can be enabled by creating /etc/vbox/networks.conf and specifying allowed ranges there. For example, to allow 10.0.0.0/8 and 192.168.0.0/16 IPv4 ranges as well as 2001::/64 range put the following lines into /etc/vbox/networks.conf:

* 10.0.0.0/8 192.168.0.0/16
* 2001::/64


Lines starting with the hash # are ignored. The following example allows any addresses, effectively disabling range control:

* 0.0.0.0/0 ::/0


If the file exists, but no ranges are specified in it, no addresses will be assigned to host-only adapters. The following example effectively disables all ranges:

# No addresses are allowed for host-only adapters
 
hello again, thanks so much for your help. Now everything it works. Just I use "NAT network" and not "NAT" on the first nic.
just for future users with same problems. Here what I've done.
run vboxnet because I don't know why doesn't run at boot. But I'll solve that too.
Rich (BB code):
# /usr/local/etc/rc.d/vboxnet start
created the file /usr/local/etc/vbox/networks.conf with the private ips I wanted.
Rich (BB code):
$ cat /usr/local/etc/vbox/networks.conf
* 192.168.10.1/24
modified the natnetwork and enabled the dhcp server with
Rich (BB code):
$ VBoxManage natnetwork list
and then
Rich (BB code):
$ VBoxManage natnetwork modify --netname natnet01 --enable --dhcp on --ipv6 off
here what I have on the guest openbsd vm:
Rich (BB code):
user@vm 15:38:22 ~ $ cat /etc/hostname.em0
dhcp
user@vm 15:38:25 ~ $ cat /etc/hostname.em1
inet 192.168.10.2 0xffffff00

em0 = nat
em1 = host-only


Also I creted a new vm with openbsd and the two vms can comunicate each other.
 
Back
Top