Linux & Bash: VirtualBox port forwarding

In this blog post, I'll guide you through port-forwarding services in VirtualBox to access services like SSH and Nginx from your host. It's pretty simple.

Open up the settings to your virtual machine.

Go to "Network".

Expand the advanced settings.

Click on the "Port Forwarding" button.

Add an entry.

Give the entry a name. Let's set up SSH port forwarding first.

The host port can be any number from 1 to 65535. I'm prefixing the guest port with 10 to get my host port. They can also be the same port numbers, but it may conflict with ports open on your host machine. Leave the other fields as-is.

We should also forward the HTTP port.

Now, any incoming connection to your host machine would be forwarded to your guest machine. For example, if your virtual machine has Nginx or Apache installed and listening on the default port 80, you can access the website on your host machine by visiting http://localhost:1080/