Internet & Connectivityinternet-and-connectivityWiFi & Ethernetwifi-and-ethernet

How To Add A Virtual Network Switch In VirtualBox

how-to-add-a-virtual-network-switch-in-virtualbox

Adding a virtual network switch in VirtualBox is the way to connect multiple virtual machines so they can communicate on an isolated network, and VirtualBox creates that switch automatically when you assign the same Internal Network name to more than one VM. You can also use NAT Network or Host-Only modes as alternative switch-like setups, depending on whether you need outbound internet access or host-to-VM communication.

What a virtual network switch means in VirtualBox

In VirtualBox, a virtual network switch is not a separate component you install; it is a logical function that VirtualBox performs behind the scenes. When you configure two or more virtual machines with the same Internal Network name, VirtualBox automatically wires their virtual adapters together and acts as a network switch, forwarding traffic between them. This gives you a completely isolated network where VMs can talk to each other but cannot reach the host or the internet. For scenarios where you need outbound connectivity, NAT Network mode provides a switch-like environment with internet access through your host, while Host-Only mode creates a switch that also lets the host machine participate but blocks external networks by default.

Open VirtualBox and select your virtual machine

Launch VirtualBox on your host system and look at the list of virtual machines in the main window. Identify the VM you want to connect to the virtual switch, and click once to select it. Before you change any network settings, make sure that VM is powered off; VirtualBox will not let you modify adapter configurations while the machine is running, and starting with a clean state avoids conflicts.

Go to the network settings

With the VM selected, click the Settings button in the toolbar, or right-click the VM and choose Settings from the context menu. In the settings window, navigate to the Network section. Here you will see tabs for up to four network adapters, labeled Adapter 1 through Adapter 4, which are the ones configurable through the graphical interface. Each tab represents a separate virtual NIC, and you can enable or disable them independently.

Add and enable a network adapter

Choose an unused adapter tab, such as Adapter 2 if Adapter 1 is already in use. Check the Enable Network Adapter checkbox to activate that NIC. Once enabled, the dropdown menus below become active, allowing you to select the attachment type. This step is essential because an adapter that is not enabled cannot participate in any virtual network, regardless of the mode you choose.

Set up an internal network switch

From the Attached To dropdown, select Internal Network. In the Name field that appears, enter a unique name for your network, such as MyInternalNet. This name is the key to creating the virtual switch: repeat the exact same name on every other VM you want on this isolated network. When multiple active adapters share that identical name, VirtualBox wires them together and acts as a switch, so you get a private LAN where VMs can exchange data freely without any external access.

Set up a NAT network switch

If your VMs need internet access in addition to inter-VM communication, a NAT Network is the better choice. First, create the network by going to File > Tools > Network Manager in the VirtualBox main window. Click the Create button (the green plus icon) to add a new NAT Network, then click Properties (the wrench icon) to configure its CIDR address range and enable the built-in DHCP server. After saving that, return to your VM's Network settings, select an adapter tab, choose NAT Network from the Attached To dropdown, and pick the network you just created from the Name list. Repeat this on every VM that should join the same NAT switch.

Set up a host-only network switch

For a network that includes your host machine as a participant, create a Host-Only Network. Open the same Network Manager via File > Tools, then create a new Host-Only Network and open its Properties. Here you can set the adapter's IP address and configure the DHCP server, which VirtualBox enables by default for host-only networks. Once the network is defined, go to your VM's adapter tab, select Host-only Adapter from the Attached To dropdown, and choose the specific host-only network from the Name dropdown. This mode lets VMs talk to each other and to the host, but by default it blocks external internet traffic.

Apply changes and start the virtual machine

After you have configured the adapter and selected the appropriate network type, click OK to save the settings and close the window. Start the virtual machine by selecting it and clicking Start. Once the VM boots, verify connectivity by pinging another VM on the same virtual switch or checking the network settings inside the guest OS. If you used an Internal Network, the VMs should see each other immediately; with NAT Network or Host-Only, confirm that DHCP assigned addresses and that traffic flows as expected.

About the author

Hailing from the vibrant city of Sydney, Australia, Karrie Atwell is a beacon of inspiration in the realm of tech-education.

View all 77 articles by Karrie Atwell  ·  Our editorial policy

Leave a Reply

Your email address will not be published. Required fields are marked *