73
42
I use VirtualBox for my VMs. My office network setup is wireless, i.e. I connect to my company's WiFi network, which has a local DNS to resolve local names (such as something.mycompany.com going to 123.45.67.89). When I build a new VM, it can connect to the outside internet inheriting the host's connection but it doesn't resolve local names using the local DNS. So I have to go into /etc/hosts
on the VM and manually make an entry after I resolve the name on the host, which is annoying.
Is there a way to have VirtualBox automatically connect the guest to the host's DNS so that I do not have to do this manual step? My host is OSX Mountain Lion, the VMs are typically Ubuntu but I doubt that should matter.
11For further information for others: this needs to be run from the host. If your host is Windows, open a Command Prompt, cd to "C:\Program Files\Oracle\VirtualBox", and run that command. There doesn't seem to be any option in the VirtualBox Manager GUI (at least in all versions from 4.* to 5.0.20) which lets you set this any other way. – Graham – 2016-06-03T12:55:47.900
I'd like to add that you need to run this command as administrator. I tried it from my cmd and it didn't work for me, but then I ran cmd as administrator and it all worked perfectly fine. – SergeyOvchinnik – 2016-12-19T11:24:43.593
3This used to work for me, but not with Ubuntu 16.04 and the latest virtualbox for Windows – Shanteva – 2017-06-28T12:26:18.153
Not working for me as well :( – Pavel Durov – 2017-12-29T13:24:42.017
1This still works with MacOs High Sierra as the host, VirtualBox 5.2.6, running Windows 7 in the VM. – John Eikenberry – 2018-01-25T20:12:52.293
In my setting (host Windows 10, guest Ubuntu 16.04), this works with VirtualBox 5.2.8 but not with VirtualBox 5.2.14. – mkorvas – 2018-07-10T11:42:41.707
Works great for me with VirtualBox 5.2.22, OS X 10.14 host, Windows guests. – Ryan LaBarre – 2019-01-08T00:10:36.863
This is especially useful when using
docker-machine
on windows hosts! – Tamas Hegedus – 2019-08-13T13:20:11.2731I get the following errors: VBoxManage.exe: error: The machine 'DebianServer64' is already locked for a session (or being unlocked) VBoxManage.exe: error: Details: code VBOX_E_INVALID_OBJECT_STATE (0x80bb0007), component MachineWrap, interface IMachine, callee IUnknown VBoxManage.exe: error: Context: "LockMachine(a->session, LockType_Write)" at line 531 of file VBoxManageModifyVM.cpp – Ryan Augustine – 2019-11-18T12:09:15.127
1@RyanAugustine Chances are you need to shut down the Guest vm before this will work – evanr – 2020-01-01T00:39:45.733