My issue is basically that I cannot access the internet from an Ubuntu VM. I'm trying to figure out how to do so, and would very much appreciate help in doing so. I realize that there are quite a few results that Google pulls up when you search this, and no solution I've found seems to work. I'm also not particularly proficient in networking, so forgive me (and please do correct me!) if I misuse any terminology.
The specifics of my issue are as follows: I have an Ubuntu 14.04 server guest in Virtualbox in a Windows 8.1 host. I've set up two network adapters in VBox, one to get internet from the VM, the other to SSH into the VM from the host. I can successfully SSH into the guest from the host, but cannot access the internet from the VM itself.
I have two network adapters enabled for said guest as follows:
- Adapter 1: NAT, cable connected; no port forwarding rules
- Adapter 2: Host-only Adapter, VirtualBox Host-Only Ethernet Adapter, cable connected
In the VM, I have configured /etc/network/interfaces
as follows:
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
auto eth0
iface eth0 inet dhcp
auto eth1
iface eth1 inet static
address 192.168.56.11
gateway 192.168.56.1
Running ifconfig
in the VM gives:
eth0 Link encap:Ethernet HWaddr 08:00:27:f8:41:f4
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fef8:41f4/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6 errors:0 dropped:0 overruns:0 frame:0
TX packets:61 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2568 (2.5 KB) TX bytes:9768 (9.7 KB)
eth1 Link encap:Ethernet HWaddr 08:00:27:bd:71:e5
inet addr:192.168.56.11 Bcast:192.168.56.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:febd:71e5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:992 errors:0 dropped:0 overruns:0 frame:0
TX packets:687 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:111574 (111.5 KB) TX bytes:99004 (99.0 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:28 errors:0 dropped:0 overruns:0 frame:0
and netstat -rn
gives:
Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 192.168.56.1 0.0.0.0 UG 0 0 0 eth1
10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.56.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
As I noted earlier, I can easily SSH into the VM (I should note that the VBox Host-Only Network handles 192.168.56.0/24
). I am experiencing no problems with this function.
What I am experiencing problems with is eth0
. This NIC (is this the correct term?) seems to be working fine – it's connecting, after all:
user@machine:~$ sudo ifdown eth0
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eth0/08:00:27:f8:41:f4
Sending on LPF/eth0/08:00:27:f8:41:f4
Sending on Socket/fallback
DHCPRELEASE on eth0 to 10.0.2.2 port 67 (xid=0x2ecf8ea)
user@machine:~$ sudo ifup eth0
Internet Systems Consortium DHCP Client 4.2.4
Copyright 2004-2012 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eth0/08:00:27:f8:41:f4
Sending on LPF/eth0/08:00:27:f8:41:f4
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 3 (xid=0x3c7a1e6f)
DHCPREQUEST of 10.0.2.15 on eth0 to 255.255.255.255 port 67 (xid=0x3c7a1e6f)
DHCPOFFER of 10.0.2.15 from 10.0.2.2
DHCPACK of 10.0.2.15 from 10.0.2.2
bound to 10.0.2.15 -- renewal in 41246 seconds.
However, this does not seem to be the internet connection that my host is using. (I should note that I'm a university student and although I have no confirmation on this, I think that the two wireless networks in my dorm span 10.66.0.0/16 and 10.67.0.0/16). The relevant snippets of ipconfig
are:
Wireless LAN adapter Local Area Connection* 12:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . :
Wireless LAN adapter Wi-Fi:
Connection-specific DNS Suffix . : <$university>.edu
Link-local IPv6 Address . . . . . : fe80::6951:a0dd:9416:1174%4
IPv4 Address. . . . . . . . . . . : 10.66.31.253
Subnet Mask . . . . . . . . . . . : 255.255.0.0
Default Gateway . . . . . . . . . : 10.66.0.1
Ethernet adapter Ethernet:
Media State . . . . . . . . . . . : Media disconnected
Connection-specific DNS Suffix . : <$university>.edu
Ethernet adapter VirtualBox Host-Only Network:
Connection-specific DNS Suffix . :
Link-local IPv6 Address . . . . . : fe80::b53e:38c2:fa96:efb8%17
IPv4 Address. . . . . . . . . . . : 192.168.56.1
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . :
All I have in /etc/udev/rules.d
is a README
; there is no 70-persistent-net.rules
file there.
I have verified that Oracle VM Virtualbox has access through Windows Firewall.
I have gotten the occasional connection to the internet from the VM (i.e., ping 8.8.8.8
doesn't lose packets), and I have absolutely no idea how, but rebooting the VM will kill the connection. Among the few times I've gotten the connections, one happened after reversing the network adapters (adapter 1 from host-only to NAT and 2 from NAT to host-only and flipping eth0
and eth1
in /etc/network/interfaces
).
Other than that, I'm at a complete loss. Is the issue definitely on my end, or is it possible that there's a problem between the guest and my university's network? All I know is that eth0 is putting the guest on 10.0.2.0/24
and from what the host is telling me, I want the guest on either 10.66.0.0/24
or 10.67.0.0/24
.
Best Answer
Quick question... why not just use 1 NIC in bridged adapter mode? Your VM would get an IP from your LAN and you would be able to go on the web right away, nothing fancy needed.