VirtualBox: How do I ping a Windows guest from the Ubuntu?

12,394

Assuming you can use the Windows 7 guest system, check its IP address. One way to do that in Windows is to open a Command Prompt (type cmd.exe in the textbox in the Start menu) and run ipconfig.

You may be told about IP addresses on multiple interfaces.

Now try pinging them from the Ubuntu system by opening a Terminal window on the Ubuntu system (Ctrl+Alt+T) and using the ping command. For example:

ping -c 5 192.168.1.120

Replace 192.168.1.120 with the IP address obtained from the Windows system with ipconfig. The -c 5 part tells ping to send 5 pings, then stop. (You can change that to whatever you want, or leave off the -c flag altogether and it will continue pinging until you stop it with Ctrl+C.)

You can repeat that with the other IP addresses, if you got more than one IP address from ipconfig in Windows. But don't ping 127.0.0.1--that IP address always refers to the local computer. (So if you ping 127.0.0.1 from your Ubuntu host machine, you're pinging your Ubuntu host machine, not the Windows guest machine.)

Please note that by default, all recent (in fact, all non-EoL) versions of Windows have a firewall enabled that blocks pings. You can turn this firewall off or customize it so it does, though. Details about how to do this would probably be considered off-topic for AskUbuntu (but on-topic for a Windows forum or a general computing support site).


This will work without Internet access, but this will not work without a network connecting the host machine to the guest machine. If you have a router that provides IP addresses via DHCP and also Internet access, and you turn that router off, then (unless the host and guest still remember their old IP's), this will not work.

But you can always set up a "host-only" network between the Windows virtual machine and the Ubuntu host machine in VirtualBox. This will permit pinging and other network activity between the host and guest machines even when there is no other network connection. To do this, click Devices > Network Adapters in the menu bar at the top of the VirtualBox virtual machine window, then select Host-only Adapter in the Attached to drop-down menu.

A VirtualBox VM's network settings, showing the "Host-only Adapter" option in the "Attached to" drop-down menu

While in the above screenshot, I am changing the setting for the single network adapter (thus disabling access to whatever other network there might be), the network settings window shown above also lets you enable another network adapter (you can have up to four easily) and make it "Host-only." Just click Adapter 2.

Share:
12,394

Related videos on Youtube

Arkaprovo Bhattacharjee
Author by

Arkaprovo Bhattacharjee

Updated on September 18, 2022

Comments

  • Arkaprovo Bhattacharjee
    Arkaprovo Bhattacharjee over 1 year

    I use Ubuntu 12.04 (64-bit) as host OS and Windows 7 as guest OS. How can I ping the Windows 7 system from Ubuntu? And is that possible even when Internet is off?