VirtualBox with Ubuntu Server guest can't ping outside
Solution 1
I had the same problem. I solved it by changing my virtualbox network adapter from "NAT" to "bridge adapter".
You can use NAT for port forwardind. So you can, for example, configure your forwarding table to forward request from port 8080 to your virtual server.
Solution 2
I am not sure if this will resolve your issue or not, as perhaps it is not exactly the same issue as mine, since you are using NAT, but I think it is worth a try.
I was having a similar issue where I could not ping my host or the router or any other box from the Ubuntu VM. I had set up a bridged WiFi adapter via Machine -> Settings -> Network options in VBox.
But then I noticed that there were actually two Wifi adapters listed:
Microsoft Virtual WiFi Miniport Adapter
Realtek RTL8188CE 802.11b/g/n WiFi Adapter
I had selected the Microsoft one first, and then when I switched to the Realtek one and restarted the VM, the issue was resolved for me.
Related videos on Youtube
Danidan
Updated on September 18, 2022Comments
-
Danidan over 1 year
Here's my situation:
- an Ubuntu 12.04 Host running VirtualBox;
- two guest VMs running Ubuntu Server 12.04
- home network, so my Host pc has a wireless connection to the router of my ISP.
My problem is in one of the virtual machines: it has 3 NICs, one in NAT mode and the others in Host Only mode. My purpose is to use eth0 (NAT) for Internet access and eth1, eth2 (Host Only) for management of internal virtual network (eth1 uses a VBoxNet with this IP 192.168.69.254).
Whenever I try to
$ping 8.8.8.8
I getDestination Host Unreachable
.While if I
$ping 192.168.69.10
, that is the IP of the other VM, it works.I can't also ping my Host nor my router
My
/etc/network/interfaces
file is: auto lo iface lo inet loopbackauto eth0 iface eth0 inet dhcp auto eth1 iface eth1 inet static address 192.168.69.1 netmask 255.255.255.0 auto eth2 iface ifconfig $IFACE 0.0.0.0 up up ip link set $IFACE promisc on down ip link set $IFASE promisc off down ifconfig $IFACE down
$route -n
returns:Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.0.2.2 0.0.0.0 UG 100 0 0 eth0 10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 192.168.69.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1 192.168.100.0 0.0.0.0 255.255.255.0 U 0 0 0 virbr0
Forgetting for now what eth2 needs to do and its setup, why I can't go outside the Host box?
What can I do to help you helping me? :-)
-Edit-
On my Host:
$ ifconfig -a
eth0 Link encap:Ethernet IndirizzoHW 00:26:9e:d5:1a:bb UP BROADCAST MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisioni:0 txqueuelen:1000 Byte RX:0 (0.0 B) Byte TX:0 (0.0 B) eth1 Link encap:Ethernet IndirizzoHW c4:17:fe:17:31:b3 indirizzo inet:192.168.1.186 Bcast:192.168.1.255 Maschera:255.255.255.0 indirizzo inet6: fe80::c617:feff:fe17:31b3/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:1774067 errors:3 dropped:0 overruns:0 frame:3371346 TX packets:1486276 errors:266 dropped:0 overruns:0 carrier:0 collisioni:0 txqueuelen:1000 Byte RX:1642836807 (1.6 GB) Byte TX:170395284 (170.3 MB) Interrupt:16 lo Link encap:Loopback locale indirizzo inet:127.0.0.1 Maschera:255.0.0.0 indirizzo inet6: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:65536 Metric:1 RX packets:9119 errors:0 dropped:0 overruns:0 frame:0 TX packets:9119 errors:0 dropped:0 overruns:0 carrier:0 collisioni:0 txqueuelen:0 Byte RX:1089979 (1.0 MB) Byte TX:1089979 (1.0 MB) vboxnet0 Link encap:Ethernet IndirizzoHW 0a:00:27:00:00:00 indirizzo inet:192.168.69.254 Bcast:192.168.69.255 Maschera:255.255.255.0 indirizzo inet6: fe80::800:27ff:fe00:0/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:2314 errors:0 dropped:0 overruns:0 carrier:0 collisioni:0 txqueuelen:1000 Byte RX:0 (0.0 B) Byte TX:345450 (345.4 KB) vboxnet1 Link encap:Ethernet IndirizzoHW 0a:00:27:00:00:01 indirizzo inet:192.168.57.1 Bcast:192.168.57.255 Maschera:255.255.255.0 indirizzo inet6: fe80::800:27ff:fe00:1/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:2082 errors:0 dropped:0 overruns:0 carrier:0 collisioni:0 txqueuelen:1000 Byte RX:0 (0.0 B) Byte TX:331256 (331.2 KB)
-
MariusMatutiae over 10 yearscan you show the output of ifconfig -a on the host?
-
Oliver Salzburg over 10 yearsIs there a reason why you're using NAT for eth0 instead of bridged?
-
MariusMatutiae over 10 years@Oliver Salzburg Can you bridge over wlan0? His host is connected to his router via wifi
-
MariusMatutiae over 10 years@Danidan Could you just make an experiment? Comment out all lines referring to eth1 and eth2 in /etc/network/interfaces on your guest, and restart the VM. Can you connect to the internet right now?
-
Oliver Salzburg over 10 years@MariusMatutiae: I don't see why not, but I've never tried.
-
Danidan over 10 years@MariusMatutiae I edited the question with
ifconfig -a
as you requested. Also I commented the lines you said in my guest VM and nothing changed... -
MariusMatutiae over 10 years@Oliver Salzburg read David Schwartz's reply at the bottom of this page superuser.com/questions/597834/…
-
Danidan over 10 years@OliverSalzburg I tried also bridged but with no luck. Furthermore I added port forwarding on port 80 in NAT mode...
-
user149408 about 10 years@Danidan Back in NAT mode, try running
ifconfig
inside the guest to find out ifeth0
got a valid IP address. Then, from the guest, try to ping the host (which should be 10.0.2.2, based on your routing table). Does the host system respond to ping?