So, I load an .ova image with packer of a minimal ubuntu linux installation. I realized after everything went through (Provisioners etc) and it successfully exported the output file. However, when loading the output image with VirtualBox I can't communicate with the box, because the box doesn't have a valid network adapter that allows me to ping it etc.

So I tried adding a bridged adapter one during the build process:

"vboxmanage": [[ "modifyvm", "{{.Name}}", "--nic2", "bridged", "--bridgeadapter2","enp0s31f6" ]]

However the machine is still not reachable. This is how it looks on the VM:

enter image description here

How can I ensure that my box is always reachable from the outside? Is adding a network bridge adapter even the right way? What am I doing wrong? I think I need the VM to have an IP like 192.168.x.x


With a bridged adapter, your VM would get its IP from the host machine's network DHCP server. This would allow it to be pinged from your internal network.

I'd also specify in your configuration that your cable is connected as so:

VBoxManage modifyvm "VM" --cableconnected1 on

Port forwarding in the VM's configuration would also work. It would allow access from the host machine's IP by just specifying the forwarded port.

To forward port 22 to 2222 you would do as so:

VBoxManage modifyvm "VM" --nic1 nat
VBoxManage modifyvm "VM" --natpf1 "guestssh,tcp,,2222,,22"
VBoxManage modifyvm "VM" --cableconnected1 on

If you want it to be accessible by the internet, you would need do port forwarding on your router to route access from your public ip:port to your internal ip:port.

enter image description here

  • Yeah, that's the problem. Despite adding a bridged adapter it does not automatically get a ip assigned. I do have to add a hostonly-adapter over the UI that is configured so that the VM can get a proper IP. Is there a way to do this over the commandline too? – Kyu96 Nov 29 '19 at 15:02
  • For creating a hostonly-adapter, you would do the following: VBoxManage modifyvm "VM name" --nic1 hostonly. More on this can be found at: virtualbox.org/manual/ch06.html. I'd need more information on the setup to be able to help you. – Aliminator Nov 29 '19 at 20:51
  • When adding [ "modifyvm", "{{.Name}}", "--nic1", "hostonly"] I am prompted with the following exception: VBoxManage: error: Nonexistent host networking interface, name '' (VERR_INTERNAL_ERROR). When I manually configure the hostonly adapter over the UI I have added a new one and selected to automatically configure the DHCP server. I am sure this can be done over the command line as well. – Kyu96 Nov 30 '19 at 2:44
  • Do you know how I can add this over the CLI? – Kyu96 Dec 1 '19 at 14:20
  • Try it after doing "vboxmanage hostonlyif create". This creates the interface. – Aliminator Dec 2 '19 at 15:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.