Ping Virtual Box(Guest) from Windows(Host)

In this article we will set up our VirtualBox network interface that is easily accessible by the host machine. We will ping the VirtualBox from the host machine and also make sure VirtualBox is able to access the Internet.

Lets get started!!!!!

Environment used

  • Windows 10 [Host]

VirtualBox set up

Provided you have VirtualBox set up already done, I will be going through the steps here to set up the Network interfaces in Virtual box.

In the Oracle VM VirtualBox Manager we will add the Network Adapter i.e Host-Only Adapter. Check image below.

VM Manager settings

Above setting is done to so that our VM will share the host only network i.e. our Windows 10 host.

Login to your VM and now we will assign a static IP to our VM

ifconfig

This will list down all the network interfaces in the VM. Output would be similar like below:-

ifconfig

Observe the IP address of eth0 interface. Now, try check the IP address of your host [Windows 10] by running command ipconfig. You will observe that the IPv4 DNS range is different from what is shown in above image.

Right now, If you ping the VM machine from Host machine it will not work because of the above reason. So, now we will assign a static IP to our VM so that both host and VM share the same DNS IP range and able to communicate with each other even if there is no Internet in town.

Assign static IP to VM

cd ~/etc/netplan
ls

There will be a file called 01-network-manager-all.yaml. We need to update this file with below content.

# Let NetworkManager manage all devices on this system
network:
version: 2
renderer: NetworkManager
ethernets:
enp0s3:
addresses: [192.168.56.108/24]
dhcp4: false

We are basically applying the IP 192.168.56.108 to our VM.

sudo netplan apply

Bingo we are done.Really!!!!

Yes, now is the time to ping the VM from Host machine.

Go to your host machine terminal and run the command below

ping 192.168.56.108

Most probably, you will see the output as below

Pinging 192.168.56.108 with 32 bytes of data:
Reply from 192.168.56.108: bytes=32 time<1ms TTL=64
Reply from 192.168.56.108: bytes=32 time<1ms TTL=64
Reply from 192.168.56.108: bytes=32 time<1ms TTL=64
Reply from 192.168.56.108: bytes=32 time=1ms TTL=64
Ping statistics for 192.168.56.108:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms

Thats it!!! We have made it.~~~Congratulations. ~~~

Now you can even do ssh or ftp from your host machine to VM machine without the need of Internet.

If you want to access the Internet on your VM too….then we have a solution for that too here.

If this post was helpful, please click the clap 👏 button below a few times to show your support! ⬇⬇

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store