Port Forwarding with Oracle VirtualBox
Oracle VirtualBox is a powerful virtualization tool used by developers and system administrators to create and manage virtual machines. When using the NAT (Network address translation) network mode, virtual machines are isolated from the host machine and the internet unless specific networking configurations are made. One common requirement is port forwarding, which allows access to services (like SSH, HTTP, or database servers) running on the VM from the host machine or even other devices on the network.
In this article, we’ll walk you through how to set up port forwarding in VirtualBox using the NAT network mode—a useful setup when you want to access VM services without using bridged or host-only adapters.
What is NAT Network Mode?
NAT (Network Address Translation) network mode allows VMs to access the internet by sharing the host’s IP address, while remaining isolated from the local network. This mode is useful for simulating a network of VMs behind a router-like interface.
By default, inbound traffic from the host or external network is blocked. To enable access to specific services (like an SSH or web server running on the VM), you need to configure port forwarding.
Prerequisites
- Oracle VirtualBox installed on your system
- At least one virtual machine configured and using NAT or NAT Network mode
- A service (e.g., SSH, HTTP) running inside the VM
- Optional: Guest Additions installed
Steps to Configure Port Forwarding
Step 1: Open Oracle VirtualBox Settings for the VM
Start by opening Oracle VirtualBox and selecting the virtual machine you want to configure. Click right click on it and “Settings
” to access the VM’s configuration menu. Once you’re in the settings window, follow the steps below to set up port forwarding.
- Open VirtualBox Manager
- Select your VM and click on Settings

Step 2: Configure Port Forwarding
- Navigate to the Network tab
- Click Port Forwarding

Here you can add rules:
- Name: SSH
- Protocol: TCP
- Host IP: leave empty or
127.0.0.1
- Host Port: e.g.,
2026
for SSH - Guest IP: optional, usually leave empty
- Guest Port: e.g.,
22
for SSH or3389
for RDP (Remote Desktop Access)

Step 3: Access the Service from Host
After starting the VM, you can now access the services like this:
- SSH into the VM:
ssh -p 2222 user@127.0.0.1
Tips and Notes
- Avoid port conflicts on the host.
- You can use other ports like
3306
for MySQL or5432
for PostgreSQL. - To access from external devices, set Host IP to the host’s actual IP address.