17

I just installed a new ISO downloaded from Ubuntu.com today, just installed it to a new machine. Networking is working just fine, but the IP address isn't getting picked up by the Hyper-V manager. I am trying to make a base box for vagrant, so I need networking to actually report the IP address.

Console output for ping, ifconfig, and lsmod:

root@trusty-tahr:~# ping -c 4 stackoverflow.com
PING stackoverflow.com (198.252.206.16) 56(84) bytes of data.
64 bytes from stackoverflow.com (198.252.206.16): icmp_seq=1 ttl=54 time=49.3 ms
64 bytes from stackoverflow.com (198.252.206.16): icmp_seq=2 ttl=54 time=50.2 ms
64 bytes from stackoverflow.com (198.252.206.16): icmp_seq=3 ttl=54 time=48.7 ms
64 bytes from stackoverflow.com (198.252.206.16): icmp_seq=4 ttl=54 time=49.8 ms

--- stackoverflow.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 48.726/49.536/50.216/0.623 ms
root@trusty-tahr:~# ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:15:5d:01:98:41
          inet addr:192.168.1.186  Bcast:192.168.1.255  Mask:255.255.255.0
          inet6 addr: fe80::215:5dff:fe01:9841/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:530 errors:0 dropped:0 overruns:0 frame:0
          TX packets:252 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:83564 (83.5 KB)  TX bytes:33034 (33.0 KB)

root@trusty-tahr:~# lsmod
Module                  Size  Used by
joydev                 20480  0
hid_generic            16384  0
iosf_mbi               16384  0
crct10dif_pclmul       16384  0
crc32_pclmul           16384  0
ghash_clmulni_intel    16384  0
aesni_intel           172032  0
aes_x86_64             20480  1 aesni_intel
lrw                    16384  1 aesni_intel
gf128mul               16384  1 lrw
glue_helper            16384  1 aesni_intel
ablk_helper            16384  1 aesni_intel
cryptd                 20480  3 ghash_clmulni_intel,aesni_intel,ablk_helper
serio_raw              16384  0
hid_hyperv             16384  0
hid                   110592  2 hid_hyperv,hid_generic
hyperv_keyboard        16384  0
hv_balloon             24576  0
8250_fintek            16384  0
hyperv_fb              20480  1
i2c_piix4              24576  0
mac_hid                16384  0
lp                     20480  0
parport                45056  1 lp
hv_netvsc              36864  0
hv_utils               20480  0
hv_storvsc             20480  2
psmouse               114688  0
floppy                 77824  0
hv_vmbus               61440  8 hv_balloon,hyperv_keyboard,hv_netvsc,hid_hyperv,hv_utils,hyperv_fb,hv_storvsc
pata_acpi              16384  0
root@trusty-tahr:~#

Networking tab in Hyper-V manager:

Hyper-V Networking tab

This is on Windows 10 Professional

John P Bloch
  • 4,535
  • 1
  • 22
  • 24
  • According to this https://social.technet.microsoft.com/Forums/en-US/8ea16b25-6ede-49f7-a70e-7aa79f02f9cb/hyperv-ubuntu-1504-server-vm-not-reporting-an-ip-address-but-has-network-access?forum=linuxintegrationservices it seems to have something to do with the kvp daemon in linux-cloud-tools-virtual. – John P Bloch Oct 10 '15 at 20:44

4 Answers4

34

Ok, I figured this one out.

The tl;dr version:

sudo apt-get install "linux-cloud-tools-$(uname -r)"

Normally you'd install linux-cloud-tools-virtual to get the KVP daemon installed. Unfortunately, the kernel version that ships with Ubuntu 14.04.3 is 3.19.0-25-generic, whereas linux-cloud-tools-virtual installs the cloud tools for 3.13.0-65-generic. So obviously you need to install the cloud tools for your kernel's release version. To do that automatically you need to get your relase version using uname -r, as above.

Hope that helps somebody somewhere along the line.

John P Bloch
  • 4,535
  • 1
  • 22
  • 24
  • This worked perfectly for me in 16.04, but not in 17.10 – Taegost Mar 06 '18 at 21:35
  • This worked for me in Ubuntu 18.04.1 LTS guest on Windows 10 Enterprise Host. Without the "quotes". sudo apt-get install linux-cloud-tools-$(uname -r) – nickedeye Jan 02 '19 at 07:49
  • It worked for me, Deepin linux.Finally I can ssh into my vm without connect in and `ifconfig` to check the ip.Thanks! – valleygtc Feb 02 '19 at 07:27
  • If you install the package for your exact kernel version, is there a risk of it going stale when the kernel is updated, or will apt keep them both up to date going forwards? – mwfearnley Jul 12 '22 at 14:24
7

seems like for 18.10 the sudo apt install linux-cloud-tools-virtual is what is needed again

ondrovic
  • 1,105
  • 2
  • 23
  • 40
2

For my Ubuntu 20.04, I followed this guide for Ubuntu 18.04. I can see from the lsmodoutput from the question, that he doesn't require the first steps, but I wanted to post a more complete guide.

First edit the modules file (using nano) to add additional modules:

    sudo nano /etc/initramfs-tools/modules

and add following lines:

    hv_vmbus
    hv_storvsc
    hv_blkvsc
    hv_netvsc

Now install the virtual tools, update the initramfs modules and reboot:

    sudo apt-get install linux-virtual linux-cloud-tools-virtual linux-tools-virtual
    sudo update-initramfs -u
    sudo reboot
Bart Jolling
  • 595
  • 6
  • 21
2

On Ubuntu 22.04 Server, (similar to @mwfearnley)'s comment on https://stackoverflow.com/a/67481445/13577666, I only had to:

sudo apt install -y \
  linux-virtual \
  linux-cloud-tools-virtual \
  linux-tools-virtual

sudo reboot now
Ian Cleary
  • 21
  • 2
  • This did NOT work for me in Ubuntu Studio 22.04 LTS. I've tried literally everything, and can't get the IP address of the guest VM to show in the Hyper-V manager, or via Get-VMNetworkAdapter in PowerShell. I'm ripping my hair out at this point. – Trevor Sullivan Jun 05 '23 at 13:20