Banner of Host-Only Network: Access Local Websites in VirtualBox

Access Local Websites: Linux to Windows in VirtualBox


Category: Linux

Date: 20 days ago
Views: 119


How to Access a Local Website from a Linux Host Machine to a Windows Guest Machine in VirtualBox

If you're running a Windows virtual machine (VM) inside VirtualBox on your Linux host, you might want to access a local website or service hosted on the guest machine. In this guide, we'll walk through the steps to set up communication between your Linux host and Windows guest using a host-only network.

Prerequisites

VirtualBox: Ensure that you have VirtualBox installed on your Linux host machine.

Windows Guest VM: Set up a Windows virtual machine in VirtualBox.

Steps:

1. Create a Host-Only Network in VirtualBox:

• Open VirtualBox and go to File > Host Network Manager.

VirtualBox Network Manager
VirtualBox Network Manager

• In the Host-Only Networks tab, click Create. A host-only network will be created with the default name "vboxnet0".

Host-Only Network Creation
Host-Only Network Creation

• By default, it will have an IPv4 prefix of 192.168.56.1/24 and DHCP enabled.

2. Configure the Virtual Machine Settings:

• Open the settings for your Windows guest virtual machine.

• Keep the first network adapter (usually NAT) as it is.

• Enable the second network adapter and select Attached to: "Host-Only Adapter".

• Choose the network name "vboxnet0" (the one you created in step 1).

Host-Only Adapter
Host-Only Network Adapter

3. Start Your Virtual Machine:

• Now, whenever you run your Windows guest virtual machine, it will be connected to the host-only network.

• On the host machine (Linux), you'll find a local network for communication between the host and guest machines. in my case I got something like this

    
$ ip a | grep -oP '(?<=inet |addr:)(?:\d+\.){3}\d+'
127.0.0.1	# loopback adress
192.168.1.5	# my machine local IP adress in my Local network
192.168.56.1	# this is the IP address of the host-only network
192.168.56.101	# my machine IP adress in the host-only network
    

If I have a website running in my Linux (host) machine on port 8081 then I can access it in the guest VM like this 192.168.56.1:8081 or 192.168.56.101:8081 or 192.168.1.5:8081 when I am connected to a local network



119 views

Previous Article Next Article

0 Comments, latest

No comments.