VirtualBox and VMware both create virtual machines with the NAT network type by default. If you want to run server software inside a virtual machine, you’ll need to change its network type or forward ports through the virtual NAT.

Virtual machines don’t normally need to be reachable from outside the virtual machine, so the default is fine for most people. It actually provides some security, as it isolates the virtual machine from incoming connections.

Selecting Bridged Networking

With the NAT network type, your host operating system performs network address translation. The virtual machine shares your host computer’s IP address and won’t receive any incoming traffic. You can use bridged networking mode instead — in bridged mode, the virtual machine will appear as a separate device on your network and have its own IP address.

To change a virtual machine’s network type in VirtualBox, right-click a virtual machine and select Settings. If you can’t click Settings, you’ll need to power off the virtual machine before making these change.

Select the Bridged adapter network mode in the Network settings section and click OK. For more information about each type of network mode, consult the Introduction to networking modes section in VirtualBox’s manual.

The process is similar in VMware applications. First, right-click a powered off virtual machine and select Virtual Machine Settings.

Select the Network Adapter virtual hardware device, select the Bridged network connection type, and click OK.

Forwarding Ports to a Virtual Machine

If you prefer to use NAT network mode for some reason, you can also forward ports through the virtual machine’s NAT. Note that only one of these steps is necessary – you don’t have to forward ports if you enabled bridged networking above.

At one point, you had to use the VBoxManage command to forward ports in VirtualBox, but VirtualBox now contains a simple graphical port-forwarding window. If you need to set up port forwarding with the VBoxManage command instead of using the graphical interface, you’ll find instructions for doing so in VirtualBox’s manual.

To forward ports in VirtualBox, first open a virtual machine’s settings window by selecting the Settings option in the menu.

Select the Network pane in the virtual machine’s configuration window, expand the Advanced section, and click the Port Forwarding button. Note that this button is only active if you’re using a NAT network type – you only need to forward ports if you’re using a NAT.

Use VirtualBox’s Port Forwarding Rules window to forward ports. You don’t have to specify any IP addresses – those two fields are optional.

Note: While you don’t have to enter any IP details, leaving the Host IP box blank will make VirtualBox listen on—in other words, it will accept all traffic from the local network and forward it to your virtual machine. Enter in the Host IP box and VirtualBox will only accept traffic originating on your computer—in other words, on the host operating system.

If you’re using VMware, you’ll need to use the Virtual Network Editor (vmnetcfg) application to do this. VMware Workstation users can select Edit –> Virtual Network Editor to open it.

Unfortunately, this utility is not included with VMware Player. There are methods for installing it yourself by extracting the vmnetcfg.exe file from the VMware Player installer, but I couldn’t locate the vmnetcfg.exe utility in the latest version of VMware Player, VMware Player 5.0 – it may no longer be included in the installer. If you’re using VMware Player, you can still use bridged networking mode to make your server accessible.

Remember that this is only part of the process of making the server software inside a virtual machine reachable. You’ll also need to ensure that:

  • The firewall software running inside your virtual machine isn’t blocking the connections. (You may need to allow the server program in the guest operating system’s firewall.)
  • The firewall software on your host computer isn’t blocking the connections. (This only applies to NAT mode with port forwarding – the host computer’s firewall doesn’t interfere in bridged networking mode.)
  • Your router is forwarding ports correctly – this is only necessary if you want to access the virtual machine from the Internet. (Consult our guide to forwarding ports on routers here.)
Profile Photo for Chris Hoffman Chris Hoffman
Chris Hoffman is Editor-in-Chief of How-To Geek. He's written about technology for over a decade and was a PCWorld columnist for two years. Chris has written for The New York Times and Reader's Digest, been interviewed as a technology expert on TV stations like Miami's NBC 6, and had his work covered by news outlets like the BBC. Since 2011, Chris has written over 2,000 articles that have been read more than one billion times---and that's just here at How-To Geek.
Read Full Bio »