Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

virtualbox
port
forwarding

How to allow all incoming connections to a server on VirtualBox

Talha Ashar

Networking in VirtualBox is extremely powerful, but it is often difficult to ascertain the exact configuration for the networking modes you need.

Although VirtualBox provides several network modes, none of them allow all incoming connections by default. To enable your VMVirtual Machine to allow all incoming connections, the network settings of the VM must be adjusted.

The following steps are needed to allow all incoming connections:

  1. Create the VM through VirtualBox.
  2. Adjust network settings to allow port forwarding.
  3. Add port forwarding rules.

Create the VM

The VM is created with Ubuntu (6464-bit) as the operating system and a base memory of 10241024 MB, for this tutorial. The complete specifications are shown below:

VM Specifications
VM Specifications

Note: You can use different hardware specifications for the VM, as a particular configuration is unnecessary for this walkthrough.

Network settings

Under the Settings tab for your VM, choose the Network option. VirtualBox sets the default network mode as NATNetwork Address Translation.

The illustration below shows how NAT works with VirtualBox:

NAT Networking in VMs

The issue with the NAT configuration mode is that it is not suitable when the VM needs to act as a server. Although NAT allows the VM to send traffic out to the internet, the incoming connections are not routed back to it.

Port forwarding

To allow external machines to connect to the VM, you will need to use the Port Forwarding option, as shown below:

Network Settings
Network Settings

The final step is to add a port forwarding rule that allows all incoming traffic to your VM. You can allow all incoming connections through the following rule:

Port Forwarding Rule
Port Forwarding Rule

The above rule informs VirtualBox that any external TCPTransmission Control Protocol connections to the host machine on port 80008000 should be forwarded to port 8080 of the VM.

Similarly, you can use different combinations for port numbers to create other rules for incoming connections.

RELATED TAGS

virtualbox
port
forwarding

CONTRIBUTOR

Talha Ashar
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring