root@R430:~# VBoxManage modifyvm DDI-DNS94 --nic2 hostonly (必须关闭虚拟机,才可以执行)
VBoxManage: error: The machine 'DDI-DNS94' is already locked for a session (or being unlocked)
VBoxManage: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee nsISupports
VBoxManage: error: Context: "LockMachine(a->session, LockType_Write)" at line 525 of file VBoxManageModifyVM.cpp
root@R430:~#
root@R430:~# VBoxManage controlvm DDI-DNS94 poweroff (关闭虚拟机)
0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%
root@R430:~# VBoxManage hostonlyif create (添加网卡vboxnet0,再次执行会创建vboxnet1)
root@R430:~# VBoxManage modifyvm DDI-DNS94 --nic2 hostonly (添加网卡2为hostonly模式)
root@R430:~# VBoxManage modifyvm DDI-DNS94 --nic3 hostonly
root@R430:~# VBoxManage modifyvm DDI-DNS94 --nic3 none (删除网卡3的hostonly模式)
root@R430:~# VBoxManage modifyvm DDI-DNS94 --hostonlyadapter2 vboxnet0
root@R430:~# VBoxManage modifyvm DDI-DNS94 --hostonlyadapter3 vboxnet1
root@R430:~# VBoxManage startvm DDI-DNS94 (启动虚拟机)
Waiting for VM "DDI-DNS94" to power on...
VM "DDI-DNS94" has been successfully started.
root@R430:~#
备注:
创建vboxnet0 hostonly虚拟网卡vboxmanage hostonlyif create ipconfig vboxnet0 --dhcp
分配地址: VBoxManage hostonlyif ipconfig vboxnet1 --ip 192.168.200.1 --netmask 255.255.255.0
实战练习: