Page 1 of 1

[Solved] Change the <HostOnlyInterface/> setting using VBoxManage

Posted: 28. Sep 2018, 03:24
by SaveMeTenMinutes
Is there a way to update the

Code: Select all

<HostOnlyInterface/>
to

Code: Select all

<HostOnlyInterface name="vboxnet0"/>
using

Code: Select all

VBoxManage modifyvm ...
:?: Thanks in advance.

Re: Change the <HostOnlyInterface/> setting using VBoxManage

Posted: 28. Sep 2018, 03:26
by socratis
SaveMeTenMinutes wrote:Is there a way to update
Update it where exactly? What do you want to do, and why?

Re: Change the <HostOnlyInterface/> setting using VBoxManage

Posted: 28. Sep 2018, 03:39
by SaveMeTenMinutes
I have this shell script:

Code: Select all

VM='centos7-i386';

VBoxManage createhd --variant Standard --filename /home/VirtualBox/boxes/${VM}/disks/${VM}.vdi --size 12288;

#VBoxManage list ostypes;

VBoxManage createvm --name ${VM} --ostype "RedHat" --register --basefolder /home/VirtualBox/boxes/${VM};

VBoxManage storagectl ${VM} --name "SATA Controller" --add sata --controller IntelAHCI;
VBoxManage storageattach ${VM} --storagectl "SATA Controller" --port 0 --device 0 --type hdd --medium /home/VirtualBox/boxes/${VM}/disks/${VM}.vdi;

VBoxManage storagectl ${VM} --name "IDE Controller" --add ide;
VBoxManage storageattach ${VM} --storagectl "IDE Controller" --port 0 --device 0 --type dvddrive --medium /home/VirtualBox/iso/CentOS-7-i386-Minimal-1804---VagrantBox-SaveMeTenMinutes.iso;

VBoxManage hostonlyif create;

VBoxManage modifyvm ${VM} --nic1 nat --nictype1 82540EM --nicproperty1 name="VirtualBox NAT Ethernet Adapter";

[b]VBoxManage modifyvm ${VM} --nic2 hostonly --nictype2 82540EM --nicproperty2 name="VirtualBox Host-Only Ethernet Adapter";[/b]

VBoxManage modifyvm ${VM} --audio none;
VBoxManage modifyvm ${VM} --ioapic on;
VBoxManage modifyvm ${VM} --boot1 dvd --boot2 disk --boot3 none --boot4 none;
VBoxManage modifyvm ${VM} --memory 1024 --vram 16;
VBoxManage modifyvm ${VM} --clipboard bidirectional;

VBoxHeadless -s ${VM};
But when I run the last line I get this:

Code: Select all

Oracle VM VirtualBox Headless Interface 5.2.18
(C) 2008-2018 Oracle Corporation
All rights reserved.

Error: failed to start machine. Error message: Nonexistent host networking interface, name '' (VERR_INTERNAL_ERROR)
Only if I go and update the settings file:

Code: Select all

<?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="namespaceurl" version="1.16-linux">
  <Machine uuid="{d8621a5b-4e28-44dc-b128-b7378a4e5293}" name="centos7-i386" OSType="RedHat" snapshotFolder="Snapshots" lastStateChange="2018-09-27T22:31:20Z">
    <MediaRegistry>
      <HardDisks>
        <HardDisk uuid="{982a5a7a-8c91-4fef-8d40-2f60fff531d4}" location="/home/VirtualBox/boxes/centos7-i386/disks/centos7-i386.vdi" format="VDI" type="Normal"/>
      </HardDisks>
      <DVDImages>
        <Image uuid="{1dcddbc2-1066-4480-a997-b83b1f6f2586}" location="/home/VirtualBox/iso/CentOS-7-i386-Minimal-1804---VagrantBox-SaveMeTenMinutes.iso"/>
      </DVDImages>
    </MediaRegistry>
    <Hardware>
      <CPU>
        <PAE enabled="true"/>
        <LongMode enabled="true"/>
        <X2APIC enabled="true"/>
        <HardwareVirtExLargePages enabled="false"/>
      </CPU>
      <Memory RAMSize="1024"/>
      <Boot>
        <Order position="1" device="DVD"/>
        <Order position="2" device="HardDisk"/>
        <Order position="3" device="None"/>
        <Order position="4" device="None"/>
      </Boot>
      <Display VRAMSize="16"/>
      <BIOS>
        <IOAPIC enabled="true"/>
      </BIOS>
      <Network>
        <Adapter slot="0" enabled="true" MACAddress="08002771038E" type="82540EM">
          <DisabledModes>
            <HostOnlyInterface name="vboxnet1"/>
            <GenericInterface driver="">
              <Property name="name" value="VirtualBox NAT Ethernet Adapter"/>
            </GenericInterface>
          </DisabledModes>
          <NAT/>
        </Adapter>
        <Adapter slot="1" enabled="true" MACAddress="0800278AF631" type="82540EM">
          <DisabledModes>
            <InternalNetwork name="vboxnet0"/>
            <GenericInterface driver="">
              <Property name="hostonlyinterfacename" value="vboxnet0"/>
              <Property name="name" value="VirtualBox Host-Only Ethernet Adapter"/>
            </GenericInterface>
            <NATNetwork name="NatNetwork"/>
          </DisabledModes>
          <HostOnlyInterface/>
        </Adapter>
      </Network>
      <AudioAdapter driver="ALSA" enabledIn="false" enabledOut="false"/>
      <Clipboard mode="Bidirectional"/>
    </Hardware>
    <StorageControllers>
      <StorageController name="SATA Controller" type="AHCI" PortCount="30" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
        <AttachedDevice type="HardDisk" hotpluggable="false" port="0" device="0">
          <Image uuid="{982a5a7a-8c91-4fef-8d40-2f60fff531d4}"/>
        </AttachedDevice>
      </StorageController>
      <StorageController name="IDE Controller" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
        <AttachedDevice passthrough="false" type="DVD" hotpluggable="false" port="0" device="0">
          <Image uuid="{1dcddbc2-1066-4480-a997-b83b1f6f2586}"/>
        </AttachedDevice>
      </StorageController>
    </StorageControllers>
  </Machine>
</VirtualBox>
and change the

Code: Select all

<HostOnlyInterface/>
tag to

Code: Select all

<HostOnlyInterface name="vboxnet0"/>
then the box starts up fine.

Re: Change the <HostOnlyInterface/> setting using VBoxManage

Posted: 28. Sep 2018, 05:06
by SaveMeTenMinutes
This is the output from

Code: Select all

VBoxManage showvminfo ${VM};

Code: Select all

Name:            centos7-i386
Groups:          /
Guest OS:        Red Hat (32-bit)
UUID:            9af24d7c-1de5-4ccc-bb8b-98366c79f84b
Config file:     /home/VirtualBox/boxes/centos7-i386/centos7-i386/centos7-i386.vbox
Snapshot folder: /home/VirtualBox/boxes/centos7-i386/centos7-i386/Snapshots
Log folder:      /home/VirtualBox/boxes/centos7-i386/centos7-i386/Logs
Hardware UUID:   9af24d7c-1de5-4ccc-bb8b-98366c79f84b
Memory size:     128MB
Page Fusion:     off
VRAM size:       8MB
CPU exec cap:    100%
HPET:            off
Chipset:         piix3
Firmware:        BIOS
Number of CPUs:  1
PAE:             on
Long Mode:       off
Triple Fault Reset: off
APIC:            on
X2APIC:          on
CPUID Portability Level: 0
CPUID overrides: None
Boot menu mode:  message and menu
Boot Device (1): Floppy
Boot Device (2): DVD
Boot Device (3): HardDisk
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          off
BIOS APIC mode:  APIC
Time offset:     0ms
RTC:             local time
Hardw. virt.ext: on
Nested Paging:   on
Large Pages:     off
VT-x VPID:       on
VT-x unr. exec.: on
Paravirt. Provider: Default
Effective Paravirt. Provider: KVM
State:           powered off (since 2018-09-28T01:34:20.000000000)
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address:
Teleporter Password:
Tracing Enabled: off
Allow Tracing to Access VM: off
Tracing Configuration:
Autostart Enabled: off
Autostart Delay: 0
Default Frontend:
Storage Controller Name (0):            SATA Controller
Storage Controller Type (0):            IntelAhci
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  30
Storage Controller Port Count (0):      30
Storage Controller Bootable (0):        on
Storage Controller Name (1):            IDE Controller
Storage Controller Type (1):            PIIX4
Storage Controller Instance Number (1): 0
Storage Controller Max Port Count (1):  2
Storage Controller Port Count (1):      2
Storage Controller Bootable (1):        on
SATA Controller (0, 0): /home/VirtualBox/boxes/centos7-i386/disks/centos7-i386.vdi (UUID: 863f7d8e-db1d-4d56-88a9-441527772857)
IDE Controller (0, 0): /home/VirtualBox/iso/CentOS-7-i386-Minimal-1804---VagrantBox-SaveMeTenMinutes.iso (UUID: d7d4d4d9-98c4-4038-8576-0319fc4f78d9)
NIC 1:           MAC: 0800279FCE59, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 2:           MAC: 0800273F8066, Attachment: Host-only Interface '', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
Pointing Device: PS/2 Mouse
Keyboard Device: PS/2 Keyboard
UART 1:          disabled
UART 2:          disabled
UART 3:          disabled
UART 4:          disabled
LPT 1:           disabled
LPT 2:           disabled
Audio:           enabled (Driver: ALSA, Controller: AC97, Codec: STAC9700)
Audio playback:  disabled
Audio capture: disabled
Clipboard Mode:  disabled
Drag and drop Mode: disabled
VRDE:            disabled
USB:             disabled
EHCI:            disabled
XHCI:            disabled

USB Device Filters:

<none>

Bandwidth groups:  <none>

Shared folders:  <none>

Capturing:          not active
Capture audio:      not active
Capture screens:    0
Capture file:       /home/VirtualBox/boxes/centos7-i386/centos7-i386/centos7-i386.webm
Capture dimensions: 1024x768
Capture rate:       512 kbps
Capture FPS:        25
Capture options:

Guest:

Configured memory balloon size:      0 MB

Code: Select all

root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --nic2 hostonly --nictype2 82540EM --nicproperty2 name="VirtualBox Host-Only Ethernet Adapter" --nicproperty2 hostonlyinterfacename="vboxnet0";
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --nic2 none;
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --nic2 hostonly --nictype2 82540EM --nicproperty2 name="VirtualBox Host-Only Ethernet Adapter";
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --audio none;
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --ioapic on;
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --boot1 dvd --boot2 disk --boot3 none --boot4 none;
VBoxManage modifyvm ${VM} --memory 1024 --vram 16;^[[3~
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --memory 1024 --vram 16;
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --memory 1024 --vram 16;
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# VBoxManage modifyvm ${VM} --clipboard bidirectional;
root@localhost(3.10.0-862.9.1.el7.x86_64):/root
# vboxmanage showvminfo ${VM}
Name:            centos7-i386
Groups:          /
Guest OS:        Red Hat (32-bit)
UUID:            9af24d7c-1de5-4ccc-bb8b-98366c79f84b
Config file:     /home/VirtualBox/boxes/centos7-i386/centos7-i386/centos7-i386.vbox
Snapshot folder: /home/VirtualBox/boxes/centos7-i386/centos7-i386/Snapshots
Log folder:      /home/VirtualBox/boxes/centos7-i386/centos7-i386/Logs
Hardware UUID:   9af24d7c-1de5-4ccc-bb8b-98366c79f84b
Memory size:     1024MB
Page Fusion:     off
VRAM size:       16MB
CPU exec cap:    100%
HPET:            off
Chipset:         piix3
Firmware:        BIOS
Number of CPUs:  1
PAE:             on
Long Mode:       off
Triple Fault Reset: off
APIC:            on
X2APIC:          on
CPUID Portability Level: 0
CPUID overrides: None
Boot menu mode:  message and menu
Boot Device (1): DVD
Boot Device (2): HardDisk
Boot Device (3): Not Assigned
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          on
BIOS APIC mode:  APIC
Time offset:     0ms
RTC:             local time
Hardw. virt.ext: on
Nested Paging:   on
Large Pages:     off
VT-x VPID:       on
VT-x unr. exec.: on
Paravirt. Provider: Default
Effective Paravirt. Provider: KVM
State:           powered off (since 2018-09-28T01:34:20.000000000)
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address:
Teleporter Password:
Tracing Enabled: off
Allow Tracing to Access VM: off
Tracing Configuration:
Autostart Enabled: off
Autostart Delay: 0
Default Frontend:
Storage Controller Name (0):            SATA Controller
Storage Controller Type (0):            IntelAhci
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  30
Storage Controller Port Count (0):      30
Storage Controller Bootable (0):        on
Storage Controller Name (1):            IDE Controller
Storage Controller Type (1):            PIIX4
Storage Controller Instance Number (1): 0
Storage Controller Max Port Count (1):  2
Storage Controller Port Count (1):      2
Storage Controller Bootable (1):        on
SATA Controller (0, 0): /home/VirtualBox/boxes/centos7-i386/disks/centos7-i386.vdi (UUID: 863f7d8e-db1d-4d56-88a9-441527772857)
IDE Controller (0, 0): /home/VirtualBox/iso/CentOS-7-i386-Minimal-1804---VagrantBox-SaveMeTenMinutes.iso (UUID: d7d4d4d9-98c4-4038-8576-0319fc4f78d9)
NIC 1:           MAC: 0800279FCE59, Attachment: NAT, Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 1 Settings:  MTU: 0, Socket (send: 64, receive: 64), TCP Window (send:64, receive: 64)
NIC 2:           MAC: 0800273F8066, Attachment: Host-only Interface '', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
Pointing Device: PS/2 Mouse
Keyboard Device: PS/2 Keyboard
UART 1:          disabled
UART 2:          disabled
UART 3:          disabled
UART 4:          disabled
LPT 1:           disabled
LPT 2:           disabled
Audio:           disabled
Audio playback:  disabled
Audio capture: disabled
Clipboard Mode:  Bidirectional
Drag and drop Mode: disabled
VRDE:            disabled
USB:             disabled
EHCI:            disabled
XHCI:            disabled

USB Device Filters:

<none>

Bandwidth groups:  <none>

Shared folders:  <none>

Capturing:          not active
Capture audio:      not active
Capture screens:    0
Capture file:       /home/VirtualBox/boxes/centos7-i386/centos7-i386/centos7-i386.webm
Capture dimensions: 1024x768
Capture rate:       512 kbps
Capture FPS:        25
Capture options:

Guest:

Configured memory balloon size:      0 MB
I need to change this part:
NIC 2: MAC: 0800273F8066, Attachment: Host-only Interface '', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
It needs to become:
NIC 2: MAC: 0800273F8066, Attachment: Host-only Interface 'vboxnet0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none

Re: Change the <HostOnlyInterface/> setting using VBoxManage

Posted: 28. Sep 2018, 06:25
by socratis
You need to issue another command right after the
SaveMeTenMinutes wrote:
VBoxManage hostonlyif create;
VBoxManage modifyvm ${VM} --nic2 hostonly --nictype2 82540EM --nicproperty2 name="VirtualBox Host-Only Ethernet Adapter";
which specifies which HostOnly network your card should be attached to:
SaveMeTenMinutes wrote:
VBoxManage hostonlyif create;
VBoxManage modifyvm ${VM} --nic2 hostonly --nictype2 82540EM --nicproperty2 name="VirtualBox Host-Only Ethernet Adapter";
VBoxManage modifyvm ${VM} --hostonlyadapter2 vboxnet0
See ch. 8.8.2 Networking Settings for more details.

Re: Change the <HostOnlyInterface/> setting using VBoxManage

Posted: 28. Sep 2018, 08:33
by SaveMeTenMinutes
Thank you, socratis, that's exactly what I was looking for!

Re: Change the <HostOnlyInterface/> setting using VBoxManage

Posted: 28. Sep 2018, 08:36
by socratis
Glad I could help. Marking as [Solved].