Open a Port from VirtualBox

If you have a VirtualBox VM, you may want to open a port in order to ssh into a Linux VM, view your development website on your main PC, etc. This is done by port forwarding, which means the port on your VM will appear as an open port on the host machine.

Open the settings panel of the VM (Machine - Settings)
Navigate to the Network tag, press the advanced dropdown, and press Port Forwarding.
This will open a list of opened ports. It should be empty. Press the green + button on the right to add a new port.
I will be opening port 22 in order to SSH into my VM. I set the host port to 8022, meaning that my ssh port will be 8022 on the machine running VirtualBox. The guest port is 22, since this is the default ssh port on the virtual machine. I also gave it a name to remember it later.
Now you can press "ok" to save your settings, and close the settings panel. If you go back to the host machine, you should be able to connect to your open port now using the host port. Here, I was able to ssh into my virtual machine using the 8022 port I set earlier.

Comments