2

I have an Ubuntu 14.04 Server running as a Hyper-V VM. It has an external virtual adapter and an internal virtual adapter connected to it.

The external adapter eth0 gets an ip from 192.168.1.x dynamically assigned while its internal adapter eth1 gets a static ip of 192.168.1.109 assigned.

    eth0      Link encap:Ethernet  HWaddr 00:15:5d:01:17:30
      inet addr:192.168.1.254  Bcast:192.168.1.255  Mask:255.255.255.0
      inet6 addr: fe80::215:5dff:fe01:1730/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:31 errors:0 dropped:0 overruns:0 frame:0
      TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:11926 (11.9 KB)  TX bytes:1332 (1.3 KB)

    eth1      Link encap:Ethernet  HWaddr 00:15:5d:01:17:29
      inet addr:192.168.1.109  Bcast:192.168.1.255  Mask:255.255.255.0
      inet6 addr: fe80::215:5dff:fe01:1729/64 Scope:Link
      UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
      RX packets:14 errors:0 dropped:0 overruns:0 frame:0
      TX packets:47 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:1000
      RX bytes:1359 (1.3 KB)  TX bytes:2286 (2.8 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:33 errors:0 dropped:0 overruns:0 frame:0
      TX packets:33 errors:0 dropped:0 overruns:0 carrier:0
      collisions:0 txqueuelen:0
      RX bytes:2888 (2.8 KB)  TX bytes:2888 (2.8 KB)

Because this is a laptop, I often take it places with no router to connect to. With no router, the external adapter won't work. The purpose for the internal adapter is so I can map in my hosts file a consistent ip (192.168.1.109) to a domain (ubuntu.local) that exists on the Ubuntu VM. This way, I can always connect to ubuntu.local via the same ip regardless of whether or not I have a router to connect to.

The internal adapter solution works great. The issue (I think) is that when the Ubuntu VM has the internal adapter connected, it tries to use it to connect to the internet instead of the external adapter. As a side note: I only really need internet access to update ubuntu and add packages.

sudo apt-get update fails and I can't ping google.com or any other site:

    ping google.com
    ping: unknown host google.com

I have tried sharing the external virtual adapter connection with the internal virtual adapter but it did not work. I tried changing the internal adapter to be eth0 and the external to be eth1 in /etc/network/interfaces with no luck. I tried a misguided solution involving a Hyper-V virtualized router (based on DD-WRT) on 192.168.2.1 that assigned the Ubuntu VM a static ip of 192.168.2.109. That all worked but still did not solve this particular issue - could not ping any address and failed to update.

I think what needs to happen is that I need to switch the priority that the Ubuntu VM uses it's network adapters but I can't seem to figure out how to do this.

Does anyone have any insight into this issue? I would like to at least know if I'm headed in the right direction with debugging this issue.

2 Answers 2

0

This should work on a Windows, dunno about Ubuntu.

Just remove the default gateway IP address from the Internal Network card, this will make the OS know that this network card is not routable.

0

The problem is you used the same subnet for the external network and the internal network. The machine can then rightly assume that the two adapters are actually connected to the same network, and use either one to reach the gateway.

Since this is not the case, and the networks are different, they must use IP addresses in different subnets.

The solution is to renumber one or both virtual networks.

1
  • So the aforementioned virtualized router idea for a subnet of 192.168.2.x was correct?
    – Steve Karwacki
    Apr 21, 2016 at 17:01

You must log in to answer this question.

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