Can't ping between two guest OS in Virtualbox

9

4

Host OS: Ubuntu 13.04 VMM: Virtualbox

Guest OS1: Kali Linux Network Setting: Adapter 1 attached to NAT

Guest OS2: Windows XP Network Setting: Adapter 1 attached to NAT

Issue: can't ping between guest OS.

When i checked the IP, both the guest machines have same IP address, howz that possible..? What is the required network setting i have to apply in guest OS for networking the guest os together(ping guest1 from guest2 and vice versa)

3lokh

Posted 2014-02-02T19:20:13.713

Reputation: 213

Answers

9

Choose Bridged Adapter for the connection of all VMs; the Windows VM will come up connected, while in Kali, after booting, issue the commands

   ifconfig eth0 up
   dhclient eth0

That's all.

Edit:

The above works if the host is connected to a LAN, because both VMs will then get the necessary information (IP address, router's IP address, DNSs) from the LAN router.

If the host is not connected, you will need Host only network. Before configuring this in a VM, you must go to the panel File -> Preferences -> Network, select Host only Networks, click on the Plus sign, then the screwdriver. Under Adapter, choose:

  Ip address 192.168.56.1
  IPv4 Network Mask: 255.255.255.0

Then go to DHCP server, and choose:

  Enable Server (tick!)
  IP address 192.168.56.254
  Server Mask 255.255.255.0
  Lower Bound 192.168.56.100
  Upper Bound 192.168.56.200

Save, then go to your VM panel, choose for the Network adapter Host only. There is no need to configure the Advanced Options. Start your two VMs; Windows will already be connected, for Kali you will need to issue the same two commands as above, i.e.:

  ifconfig eth0 up
  dhclient eth0

At this point you will be connected to the Host; the host will be 192.168.56.1, and the two VMs 192.168.56.100 and 192.168.56.101 (which is which, between Windows and Kali, depends on which comes up first).

Just in case: you may also have two or more adapters on each VM, so that you can have simultaneously the Bridged adapter (or NAT) that connects you to the world, and the Host-Only adapter that connects to the host and to the other VMs. This however requires that you learn how to handle several connected adapters on Windows and Linux. It is not difficult, but it does require you to do some work.

MariusMatutiae

Posted 2014-02-02T19:20:13.713

Reputation: 41 321

don't forget sudo!! – Andy – 2014-07-15T16:42:59.243

I gave Bridged adapter for both the VM and I choose eth0 for both Bridged adapter.Right now my Host machine is not connected to any network.The windows VM came up but the Kali VM shows network disconnected..Is it may be coz the host network is down.? – 3lokh – 2014-02-02T19:31:29.137

@Nikhil It's due to the fact that the host machine is not connected. What I wrote works only in this case, because bridged adapter means the VMs will get IP address, gateway address and DNSs from your home router. If you want to connect them when the host is not connected, just le me know, I'll show you how. – MariusMatutiae – 2014-02-02T19:49:58.323

Thanks for the reply Marius, can you tel me how to connect between two VM when is host is not connected..? I'm actually doing an academic project which wants me to run an exploit from metasploit framework in Kali VM with Win XP VM as target..So i just need both VM's connected.. – 3lokh – 2014-02-02T19:54:15.980

@Nikhil Please see the edit to my post – MariusMatutiae – 2014-02-02T20:16:51.410

Hi Marius, In the Network->Adapter 1 I selected 'Attached to:Host-Only Adapter' but in 'Name' field below it shows 'Not Selected', i have no items to select there, show it shows invalid settings...can't save it – 3lokh – 2014-02-03T05:16:05.413

@Nikhil You need to complete the part on the File panel, first. – MariusMatutiae – 2014-02-03T06:06:02.577

@MariusMatutiae....Thanks a lot...It worked !!!....I actually got confused about where to look for the file panel, finally got it from Virtualbox Menu.. – 3lokh – 2014-02-03T06:50:35.097

4

Source Network Address Translation (NAT):

The "router", in this case, is the VirtualBox networking engine, which maps traffic from and to the virtual machine transparently. In VirtualBox this router is placed between each virtual machine and the host. This separation maximizes security since by default virtual machines cannot talk to each other.

If you are running a version greater than Virtualbox 4.3.0 (source) you can use the new NAT network option in the network dropdown. Networking improvements: A new Network Address Translation (NAT) option allows virtual machines to talk to each other on the same host, and communicate with the outside world

For earlier versions, internal network or host-only network is your choice. If you don't mind your VMs to be on the same physical network your host is connected to then you can use bridged adapter too.

balwa

Posted 2014-02-02T19:20:13.713

Reputation: 326

Hi, I put both on internal network and gave ip Win VM as 192.168.1.10 and in kali VM as 192.168.1.20, additionally i had to give gateway IP also in Kali VM to save the setting for which i gave the same IP 192.168.1.20. Now i refreshed the connections in both the VMs..Now also both can;t ping each other – 3lokh – 2014-02-02T19:49:53.930

Use the IP address of each other as the gateway. So on Win VM use 192.168.1.20 as the gateway and on Kali use 192.168.1.10 as the gateway. See if you can ping then. – balwa – 2014-02-02T19:56:23.863

Still no luck.... – 3lokh – 2014-02-02T20:03:05.860

I tried the same configuration in my VB. That seemed to work just fine. So the only thing that I can think of is Cable connected checked? And for kali your interfaces looks like: iface eth0 inet static address 192.168.1.20 netmask 255.255.255.0 gateway 192.168.1.10 – balwa – 2014-02-02T20:26:34.557

2

You need to configure TWO network interfaces. First, Host-only, so that the VMs could talk to the Host (the VM IP address will be 192.168.56.). Second one, a bridged connection. This will allow you to connect the VM to the external world, as well as to each other, irrespective of whether they are on the same or different hosts. This will have an IP address something like 192.168.1.. You must use this second IP for your pings or Telnets etc, which will allow you to connect the VMs to each other.

Deval Bhamare

Posted 2014-02-02T19:20:13.713

Reputation: 21

1

When you use NAT with Virtualbox each machine is on its own virtual subnet and gets its IP-address from the built-in DHCP-server in the VirtualBox. Those networks have nothing in common.

If you want to be able to let them reach each other use Bridged Mode instead. Be aware that now both VMs will be part of your "outer" network - they will get their IP-addresses from your router.

In Bridged Mode you must tell VirtualBox to which real adapter the virtual adapter should be bridged (use the same for both) and without an external DHCP-server the VMs will get no IP-addresses - you can choose fixed ones (use the same network address (not host address) you use on eth0)

You will probably have to refresh the network connection within each guest.

guntbert

Posted 2014-02-02T19:20:13.713

Reputation: 373

I gave Bridged adapter for both the VM and I choose eth0 for both Bridged adapter.Right now my Host machine is not connected to any network.The windows VM came up but the Kali VM shows network disconnected..Is it may be coz the host network is down.? – 3lokh – 2014-02-02T19:50:19.963