I use VirtualBox every day to test new apps, new operating systems, how to configure, and even how to break things.
I also use virtual machine technology to deploy servers that I use for a variety of purposes, and if I don’t configure them properly, those servers become inaccessible from my network. . When that happens, those servers are of no use to me.
To ensure that the virtual machine can be accessed from the Local Area Network (LAN), you must configure it properly.
I want to show you how to do it, so you can stop pulling your hair and wonder why it’s new WordPress deployment nowhere to be found.
Thankfully, the configuration is actually pretty easy to take care of. Let me show you what you need to do.
How to connect a VirtualBox virtual machine from your LAN
To make this work, you will need a running VirtualBox instance and a pre-existing guest virtual machine. It doesn’t matter which operating system you use as server or client, as the process is the same regardless.
That’s it. Let’s configure the network.
It’s all about the bridge
When you create (or configure) a virtual machine on VirtualBox, there is a Network section that includes tabs for each available network adapter. In most virtual machines, there will only be one adapter, called Adapter 1. In that tab, you’ll see a drop-down labeled Attached. By default, that drop-down is set to NAT.
NAT stands for Network Address Translation and is the process of mapping an IP address to another IP address by changing the header of an IP packet while it travels through the router. If you use NAT as the network adapter for the virtual machine, you will notice (when you start the virtual machine), the network on the client machine is different from the network on the host operating system. For example, your server has a network address of 192.168.1.62. If you leave your VM set to NAT, there’s a chance that the guest address will be something like 10.0.2.15.
Theoretically, if set up properly, you should be able to access address 10.0.2.15 from 192.168.1.62, but usually that’s not the case and you won’t be able to access address 10.0.2.15 from 192.168.1.62 . However, you can access 192.168.1.62 from 10.0.2.15. That’s great if you just need to get out of the internet from guests. But if your guest is a server and you need to access it from LAN, you have to change NAT to Bridge. This is the way.
And that’s all it takes to make sure your VirtualBox VMs are accessible from your LAN. Every time I set up a new virtual machine with VirtualBox, I make sure to change this setting so that my virtual machine is always ready for my network.