0

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.

3 Answers 3

0

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.

1
  • I'm constantly switching between a physical Ethernet connection and a WiFi connection, so I'd constantly have to reconfigure the bridge. Also, whenever I do try bridging the connections, the NIC can never find an IP to bind to.
    – Pockets
    Apr 27, 2014 at 16:30
0

Managed to solve my problem. The solution was ultimately scrapping the gateway line from /etc/network/interfaces. While I don't perfectly understand why, I did find this:

Only the Internet-facing machine should have a "gateway" declaration. The other interface will simply broadcast packets intended for the other subnet which the machines on that network will read.

The gateway declaration tells the OS where to send packets that have no local destination, so it must be unique.

I should note that I realized this was the problem after the following (note that when I say disabled/enabled adapters, I'm talking about doing so in VBox with the VM shut down; I rebooted it multiple times to make sure that I was actually fixing the problem and not just the symptoms) :

  1. Disabled adapter #2, enabled adapter #1 to bridge to the host's Ethernet NIC, discovered that this actually connected the guest to the internet. This is the first hint that I got that my problem was related to having not one but two adapters. I should note that I also bridged adapter #1 to the host's wireless NIC, which failed presumably because of an impressive 86% packet loss with my uni's WiFi.
  2. Kept adapter #2 disabled, switched adapter #1 to NAT, verified connectivity while still on the 10.0.2.0/24 network. I still don't particularly understand this part, and if anyone could explain why it works this way, that would be great. In any case, this proved to me that the problem wasn't with the NAT but with having both adapters enabled.
  3. Enabled both adapters, #1 as NAT and #2 as Host-only. Looked up dual-NIC configurations, realized I had a gateway setting problem (I had always thought I needed both gateways configured).
  4. I deleted the gateway configuration line for eth1 and tried sudo /etc/init.d/networking restart as well as combinations of ifdown and ifup (this comment notes that commenting the line out didn't work). I should note that this did not work for me.
  5. I decided to collecting kernel routing information about the different working setups, and when I booted back into the dual-NIC configuration I discovered after a cursory ping that I had an internet connection from the guest. I suspect the reason for this lies specifically somewhere between a discrepancy between the network configuration processes run during startup and ifconfig, ifdown, ifup, and /etc/init.d/networking, but in any case, I finally got a working internet connection on my guest the way I wanted it to.
1
  • 1
    The gateway is the machine that will receive all packets destined for an address not directly on the network. In your case you had set the gateway to 192.168.56.1, so any packet not destined to 10.0.2.0/24 or 192.168.56.0/24 went to 192.168.56.1 and was dropped. Apr 28, 2014 at 11:57
0

Copy this to the /etc/network/interface:

auto lo
iface lo inet loopback
auto lo eth0

Change the network setting to NAT adapter and reboot the m/c.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .