I have an VM (VirtualBox) with Ubuntu. Host machine is Windows 7. How can I ping my Ubuntu from host and vice versa? Trying to set "Bridged" connection type in VM settings but there is no effect, I only lose my internet connection in Ubuntu.
3 Answers
In most cases simply switching the virtual machine network adapter to bridged mode is enough to make the guest machine accessible from outside.
Sometimes it's possible for the guest machine to not automatically receive an IP which matches the host's IP range after switching to bridged mode (even after rebooting the guest machine). This is often caused by a malfunctioning or badly configured DHCP on the host network.
For example, if the host IP is 192.168.1.1
the guest machine needs to have an IP in the format 192.168.1.*
where only the last group of numbers is allowed to be different from the host IP.
You can use a terminal (shell) and type ifconfig
(ipconfig
for Windows guests) to check what IP is assigned to the guest machine and change it if required.
If the host and guest IPs do not match simply setting a static IP for the guest machine explicitly should resolve the issue.
-
3But i have one issue: there is no internet access on VM since i disable DHCP, enable bridge and assign static IP. How can i fix it or where problem could be? – Rusty Jun 28 '12 at 09:38
-
2Use `ifconfig` in Ubuntu shell to make sure that the guest's IP address is part of the host's IP range. I.e. if host IP is 192.168.1.1 make sure guest has an IP in the range 192.168.1.*. If its not in the range set the guest's IP manually to a static IP within range (i.e. 192.168.1.2). Also very important, make sure that your host (Ubuntu) is configured properly to use a gateway. If you are unsure which IP is the gateway then simply look up your Windows network settings (its usually the routers IP). – Jun 28 '12 at 14:03
-
2PS - this also works for me using the opposite configuration (Ubuntu host, Win7 32 bit VM) – alph486 Nov 13 '12 at 19:00
-
2@holodoc Thank you so much for this! Many people do not mention that only the last part of the IP should be different between the guest and host. – Asu Apr 05 '17 at 12:33
-
upvoted! isnt this the internal IP address, if I wanted to add this to an A record on Godaddy, would it work? – PirateApp Aug 27 '19 at 13:49
Using NAT (the default) this is not possible. Bridged Networking should allow it. If bridged does not work for you (this may be the case when your network adminstration does not allow multiple IP addresses on one physical interface), you could try 'Host-only networking' instead.
For configuration of Host-only here is a quote from the vbox manual(which is pretty good). http://www.virtualbox.org/manual/ch06.html:
For host-only networking, like with internal networking, you may find the DHCP server useful that is built into VirtualBox. This can be enabled to then manage the IP addresses in the host-only network since otherwise you would need to configure all IP addresses statically.
In the VirtualBox graphical user interface, you can configure all these items in the global settings via "File" -> "Settings" -> "Network", which lists all host-only networks which are presently in use. Click on the network name and then on the "Edit" button to the right, and you can modify the adapter and DHCP settings.

- 2,929
- 1
- 34
- 63

- 2,748
- 4
- 28
- 42
-
3This worked on my Host=Win8 and Guest=Debian combination. Also, after originally doing this I stopped being able to ping my host from the guest. It was a Windows Firewall issue. – Andrei Bârsan Nov 17 '13 at 12:33
If you start tinkering with VirtualBox network settings, watch out for this: you might make new network adapters (eth1, eth2), yet have your /etc/network/interfaces
still configured for eth0.
Diagnose:
ethtool -i eth0
Cannot get driver information: no such device
Find your interfaces:
ls /sys/class/net
eth1 eth2 lo
Fix it:
Edit /etc/networking/interfaces
and replace eth0 with the appropriate interface name (e.g eth1, eth2, etc.)
:%s/eth0/eth2/g

- 10,385
- 6
- 60
- 58