Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Start vboxnet0 at boot
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
GOS
Tux's lil' helper
Tux's lil' helper


Joined: 09 Sep 2010
Posts: 102
Location: Germany

PostPosted: Sun Sep 05, 2021 8:25 pm    Post subject: [SOLVED] Start vboxnet0 at boot Reply with quote

Hello,

does anyone know, how to start the Virtualbox networking interface vboxnet0 at boot (host)?

The reason is the following:

I have a virtual machine with Windows 10 without any network connection, accept a host-only network via vboxnet0. This is, because I can use the hosts printers via this host-only network. Unfortunately the host's cupsd does not listen at vboxnet0 if cupsd is started, before vboxnet0 is up.

This means I have to do an "/etc/init.d/cupsd restart" (on the host) after I started my Win-VM, because vboxnet0 is not present before.

Any ideas?


Last edited by GOS on Tue Sep 07, 2021 8:40 pm; edited 1 time in total
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3878

PostPosted: Sun Sep 05, 2021 8:39 pm    Post subject: Reply with quote

How about
If the interface is shown when you run "ip a"
Code:

ip link set vboxnet0 up

in a startup script?
Also plz include
Code:

vboxdrv vboxnetadp vboxnetflt

in
/etc/conf.d/modules
_________________
:)
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2956
Location: Edge of marsh USA

PostPosted: Mon Sep 06, 2021 2:37 am    Post subject: Reply with quote

The package virtualbox-modules automatically creates the file /usr/lib/modules-load.d/virtualbox.conf containing the list of loadable virtualbox modules.
Code:
$ cat /usr/lib/modules-load.d/virtualbox.conf
vboxdrv
vboxnetflt
vboxnetadp

Using /etc/conf.d/modules appears to be deprecated.

According to /etc/init.d/modules, modules are loaded from three specific locations:
Code:
$ grep lib /etc/init.d/modules
local dirs="/usr/lib/modules-load.d /run/modules-load.d /etc/modules-load.d"

That wasn't a scientific way to go about getting that, but I found what I was browsing for.
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
GOS
Tux's lil' helper
Tux's lil' helper


Joined: 09 Sep 2010
Posts: 102
Location: Germany

PostPosted: Mon Sep 06, 2021 9:49 am    Post subject: Reply with quote

1) Unfortunately the device vboxnet0 is not present (and not shown by "ip -a" or in "/sys/class/net") at host-boot. vboxnet0 is created when one runs the VM the first time (and then vboxnet0 is also listed in /sys/class/net).

2) Indeed, the three modules are loaded via the way figueroa mentioned. But this does not create vboxnet0 at host-boot.
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2956
Location: Edge of marsh USA

PostPosted: Mon Sep 06, 2021 12:21 pm    Post subject: Reply with quote

Head to the VirtualBox manual and look for a commandline option that might create that interface. Otherwise, you might start a small headless VM to spawn the interface.
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3878

PostPosted: Mon Sep 06, 2021 4:13 pm    Post subject: Reply with quote

Try using VboxManage command
Code:

VBoxManage hostonlyif create vboxnet0
VBoxManage dhcpserver add –ifname vboxnet0 –ip 10.10.10.1 –netmask 255.255.255.0 –lowerip 10.10.10.100 –upperip 10.10.10.200
VBoxManage dhcpserver modify –ifname vboxnet0 –enable
ip link set  vboxnet0 up
ip addr add 10.10.10.1 dev vboxnet0 #### might be needed if vboxnet0 not automatically assigned ip (when you run i"p a")

Put this in
Code:

/etc/local.d/vboxnet0.start

and see what happens.
Plz modify according to your needs.
.....And keep your fingers crossed.
_________________
:)
Back to top
View user's profile Send private message
GOS
Tux's lil' helper
Tux's lil' helper


Joined: 09 Sep 2010
Posts: 102
Location: Germany

PostPosted: Tue Sep 07, 2021 8:57 pm    Post subject: Reply with quote

Solved the problem with the flowing steps:

1) Create vboxnet0 via "VBoxManage hostonlyif create" as root. (If one do this as user, root cannot start vboxnet0 in step 2)

2) Create my own init service (MyOwnService) in "/etc/init.d" which launches "VBoxManage list vms" and which starts before net.vboxnet0. (This step secures, that vboxnet0 is listed in "/sys/class/net". That step 1 is done as root is crucial for step 2!)

3) Put MyOwnService in runlevel default.

3) Create net.vboxnet0 in /etc/init.d as symlink of net.lo and put it in runlevel default.

4) Add vboxnet0 to "/etc/conf.d/net" with the desired configuration.

Result: vboxnet0 starts with the desired configuration before cupsd does and everything works like a charm.

============================
PS: MyOwnService looks like:

#!/sbin/openrc-run

depend()
{
need localmount
after bootmisc
before net.vboxnet0
}

start()
{
ebegin "Start my own services"
/var/lib64/virtualbox/VBoxManage list vms
eend $?
}

stop()
{
ebegin "Do nothing"
eend $?
}
Back to top
View user's profile Send private message
figueroa
Advocate
Advocate


Joined: 14 Aug 2005
Posts: 2956
Location: Edge of marsh USA

PostPosted: Tue Sep 07, 2021 9:10 pm    Post subject: Reply with quote

Brilliantly done!
_________________
Andy Figueroa
hp pavilion hpe h8-1260t/2AB5; spinning rust x3
i7-2600 @ 3.40GHz; 16 gb; Radeon HD 7570
amd64/23.0/split-usr/desktop (stable), OpenRC, -systemd -pulseaudio -uefi
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum