HowTo Start VBox Net Interfaces At Boot & Attach Servers
Posted: 23. Jul 2015, 09:08
How To Start VBox Network Interfaces At/During Boot, and Attach Dependent Servers/Services/Daemons etc.
When VirtualBox for Mac OS X is installed (on Mac OS X host computer), it will automatically also load below daemon service in MacOSX system:
/Library/LaunchDaemons/org.virtualbox.startup.plist
Above daemon service initiator executes below bash script .sh file, to unload+load vbox kexts/drivers:
"/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
Default script was not able to load host-only network interface(s) during boot, in two Apple computers where i have tried+tested.
So i had to modify default script file, into below "VirtualBoxStartup.sh" script file, with help of other online users, to load vbox related kexts/drivers at boot time, in MacOSX host computer, and, also to start/load vboxnet* host-only network interfaces/adapters during boot time, and, also to attach various other (including 3rd party) services/daemons with vbox net interface which depend on existence of active vbox net interface(s).
1st make backup copy of your original "VirtualBoxStartup.sh" file, then copy below script source-codes from shown "VirtualBoxStartup.sh" file section.
I prefer to use "BlueFish" text editor for editing such text or source-code files. Get it from http://sourceforge.net/projects/bluefish/
Install it. Open the "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" file in BlueFish, and delete all previous code lines, and paste entire content of below shown "VirtualBoxStartup.sh" file, into your own "VirtualBoxStartup.sh" file which is opened inside your BlueFish text-editor.
Before saving in BlueFish, use below "chown" command in Terminal 1st, to change script file's OWNERSHIP, so that you can save your changes:
sudo chown Your-user-id-in-Mac "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh"
after saving your changes into the script file, you will have to change file's ownership back to mac osx system, so that system can run/execute it at/during boot time, by running below command in Terminal:
sudo chown root:wheel "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh"
VirtualBoxStartup.sh file:
In mac osx Terminal, you can test this entire script, or test portion of it's various functions, if its working or not.
Below command will do: kext/driver unloading/loading, Network Interface disable/enable, 3rd Party Service unloading/loading, etc:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart_with_nifs_and_3rdPrtySvc
you can test this script, if kexts/drivers unloading/loading, Network Interface enable/disable, etc are working or not:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart_with_nifs
you can test this script, if kexts/drivers unloading/loading is working or not:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
You can also test the above bash script with these other parameters:
stop
stop_also_nifs
stop_also_nifs_and_3rdPrtySvc
start
start_with_nifs
start_with_nifs_and_3rdPrtySvc
launchd
launchd_with_nifs
launchd_with_nifs_and_3rdPrtySvc
status
To Start VBox (kexts and) Network Interfaces & 3rd Party Services At Boot:
Download "Lingon" from http://sourceforge.net/projects/lingon/ website. Install it. Start Lingon.
Inside Lingon, locate "org.virtualbox.startup" under USER DAEMONS section.
In "What" textbox, it suppose to show data code like below:
"/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
change above data codes into below data code:
"/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart_with_nifs_and_3rdPrtySvc
then click on any other service/daemon once, lingon will auto initiate & display Mac OSX's privilege user password & consent window, to help saving the changes, so enter an Admin level privileged user-name/id & that user's pass, click on ok button.
Reboot once, or execute below command once in Terminal:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart_with_nifs_and_3rdPrtySvc
Then in Terminal, run below dns test command:
dig @192.168.56.1 in TLSA _443._tcp.www.isc.org. +dnssec
If above dns query result shows "ad" in flag, and "NOERROR" in status, then it is indicating, unbound DNS daemon/service is responding to DNS query sent toward vboxnet0 interface ip address 192.168.56.1, and DNSSEC based validated DNS resolving is also working fine.
Note: If you do not have a local unbound or bind DNSSEC enabled DNS Server running-at or listening-to vboxnet0 interface ip-adrs 192.168.56.1, then above command will not work. See next post, how you can load "unbound" dnssec dns server in host OS, for host itself and for all VMs.
So from now on, VBox kexts & vbox network interfaces (NIFS) & 3rd party services (if specified inside appropriate section of bash script) will auto start at boot (a.k.a. during boot of Mac OSX host computer).
These codes are tested & passed in my Mac OSX computer:
at the time of writing these posts & testing & developing this script for virtualvox...
i have used VirtualBox-4.3.30-101610-OSX, my test seems to have worked, and i will use at-least for a week.
VirtualBox v5.0.0-101573 (July, 2015) seems to be buggy or very likely buggy, when 2nd adapter (a host-only) was added into a guest/VM, then VM's both adapters loose DHCP features & stop working !
VirtualBox v5.0.0-RC1-101436 (July, 2015) could not even load the VM which was created using v4.3.28 !
In VirtualBox v4.3.28 r100309 (2015), my test was successful (i observed no bugs related to this posting/context), and i used it also for a week, fully functional.
My host computer running Mac OS X, it is Yosemite 10.10.4 (July, 2015).
Script file also worked on Mac OSX 10.10.3.
Related tests were also done on one of my VM, which guest-OS is WinXP Professional (32bit), with SP3.
Disclaimer: Some of the codes & paragraphs of information i have shown here, are directly copied from my own notes, or from other authors (either from their websites, or from contributed info webpages on various project websites, blogging websites, etc), or from Manual/Document webpages, or from public mailing list, or from public IRC channels, etc. And i have modified some of them slightly. Worked on my computers. But you may have different result as overall configuration might not be same, so use with caution & with your own decision & risk.
When VirtualBox for Mac OS X is installed (on Mac OS X host computer), it will automatically also load below daemon service in MacOSX system:
/Library/LaunchDaemons/org.virtualbox.startup.plist
Above daemon service initiator executes below bash script .sh file, to unload+load vbox kexts/drivers:
"/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
Default script was not able to load host-only network interface(s) during boot, in two Apple computers where i have tried+tested.
So i had to modify default script file, into below "VirtualBoxStartup.sh" script file, with help of other online users, to load vbox related kexts/drivers at boot time, in MacOSX host computer, and, also to start/load vboxnet* host-only network interfaces/adapters during boot time, and, also to attach various other (including 3rd party) services/daemons with vbox net interface which depend on existence of active vbox net interface(s).
1st make backup copy of your original "VirtualBoxStartup.sh" file, then copy below script source-codes from shown "VirtualBoxStartup.sh" file section.
I prefer to use "BlueFish" text editor for editing such text or source-code files. Get it from http://sourceforge.net/projects/bluefish/
Install it. Open the "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" file in BlueFish, and delete all previous code lines, and paste entire content of below shown "VirtualBoxStartup.sh" file, into your own "VirtualBoxStartup.sh" file which is opened inside your BlueFish text-editor.
Before saving in BlueFish, use below "chown" command in Terminal 1st, to change script file's OWNERSHIP, so that you can save your changes:
sudo chown Your-user-id-in-Mac "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh"
after saving your changes into the script file, you will have to change file's ownership back to mac osx system, so that system can run/execute it at/during boot time, by running below command in Terminal:
sudo chown root:wheel "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh"
VirtualBoxStartup.sh file:
Code: Select all
#!/bin/sh
# $Id: VirtualBoxStartup.sh 90723 2013-11-18 20:25:07Z fmehnert $
## @file
# Startup service for loading the kernel extensions and select the set of VBox
# binaries that matches the kernel architecture.
#
#
# Copyright (C) 2007-2013 Oracle Corporation
#
# This file is part of VirtualBox Open Source Edition (OSE), as
# available from http://www.virtualbox.org. This file is free software;
# you can redistribute it and/or modify it under the terms of the GNU
# General Public License (GPL) as published by the Free Software
# Foundation, in version 2 as it comes in the "COPYING" file of the
# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
#
#
# Copyright (C) 2015 tErik (at3erik at outlook dot com) (remov prev 3).
# tErik releasing this modified script code, under same License
# as original script file, which is, GPL v2 License.
#
# Code is released with below License agreement as well.
#
# The MIT License (MIT)
# Copyright (C) 2015 tErik, (at3erik at outlook dot com) (remov prev 3).
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
#
VBoxRestart=0
VBoxNIF=0
VBox3rdPrtySvc=0
if false; then
. /etc/rc.common
else
# Fake the startup item functions we're using.
ConsoleMessage()
{
if [ "$1" != "-f" ] ; then
printf "$@\n"
else
shift
printf "Fatal error: $@\n"
exit 1;
fi
}
MsgWithoutEndNL()
{
printf "$@"
}
RunService()
{
case "$1" in
"status")
ShowStatus
exit $?;
;;
"start")
StartService
exit $?;
;;
"start_with_nifs")
VBoxNIF=1
StartService
exit $?;
;;
"start_with_nifs_and_3rdPrtySvc")
VBoxNIF=1
VBox3rdPrtySvc=1
StartService
exit $?;
;;
"stop")
StopService
exit $?;
;;
"stop_also_nifs")
VBoxNIF=1
StopService
exit $?;
;;
"stop_also_nifs_and_3rdPrtySvc")
VBoxNIF=1
VBox3rdPrtySvc=1
StopService
exit $?;
;;
"restart")
VBoxRestart=1
RestartService
exit $?;
;;
"restart_with_nifs")
VBoxNIF=1
VBoxRestart=1
RestartService
exit $?;
;;
"restart_with_nifs_and_3rdPrtySvc")
VBoxNIF=1
VBox3rdPrtySvc=1
VBoxRestart=1
RestartService
exit $?;
;;
"launchd")
VBoxRestart=1
if RestartService; then
while true;
do
sleep 3600
done
fi
exit $?;
;;
"launchd_with_nifs")
VBoxNIF=1
VBoxRestart=1
if RestartService; then
while true;
do
sleep 3600
done
fi
exit $?;
;;
"launchd_with_nifs_and_3rdPrtySvc")
VBoxNIF=1
VBox3rdPrtySvc=1
VBoxRestart=1
if RestartService; then
while true;
do
sleep 3600
done
fi
exit $?;
;;
**)
printf "Error: Unknown action '$1'\n"
printf " Supported parameters are:\n"
printf " start, start_with_nifs, start_with_nifs_and_3rdPrtySvc,\n"
printf " stop, stop_also_nifs, stop_also_nifs_and_3rdPrtySvc,\n"
printf " restart, restart_with_nifs, restart_with_nifs_and_3rdPrtySvc,\n"
printf " launchd, launchd_with_nifs, launchd_with_nifs_and_3rdPrtySvc\n"
printf " status\n"
exit 1;
esac
}
fi
StartService()
{
VBOX_RC=0
VBoxNInm=0
VBoxNIip=0
VBOXDRV="VBoxDrv"
VBOXUSB="VBoxUSB"
#VBoxHInm=""
VBoxStr=""
VBoxCmdOut=""
VBoxChkDhcp=0
VBoxLoc="/Applications/VirtualBox.app/Contents/MacOS"
VBoxFindThis=""
MsgWithoutEndNL "Loading VirtualBox (vbox) kexts/drivers"; if [ "$VBoxNIF" -eq 1 ] ; then MsgWithoutEndNL " & net interfaces"; fi; ConsoleMessage "..."
#
# Switch the binaries to the right architecture.
#
VBOX_ARCH=`uname -m`
if test "$VBOX_ARCH" = "x86_64"; then
VBOX_ARCH="amd64"
else
VBOX_ARCH="x86"
fi
for VBOX_TRG in `ls /Applications/VirtualBox.app/Contents/MacOS/*-${VBOX_ARCH}`;
do
VBOX_LINKNAME=`echo "$VBOX_TRG" | sed -e 's|-'"${VBOX_ARCH}"'$||' `
if test "$VBOX_LINKNAME" != "$VBOX_TRG"; then
rm -f "$VBOX_LINKNAME"
if ! /bin/ln -vh "$VBOX_TRG" "$VBOX_LINKNAME"; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: /bin/ln -vh $VBOX_TRG $VBOX_LINKNAME failed"
VBOX_RC=1
else
ConsoleMessage " /bin/ln -vh $VBOX_TRG $VBOX_LINKNAME failed"
fi
fi
else
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: Script error VBOX_TRG=$VBOX_TRG"
VBOX_RC=1
else
ConsoleMessage " Script error VBOX_TRG=$VBOX_TRG"
fi
fi
done
#
# Check that all the directories exist first.
#
if [ ! -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" ] ; then
ConsoleMessage " Error: /Library/Application Support/VirtualBox/${VBOXDRV}.kext is missing"
VBOX_RC=1
fi
if [ ! -d "/Library/Application Support/VirtualBox/${VBOXUSB}.kext" ] ; then
ConsoleMessage " Error: /Library/Application Support/VirtualBox/${VBOXUSB}.kext is missing"
VBOX_RC=1
fi
if [ ! -d "/Library/Application Support/VirtualBox/VBoxNetFlt.kext" ] ; then
ConsoleMessage " Error: /Library/Application Support/VirtualBox/VBoxNetFlt.kext is missing"
VBOX_RC=1
fi
if [ ! -d "/Library/Application Support/VirtualBox/VBoxNetAdp.kext" ] ; then
ConsoleMessage " Error: /Library/Application Support/VirtualBox/VBoxNetAdp.kext is missing"
VBOX_RC=1
fi
#
# Check that no drivers are currently running.
# (Try stop the service if this is the case.)
#
if [ "$VBOX_RC" -eq 0 ] ; then
if kextstat -lb org.virtualbox.kext.VBoxDrv 2>&1 | grep -q org.virtualbox.kext.VBoxDrv; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: ${VBOXDRV}.kext is already loaded"
VBOX_RC=1
else
ConsoleMessage " ${VBOXDRV}.kext is already loaded"
fi
fi
if kextstat -lb org.virtualbox.kext.VBoxUSB 2>&1 | grep -q org.virtualbox.kext.VBoxUSB; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: ${VBOXUSB}.kext is already loaded"
VBOX_RC=1
else
ConsoleMessage " ${VBOXUSB}.kext is already loaded"
fi
fi
if kextstat -lb org.virtualbox.kext.VBoxNetFlt 2>&1 | grep -q org.virtualbox.kext.VBoxNetFlt; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: VBoxNetFlt.kext is already loaded"
VBOX_RC=1
else
ConsoleMessage " VBoxNetFlt.kext is already loaded"
fi
fi
if kextstat -lb org.virtualbox.kext.VBoxNetAdp 2>&1 | grep -q org.virtualbox.kext.VBoxNetAdp; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: VBoxNetAdp.kext is already loaded"
VBOX_RC=1
else
ConsoleMessage " VBoxNetAdp.kext is already loaded"
fi
fi
fi
#
# Load the drivers.
#
if [ "$VBOX_RC" -eq 0 ] ; then
ConsoleMessage " Loading ${VBOXDRV}.kext..."
if ! kextload "/Library/Application Support/VirtualBox/${VBOXDRV}.kext"; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: Failed to load /Library/Application Support/VirtualBox/${VBOXDRV}.kext"
VBOX_RC=1
else
ConsoleMessage " ${VBOXDRV}.kext is already loaded"
fi
else
ConsoleMessage " ${VBOXDRV}.kext is now loaded."
fi
ConsoleMessage " Loading ${VBOXUSB}.kext..."
if ! kextload -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" "/Library/Application Support/VirtualBox/${VBOXUSB}.kext"; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: Failed to load /Library/Application Support/VirtualBox/${VBOXUSB}.kext"
VBOX_RC=1
else
ConsoleMessage " ${VBOXUSB}.kext is already loaded"
fi
else
ConsoleMessage " ${VBOXUSB}.kext is now loaded."
fi
ConsoleMessage " Loading VBoxNetFlt.kext..."
if ! kextload -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" "/Library/Application Support/VirtualBox/VBoxNetFlt.kext"; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: Failed to load /Library/Application Support/VirtualBox/VBoxNetFlt.kext"
VBOX_RC=1
else
ConsoleMessage " VBoxNetFlt.kext is already loaded"
fi
else
ConsoleMessage " VBoxNetFlt.kext is now loaded."
fi
ConsoleMessage " Loading VBoxNetAdp.kext..."
if ! kextload -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" "/Library/Application Support/VirtualBox/VBoxNetAdp.kext"; then
if [ "$VBoxRestart" -eq 0 ] ; then
ConsoleMessage " Error: Failed to load /Library/Application Support/VirtualBox/VBoxNetAdp.kext"
VBOX_RC=1
else
ConsoleMessage " VBoxNetAdp.kext is already loaded"
fi
else
ConsoleMessage " VBoxNetAdp.kext is now loaded."
fi
if [ "$VBOX_RC" -ne 0 ] ; then
# unload the drivers (ignoring failures)
ConsoleMessage " Ignoring failures & unloading all vbox kexts/drivers..."
kextunload -b org.virtualbox.kext.VBoxNetAdp
kextunload -b org.virtualbox.kext.VBoxNetFlt
kextunload -b org.virtualbox.kext.VBoxUSB
kextunload -b org.virtualbox.kext.VBoxDrv
ConsoleMessage " done (unloaded kexts)."
if [ "$VBoxRestart" -ge 1 ] ; then
VBOX_RC=0
fi
fi
fi
#
# Set the error on failure.
#
if [ "$VBOX_RC" -ne 0 ] ; then
if [ "$VBoxRestart" -eq 0 ] ; then
MsgWithoutEndNL " Run this script again to reload all vbox kexts"; if [ "$VBoxNIF" -eq 1 ] ; then MsgWithoutEndNL " (and vboxnet* interfaces)"; fi; ConsoleMessage "."
ConsoleMessage -f VirtualBox
VBoxNInm=0
VBoxNIip=0
#VBoxHInm=""
VBoxStr=""
VBoxCmdOut=""
VBoxChkDhcp=0
VBoxLoc=""
VBoxFindThis=""
exit $VBOX_RC
fi
fi
#
# Enable vboxnet* network interface, (after VBox kexts are loaded successfully),
# and, when vboxnet* is/are also pre-defined inside virtualbox.
# Codes added by tErik (at2erik at outlook dot com) (remove previous 2).
# Also thanks to other code contributors @irc.freenode.net #bash
# contributors: izabera, geirha (gina.it.ntnu.no), mattcen,
# osse, Riviera, kurahaupo_
#
if [ "$VBOX_RC" -eq 0 ] && [ "$VBoxNIF" -eq 1 ] ; then
VBoxNInm=-1
VBoxNIip=55
# for working with vboxnet0 (192.168.56.x) to vboxnet3 (192.168.59.x)
while [ "$VBoxNInm" -lt 3 ] ; do
let "VBoxNInm+=1"
let "VBoxNIip+=1"
VBoxChkDhcp=0
ConsoleMessage " Checking if vboxnet$VBoxNInm network interface is pre-defined in VBox..."
VBoxStr="^Name[:][[:space:]]*vboxnet${VBoxNInm}$"
if ${VBoxLoc}/VBoxManage list hostonlyifs | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is found pre-defined in vbox."
ConsoleMessage " modifying vboxnet${VBoxNInm}, and changing to 192.168.${VBoxNIip}.1 ip-addresss..."
${VBoxLoc}/VBoxManage hostonlyif ipconfig vboxnet$VBoxNInm --ip 192.168.${VBoxNIip}.1 --netmask 255.255.255.0
VBoxChkDhcp=1
else
ConsoleMessage " vboxnet$VBoxNInm is not pre-defined in vbox."
ConsoleMessage " so creating a new interface in vbox..."
${VBoxLoc}/VBoxManage hostonlyif create
ConsoleMessage " Renaming new interface into vboxnet${VBoxNInm}, and adding (192.168.${VBoxNIip}.1) IP-addresss..."
${VBoxLoc}/VBoxManage hostonlyif ipconfig vboxnet$VBoxNInm --ip 192.168.${VBoxNIip}.1 --netmask 255.255.255.0
VBoxChkDhcp=1
fi
# Checking for vboxnet* DHCP presence, and if necessary, Adding & Activating DHCP:
if [ "$VBoxChkDhcp" -eq 1 ] ; then
VBoxStr="^IP[:][[:space:]]*192\.168\.${VBoxNIip}\.1$"
if ${VBoxLoc}/VBoxManage list dhcpservers | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " DHCP (192.168.${VBoxNIip}.1) for vboxnet$VBoxNInm is pre-defined in vbox."
else
ConsoleMessage " DHCP (192.168.${VBoxNIip}.1) for vboxnet$VBoxNInm is not pre-defined in vbox,\r\n so Adding DHCP server with vboxnet${VBoxNInm}..."
${VBoxLoc}/VBoxManage dhcpserver modify --ifname vboxnet$VBoxNInm --ip 192.168.${VBoxNIip}.1 --netmask 255.255.255.0 --lowerip 192.168.${VBoxNIip}.100 --upperip 192.168.${VBoxNIip}.199 --enable
ConsoleMessage " done (added dhcp ip-adrs)."
fi
ConsoleMessage " checking if DHCP (for vboxnet${VBoxNInm}) is active or not..."
VBoxStr="IP[:][[:space:]]192\.168\.${VBoxNIip}\.1[[:space:]].*?Enabled[:][[:space:]](No|Yes)"
VBoxCmdOut=$(${VBoxLoc}/VBoxManage list dhcpservers | tr -s '\r\n\t\ ' " " | grep -aiEo "$VBoxStr")
VBoxFindThis=".*Yes$"
if [[ $VBoxCmdOut =~ $VBoxFindThis ]] ; then
ConsoleMessage " DHCP server for vboxnet$VBoxNInm is already enabled/activated."
else
ConsoleMessage " DHCP vboxnet$VBoxNInm is not enabled/activated, so enabling..."
${VBoxLoc}/VBoxManage dhcpserver modify --ifname vboxnet$VBoxNInm --ip 192.168.${VBoxNIip}.1 --netmask 255.255.255.0 --lowerip 192.168.${VBoxNIip}.100 --upperip 192.168.${VBoxNIip}.199 --enable
VBoxCmdOut=$(${VBoxLoc}/VBoxManage list dhcpservers | tr -s '\r\n\t\ ' " " | grep -aiEo "$VBoxStr")
if [[ $VBoxCmdOut =~ $VBoxFindThis ]] ; then
ConsoleMessage " DHCP server for vboxnet$VBoxNInm is now enabled/activated."
else
ConsoleMessage " DHCP server for vboxnet$VBoxNInm could not be enabled/activated!"
# you may add code here for forcefully enable DHCP for vbox net interface.
fi
fi
fi
# Check presence of vbox net interface in system, and, Activate/Enable if necessary:
ConsoleMessage " Checking presence of vboxnet$VBoxNInm net interface in system..."
VBoxStr="^vboxnet${VBoxNInm}[:][[:space:]]"
if ! /sbin/ifconfig | grep -aiEoq "${VBoxStr}"; then
ConsoleMessage " vboxnet$VBoxNInm interface is not detected by this script!\r\n and, not enabled/up for usage on this system!"
# you may add code here for forcefully enable vbox net interface in vbox & in system.
else
ConsoleMessage " vboxnet$VBoxNInm interface is detected+present in system.\r\n checking, if its enabled/up for use or not..."
VBoxStr="^vboxnet${VBoxNInm}[:][[:space:]]flags[\=][[:alnum:]]*[\<](UP[,\>]|[[:alnum:]]*[,]UP[,\>])"
if /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm interface is already enabled+Up for vbox & system."
else
ConsoleMessage " vboxnet$VBoxNInm interface is not yet enabled+Up for system, enabling..."
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm up 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
if /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm interface is now enabled/up for usage on this system."
else
ConsoleMessage " vboxnet$VBoxNInm interface exists but could not be enabled/up for this system!"
# you may add code here for forcefully enable vbox net interface in vbox & in system.
fi
fi
fi
done
fi
# END OF vboxnet* interface Loading section
VBoxNInm=0
VBoxNIip=0
#VBoxHInm=""
VBoxStr=""
VBoxCmdOut=""
VBoxChkDhcp=0
VBoxLoc=""
VBoxFindThis=""
if [ "$VBOX_RC" -eq 0 ] && [ "$VBox3rdPrtySvc" -eq 1 ] ; then
Start3rdPartyOrOtherServices
fi
VBoxRestart=0
VBoxNIF=0
VBox3rdPrtySvc=0
}
StopService()
{
VBOX_RC=0
VBoxNInm=0
VBoxNIip=0
VBOXDRV="VBoxDrv"
VBOXUSB="VBoxUSB"
#VBoxHInm=""
VBoxStr=""
VBoxCmdOut=""
VBoxLoc="/Applications/VirtualBox.app/Contents/MacOS"
VBoxFindThis=""
if [ "$VBox3rdPrtySvc" -eq 1 ] ; then
Stop3rdPartyOrOtherServices
fi
if [ "$VBoxRestart" -gt 0 ] ; then
MsgWithoutEndNL "Attempt #${VBoxRestart}: Stop+Unload VirtualBox (vbox) kexts"; if [ "$VBoxNIF" -eq 1 ] ; then MsgWithoutEndNL " & network interfaces"; fi; ConsoleMessage "..."
else
MsgWithoutEndNL "Stopping/Disabling VirtualBox (vbox)"; if [ "$VBoxNIF" -eq 1 ] ; then MsgWithoutEndNL " net interfaces & vbox"; fi; ConsoleMessage " kexts..."
fi
if kextstat -lb org.virtualbox.kext.VBoxUSB 2>&1 | grep -q org.virtualbox.kext.VBoxUSB; then
ConsoleMessage " Unloading ${VBOXUSB}.kext..."
if ! kextunload -m org.virtualbox.kext.VBoxUSB; then
ConsoleMessage " Error: Failed to unload VBoxUSB.kext"
VBOX_RC=1
ConsoleMessage " Ignoring failures & attempting to unload VBoxUSB.kext again..."
kextunload -b org.virtualbox.kext.VBoxUSB
ConsoleMessage " done (unloaded kext)."
else
ConsoleMessage " ${VBOXUSB}.kext is now unloaded."
fi
fi
#
# Disable vboxnet* network interfaces, because VBox kexts are about to be unloaded.
# added by tErik (at2erik at outlook dot com) (remove previous 2).
#
if [ "$VBoxNIF" -eq 1 ] ; then
VBoxNInm=-1
VBoxNIip=55
# for working with vboxnet0 (192.168.56.x) to vboxnet3 (192.168.59.x)
while [ "$VBoxNInm" -lt 3 ] ; do
let "VBoxNInm+=1"
let "VBoxNIip+=1"
ConsoleMessage " Checking if vboxnet$VBoxNInm net interface is enabled/active/up in this system..."
VBoxStr="^vboxnet${VBoxNInm}[:][[:space:]]"
if /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is found in system. Checking if it is up/down..."
VBoxStr="^vboxnet${VBoxNInm}[:][[:space:]]flags[\=][[:alnum:]]*[\<](UP[,\>]|[[:alnum:]]*[,]UP[,\>])"
if /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is active/up in system.\r\n disabling it in system..."
else
ConsoleMessage " vboxnet$VBoxNInm is not active/up in system, (so it is disabled/down).\r\n attempting to disable it anyway in system..."
fi
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm down 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm inet 192.168.${VBoxNIip}.1 -alias 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
if ! /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is now disabled/down in system."
else
ConsoleMessage " attempting to disable vboxnet$VBoxNInm (192.168.${VBoxNIip}.1) in system, again..."
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm down 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm inet 192.168.${VBoxNIip}.1 -alias 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm destroy 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
if ! /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is now disabled/down in system."
else
ConsoleMessage " vboxnet$VBoxNInm could not be disabled in system!"
fi
fi
else
ConsoleMessage " vboxnet$VBoxNInm interface, not found in system."
fi
done
VBoxNInm=3
VBoxNIip=59
# for working with vboxnet4 (192.168.60.x) to vboxnet15 (192.168.71.x)
while [ "$VBoxNInm" -lt 15 ] ; do
let "VBoxNInm+=1"
let "VBoxNIip+=1"
ConsoleMessage " Checking if vboxnet$VBoxNInm net interface already enabled/active in this system..."
VBoxStr="^vboxnet${VBoxNInm}[:][[:space:]]"
if /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is found in system."
VBoxStr="^vboxnet${VBoxNInm}[:][[:space:]]flags[\=][[:alnum:]]*[\<](UP[,\>]|[[:alnum:]]*[,]UP[,\>])"
if /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is active/up in system.\r\n disabling it in system..."
else
ConsoleMessage " vboxnet$VBoxNInm is not active/up in system, (so it is disabled/down).\r\n attempting to disable it anyway in system..."
fi
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm down 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm inet 192.168.${VBoxNIip}.1 -alias 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
if ! /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is now disabled/down in system."
else
ConsoleMessage " attempting to disable vboxnet$VBoxNInm (192.168.${VBoxNIip}.1) in system, again..."
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm down 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm inet 192.168.${VBoxNIip}.1 -alias 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
VBoxCmdOut=$(/sbin/ifconfig vboxnet$VBoxNInm destroy 2>&1 | expand | sed -e 's/^/ /')
if [[ "$VBoxCmdOut" != "" ]] ; then ConsoleMessage "$VBoxCmdOut"; VBoxCmdOut=""; fi
if ! /sbin/ifconfig | grep -aiEoq "$VBoxStr"; then
ConsoleMessage " vboxnet$VBoxNInm is now disabled/down in system."
else
ConsoleMessage " vboxnet$VBoxNInm could not be disabled in system!"
fi
fi
else
ConsoleMessage " vboxnet$VBoxNInm interface, not found in system."
fi
done
fi
# END of vboxnet* interface Unloading section
if kextstat -lb org.virtualbox.kext.VBoxNetFlt 2>&1 | grep -q org.virtualbox.kext.VBoxNetFlt; then
ConsoleMessage " Unloading VBoxNetFlt.kext..."
if ! kextunload -m org.virtualbox.kext.VBoxNetFlt; then
ConsoleMessage " Error: Failed to unload VBoxNetFlt.kext"
VBOX_RC=1
ConsoleMessage " Ignoring failures & attempting to unload VBoxNetFlt.kext again..."
kextunload -b org.virtualbox.kext.VBoxNetFlt
ConsoleMessage " done (unloaded kext)."
else
ConsoleMessage " VBoxNetFlt.kext is now unloaded."
fi
fi
if kextstat -lb org.virtualbox.kext.VBoxNetAdp 2>&1 | grep -q org.virtualbox.kext.VBoxNetAdp; then
ConsoleMessage " Unloading VBoxNetAdp.kext..."
if ! kextunload -m org.virtualbox.kext.VBoxNetAdp; then
ConsoleMessage " Error: Failed to unload VBoxNetAdp.kext"
VBOX_RC=1
ConsoleMessage " Ignoring failures & attempting to unload VBoxNetAdp.kext again..."
kextunload -b org.virtualbox.kext.VBoxNetAdp
ConsoleMessage " done (unloaded kext)."
else
ConsoleMessage " VBoxNetAdp.kext is now unloaded."
fi
fi
# This must come last because of dependencies.
if kextstat -lb org.virtualbox.kext.VBoxDrv 2>&1 | grep -q org.virtualbox.kext.VBoxDrv; then
ConsoleMessage " Unloading ${VBOXDRV}.kext..."
if ! kextunload -m org.virtualbox.kext.VBoxDrv; then
ConsoleMessage " Error: Failed to unload VBoxDrv.kext"
VBOX_RC=1
ConsoleMessage " Ignoring failures & attempting to unload VBoxDrv.kext again..."
kextunload -b org.virtualbox.kext.VBoxDrv
ConsoleMessage " done (unloaded kext)."
else
ConsoleMessage " ${VBOXDRV}.kext is now unloaded."
fi
fi
VBoxNInm=0
VBoxNIip=0
#VBoxHInm=""
VBoxStr=""
VBoxCmdOut=""
VBoxLoc=""
VBoxFindThis=""
# Set the error on failure.
if [ "$VBOX_RC" -ne 0 ] ; then
if [ "$VBoxRestart" -eq 0 ] ; then
MsgWithoutEndNL " Run this script again to unload vbox kexts, and then reload all vbox kexts"; if [ "$VBoxNIF" -eq 1 ] ; then MsgWithoutEndNL " (and vboxnet* interfaces)"; fi; ConsoleMessage "."
ConsoleMessage -f VirtualBox
VBoxRestart=0
VBoxNIF=0
VBox3rdPrtySvc=0
exit $VBOX_RC
fi
fi
}
RestartService()
{
StopService
if [ "$VBoxRestart" -gt 0 ] ; then
let "VBoxRestart++"
fi
StopService
if [ "$VBoxRestart" -gt 0 ] ; then
let "VBoxRestart++"
fi
StartService
}
Start3rdPartyOrOtherServices()
{
# by tErik
# Load/Run Scripts or Programs or Services, which depend on VBox Kexts
# and Net-Interfaces:
#
# Note: Only add or enable or modify here those specific services/daemons,
# which must have to be modified/updated by using a specific command,
# to activate support for vbox net interfaces.
#
ConsoleMessage "Starting/Loading 3rd-party or other scripts/programs/services/servers,\r\n which depend on VBox kexts & network-interfaces..."
# Load Unbound DNSSEC DNS Server/Resolver section:
if ps ax | grep -v grep | grep -aiEoq "/usr/local/opt/unbound/sbin/unbound"; then
ConsoleMessage " Unbound DNSSEC DNS Server is already running.\r\n Enabling unbound support for vbox net interfaces..."
/usr/local/opt/unbound/sbin/unbound-control -q -c /usr/local/etc/unbound/unbound_for_vbox.conf reload
if ps ax | grep -v grep | grep -aiEoq "/usr/local/opt/unbound/sbin/unbound"; then
ConsoleMessage " done."
else
ConsoleMessage " failed to load unbound service!"
fi
else
ConsoleMessage " Unbound DNSSEC DNS Server is not running.\r\n Starting unbound server with support for vbox net interfaces..."
/usr/local/opt/unbound/sbin/unbound -d -c /usr/local/etc/unbound/unbound_for_vbox.conf &
if ps ax | grep -v grep | grep -aiEoq "/usr/local/opt/unbound/sbin/unbound"; then
ConsoleMessage " done."
else
ConsoleMessage " failed to load unbound service!"
fi
fi
# END of Unbound DNSSEC DNS Server/Resolver (Load) section
ConsoleMessage " done (starting/loading 3rd-party/other services)."
# END of Load/Run Scripts or Programs or Services, which use VBox Kexts & Net-Interfaces.
}
Stop3rdPartyOrOtherServices()
{
# by tErik
# Stop 3rd-Party Scripts or Programs or Services, which depend on VBox
# Kexts & Net-Interfaces:
#
# Note: Do not stop-or-disable here those services/daemons, which are not
# affected when any vbox net interface is down or does-not-exist or
# removed. That is, those services are smart enough to respond
# properly for missing/disabled/removed vbox net-interfaces.
#
ConsoleMessage "Stopping/Disabling 3rd-party or other scripts/programs/services/servers,\r\n which depend on VBox kexts & network-interfaces..."
# Unload Unbound DNSSEC DNS Server/Resolver, section:
# /usr/local/opt/unbound/sbin/unbound-control -q -c /usr/local/etc/unbound/unbound.conf reload
# We are not removing vboxnet0 IP-address support from Unbound,
# because Unbound service can still function, even if vboxnet0 is removed from system.
# END of Unbound DNSSEC DNS Server/Resolver (Unload) section
ConsoleMessage " done (stopping/disabling 3rd-party/other services)."
# END of Stop 3rd-Party Scripts or Programs or Services, which use VBox Kexts & Net-Interfaces.
}
ShowStatus()
{
# by tErik
# Show/Display running condition/STATUS & presence of vbox kexts
# & vbox network interfaces, etc,
# and also show running STATUS of related 3rd party services.
#
#VBOX_RC=0
VBoxNoKext=0
VBoxNInm=0
VBoxNIip=0
VBOXDRV="VBoxDrv"
VBOXUSB="VBoxUSB"
#VBoxHInm=""
VBoxStr=""
VBoxCmdOut=""
VBoxChkDhcp=0
VBoxLoc="/Applications/VirtualBox.app/Contents/MacOS"
VBoxFindThis=""
VBoxNIF=1
ConsoleMessage "Displaying VirtualBox (vbox) kexts/drivers & NIF (net interfaces) running status...";
#
# Check if the vbox kext directories exist or not.
#
if [ ! -d "/Library/Application Support/VirtualBox/${VBOXDRV}.kext" ] ; then
ConsoleMessage " /Library/Application Support/VirtualBox/${VBOXDRV}.kext is missing !"
VBoxNoKext=1
else
ConsoleMessage " /Library/Application Support/VirtualBox/${VBOXDRV}.kext is found."
fi
if [ ! -d "/Library/Application Support/VirtualBox/${VBOXUSB}.kext" ] ; then
ConsoleMessage " /Library/Application Support/VirtualBox/${VBOXUSB}.kext is missing !"
VBoxNoKext=1
else
ConsoleMessage " /Library/Application Support/VirtualBox/${VBOXUSB}.kext is found."
fi
if [ ! -d "/Library/Application Support/VirtualBox/VBoxNetFlt.kext" ] ; then
ConsoleMessage " /Library/Application Support/VirtualBox/VBoxNetFlt.kext is missing !"
VBoxNoKext=1
else
ConsoleMessage " /Library/Application Support/VirtualBox/VBoxNetFlt.kext is found."
fi
if [ ! -d "/Library/Application Support/VirtualBox/VBoxNetAdp.kext" ] ; then
ConsoleMessage " /Library/Application Support/VirtualBox/VBoxNetAdp.kext is missing !"
VBoxNoKext=1
else
ConsoleMessage " /Library/Application Support/VirtualBox/VBoxNetAdp.kext is found."
fi
#
# Check, if kexts/drivers are currently running or not.
#
if kextstat -lb org.virtualbox.kext.VBoxDrv 2>&1 | grep -q org.virtualbox.kext.VBoxDrv; then
ConsoleMessage " ${VBOXDRV}.kext is already loaded in system"
else
ConsoleMessage " ${VBOXDRV}.kext is not loaded in system"
fi
if kextstat -lb org.virtualbox.kext.VBoxUSB 2>&1 | grep -q org.virtualbox.kext.VBoxUSB; then
ConsoleMessage " ${VBOXUSB}.kext is already loaded in system"
else
ConsoleMessage " ${VBOXUSB}.kext is not loaded in system"
fi
if kextstat -lb org.virtualbox.kext.VBoxNetFlt 2>&1 | grep -q org.virtualbox.kext.VBoxNetFlt; then
ConsoleMessage " VBoxNetFlt.kext is already loaded in system"
else
ConsoleMessage " VBoxNetFlt.kext is not loaded in system"
fi
if kextstat -lb org.virtualbox.kext.VBoxNetAdp 2>&1 | grep -q org.virtualbox.kext.VBoxNetAdp; then
ConsoleMessage " VBoxNetAdp.kext is already loaded in system"
else
ConsoleMessage " VBoxNetAdp.kext is not loaded in system"
fi
ConsoleMessage " Status of network interfaces in system...\r\n Each network interface begins with * symbol..."
VBoxStr=$(ifconfig -av | expand | sed -E -e 's/^([[:alnum:]]+\:) flags\=/* \1 flags=/g' -e 's/^[\ ]+(nd6 options\=[[:alnum:]]+)\<([[:alnum:]\,]*)\>/\1, \2/g' -e 's/^[\ ]+options.+//g' -e 's/^[\ ]+media\:.+$//g' -e 's/^[\ ]+eflags\=.+$//g' -e 's/ index [[:alnum:]]+$//g' -e 's/ family\: [[:alnum:]]+ subfamily\: [[:alnum:]]+//g' -e 's/ (flags\=[[:alnum:]]+\<[[:alnum:]\,]+)\>/ \1,>/g' -e 's/ flags\=[[:alnum:]]+\<([[:alnum:]\,]*)\>/ \1/g' | tr -s '\t\f\v\b\ ' " " | sed -E -e 's/^ $//g' -e '/^$/d' -e 's/ $//g' -e 's/$/, /g' | tr -s '\r\n\t\f\v\b\ ' " " | sed -E -e 's/\, \* ([[:alnum:]])/ * \1/g' -e 's/\,[\ ]*\, /, /g' | tr -s '\ ' " " | sed -E 's/\,[\ ]*$//' )
ConsoleMessage " $VBoxStr"
#
# Check which vbox nif (network interface) is defined inside vbox settings,
# chk if dhcp is defined for those vbox nif in vbox settings,
# chk if vbox nif is available in system or not,
# chk if vbox nif is up/active/usable in system or not,
# chk if dhcp for nif is defined & working in system, or not.
#
# VBoxStr=$(${VBoxLoc}/VBoxManage list hostonlyifs)
# ... coming soon ...
# END of ShowStatus function-call
}
RunService "$1"
Below command will do: kext/driver unloading/loading, Network Interface disable/enable, 3rd Party Service unloading/loading, etc:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart_with_nifs_and_3rdPrtySvc
you can test this script, if kexts/drivers unloading/loading, Network Interface enable/disable, etc are working or not:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart_with_nifs
you can test this script, if kexts/drivers unloading/loading is working or not:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
You can also test the above bash script with these other parameters:
stop
stop_also_nifs
stop_also_nifs_and_3rdPrtySvc
start
start_with_nifs
start_with_nifs_and_3rdPrtySvc
launchd
launchd_with_nifs
launchd_with_nifs_and_3rdPrtySvc
status
To Start VBox (kexts and) Network Interfaces & 3rd Party Services At Boot:
Download "Lingon" from http://sourceforge.net/projects/lingon/ website. Install it. Start Lingon.
Inside Lingon, locate "org.virtualbox.startup" under USER DAEMONS section.
In "What" textbox, it suppose to show data code like below:
"/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart
change above data codes into below data code:
"/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart_with_nifs_and_3rdPrtySvc
then click on any other service/daemon once, lingon will auto initiate & display Mac OSX's privilege user password & consent window, to help saving the changes, so enter an Admin level privileged user-name/id & that user's pass, click on ok button.
Reboot once, or execute below command once in Terminal:
sudo "/Library/Application Support/VirtualBox/LaunchDaemons/VirtualBoxStartup.sh" restart_with_nifs_and_3rdPrtySvc
Then in Terminal, run below dns test command:
dig @192.168.56.1 in TLSA _443._tcp.www.isc.org. +dnssec
If above dns query result shows "ad" in flag, and "NOERROR" in status, then it is indicating, unbound DNS daemon/service is responding to DNS query sent toward vboxnet0 interface ip address 192.168.56.1, and DNSSEC based validated DNS resolving is also working fine.
Note: If you do not have a local unbound or bind DNSSEC enabled DNS Server running-at or listening-to vboxnet0 interface ip-adrs 192.168.56.1, then above command will not work. See next post, how you can load "unbound" dnssec dns server in host OS, for host itself and for all VMs.
So from now on, VBox kexts & vbox network interfaces (NIFS) & 3rd party services (if specified inside appropriate section of bash script) will auto start at boot (a.k.a. during boot of Mac OSX host computer).
These codes are tested & passed in my Mac OSX computer:
at the time of writing these posts & testing & developing this script for virtualvox...
i have used VirtualBox-4.3.30-101610-OSX, my test seems to have worked, and i will use at-least for a week.
VirtualBox v5.0.0-101573 (July, 2015) seems to be buggy or very likely buggy, when 2nd adapter (a host-only) was added into a guest/VM, then VM's both adapters loose DHCP features & stop working !
VirtualBox v5.0.0-RC1-101436 (July, 2015) could not even load the VM which was created using v4.3.28 !
In VirtualBox v4.3.28 r100309 (2015), my test was successful (i observed no bugs related to this posting/context), and i used it also for a week, fully functional.
My host computer running Mac OS X, it is Yosemite 10.10.4 (July, 2015).
Script file also worked on Mac OSX 10.10.3.
Related tests were also done on one of my VM, which guest-OS is WinXP Professional (32bit), with SP3.
Disclaimer: Some of the codes & paragraphs of information i have shown here, are directly copied from my own notes, or from other authors (either from their websites, or from contributed info webpages on various project websites, blogging websites, etc), or from Manual/Document webpages, or from public mailing list, or from public IRC channels, etc. And i have modified some of them slightly. Worked on my computers. But you may have different result as overall configuration might not be same, so use with caution & with your own decision & risk.