Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Connect to a VirtualBox VM from Your LAN

· 7 min read · Home Networking

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

Yes, you can connect to a VirtualBox virtual machine from another device on your local network. The key is to change the VM's network adapter from the default NAT mode to Bridged Adapter mode, which makes the VM appear as a separate device on your LAN with its own IP address. This guide walks you through the exact steps for Windows, macOS, and Linux hosts, plus how to connect via SSH, RDP, or a web browser.

What You'll Need

  • VirtualBox installed on your host computer (any recent version).
  • A virtual machine that is already created and can boot.
  • Administrator/root access on the host to change network settings.
  • The guest OS's login credentials (username/password) or a service like SSH or RDP enabled inside the guest.
  • Another device on the same LAN (e.g., a laptop, phone, or desktop) to test the connection.

Step-by-Step

  1. Shut down the VM (or at least power it off) before changing network settings. In the VirtualBox Manager window, select the VM and click Settings (the gear icon).
  2. Go to the Network tab. In the Adapter 1 section, you'll see a dropdown labeled Attached to. By default it's usually NAT. Change it to Bridged Adapter.
  3. In the Name field (which appears when you select Bridged Adapter), choose the host's physical network interface that is connected to your LAN. On Windows this might be something like Realtek PCIe GbE Family Controller or Intel Wi-Fi 6 AX200. On macOS it's often en0 (Wi-Fi) or en1 (Ethernet). On Linux, it could be eth0, wlan0, or similar. If you're using Wi-Fi, pick the Wi-Fi adapter; if Ethernet, pick the Ethernet adapter. If you're not sure, try the one that has an IP address in your LAN range (e.g., 192.168.x.x).
  4. Click OK to save the settings. The labels may vary slightly by VirtualBox version, but the principle is the same.
  5. Start the VM. Once the guest OS boots, it should receive an IP address from your router's DHCP server, just like any other device on your LAN. To find the VM's IP address, log into the guest and run:
    - On Linux/macOS guest: ip addr or ifconfig
    - On Windows guest: ipconfig
    Look for an IPv4 address in the same subnet as your host (e.g., 192.168.1.x).
  6. From another device on the same LAN, test connectivity by pinging the VM's IP address. Open a terminal or command prompt and type: ping <VM_IP>. If you get replies, the network is working.
  7. Now connect to the service you need:
    - SSH (Linux/macOS guest): From your LAN device, run ssh username@<VM_IP>. Make sure the SSH server is installed and running in the guest (sudo apt install openssh-server on Ubuntu, or enable it in the guest's settings).
    - RDP (Windows guest): Enable Remote Desktop in the guest (Settings > System > Remote Desktop) and then from your LAN device use the built-in Remote Desktop Connection (mstsc) or an app like Microsoft Remote Desktop, entering the VM's IP.
    - Web server: If the guest runs a web server (Apache, Nginx, etc.), just open a browser on your LAN device and go to http://<VM_IP>.
  8. If you want the VM to have a static IP address so it doesn't change, configure it inside the guest OS (e.g., set a fixed IP in the guest's network settings) or set a DHCP reservation on your router based on the VM's MAC address (found in VirtualBox under Settings > Network > Advanced > MAC Address).

Common Mistakes

  • Choosing the wrong adapter in Bridged mode: If you select the wrong network interface (e.g., a virtual adapter or a disconnected one), the VM won't get a proper IP. Double-check the name matches your actual physical connection.
  • Forgetting to change the adapter before booting: Some users change settings while the VM is running, but VirtualBox may not apply them until restart. Always shut down the VM first.
  • Firewall blocking connections: The guest OS's firewall (e.g., Windows Defender Firewall, ufw on Linux) may block incoming SSH/RDP/ping. Temporarily disable it to test, then create allow rules.
  • Using NAT mode and expecting LAN access: NAT allows the VM to reach the internet but hides it from the LAN. Bridged is required for LAN visibility.
  • Assuming the VM's IP is the same as the host's: They are different. The VM gets its own IP from the router.

Tips

  • Use a static IP or DHCP reservation: This prevents the VM's IP from changing after a reboot, making it easier to connect reliably.
  • For headless VMs: If you run the VM without a GUI (using VBoxHeadless), you can still connect via SSH or RDP as long as the network is set to Bridged.
  • Test with ping first: Ping is the quickest way to confirm connectivity before trying higher-level protocols.
  • If you only need one port (e.g., SSH), you can use Port Forwarding with NAT instead: In the VM's Network settings, keep NAT, click Advanced > Port Forwarding, and add a rule like Host IP: 127.0.0.1, Host Port: 2222, Guest IP: (leave blank), Guest Port: 22. Then connect to ssh -p 2222 user@localhost from the host, but this only works from the host, not from other LAN devices. For LAN access, Bridged is the correct method.
  • On macOS hosts with Wi-Fi, Bridged mode may have limitations: Some versions of macOS restrict bridging on Wi-Fi. If you have issues, try using an Ethernet cable or use a different approach like NAT with port forwarding (but that only works from the host).

Troubleshooting

If you can't connect, follow these steps in order:

  1. Check the VM's IP address: Log into the guest and run ip addr (Linux) or ipconfig (Windows). If the IP starts with 169.254.x.x (Windows) or 10.0.2.x (Linux under NAT), the bridged adapter didn't pick up DHCP. Re-check the adapter selection.
  2. Restart the VM and the host's network: Sometimes the bridge doesn't initialize properly. Reboot the VM, and if that fails, restart the host's network adapter or the host itself.
  3. Disable the guest firewall temporarily: On Linux, run sudo ufw disable (if using ufw) or sudo systemctl stop firewalld. On Windows, turn off Windows Defender Firewall for the network profile. Then test again. If it works, re-enable the firewall and add an inbound rule for the specific port (e.g., 22 for SSH, 3389 for RDP).
  4. Check if the host firewall is blocking: On the host, ensure that VirtualBox's bridged networking isn't blocked by the host's firewall. Temporarily disable the host firewall to test, then create an exception.
  5. Verify the service is running in the guest: For SSH, check sudo systemctl status ssh. For RDP, ensure Remote Desktop is enabled in the guest's settings.
  6. If all else fails, try a different network mode: Switch back to NAT and set up port forwarding as described in Tips. This works for single-port access from the host only, but can be a fallback.

Frequently Asked Questions

Can I connect to a VM that is currently in NAT mode?

Not from other LAN devices. NAT hides the VM behind the host's IP. You can only connect from the host itself using port forwarding.

Do I need to change anything inside the guest OS?

No, the guest OS will automatically get an IP via DHCP when you switch to Bridged mode. You only need to enable the service you want to connect to (SSH, RDP, etc.) inside the guest.

What if my host uses Wi-Fi and Bridged mode doesn't work?

On some operating systems (especially macOS), bridging over Wi-Fi can be unreliable. Try using an Ethernet cable, or use NAT with port forwarding if you only need to connect from the host.

Can I give the VM a fixed IP address?

Yes, either configure a static IP inside the guest OS (e.g., in /etc/network/interfaces or Windows network settings) or set a DHCP reservation on your router based on the VM's MAC address.

Is it safe to expose a VM to the LAN?

Yes, as long as your LAN is trusted. The VM will be accessible to other devices, so make sure you have strong passwords and keep the guest OS updated. If you're concerned, you can set up a firewall on the guest to limit access.

Can I connect to the VM from the internet?

That requires port forwarding on your router, which is a different setup and involves security risks. This guide only covers LAN access.