How can I get Hyper V to detect my Ubuntu VM's IP Address
Asked Answered
F

5

18

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

Featherweight answered 8/10, 2015 at 22:48 Comment(1)
According to this social.technet.microsoft.com/Forums/en-US/… it seems to have something to do with the kvp daemon in linux-cloud-tools-virtual.Featherweight
F
36

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.

Featherweight answered 10/10, 2015 at 21:53 Comment(4)
This worked perfectly for me in 16.04, but not in 17.10Asseverate
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)Champlain
It worked for me, Deepin linux.Finally I can ssh into my vm without connect in and ifconfig to check the ip.Thanks!Twibill
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?Transfer
L
8

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

Lakeshialakey answered 12/4, 2019 at 17:6 Comment(2)
this package name is valid as of 20.04Kenzi
This worked for me in 22.04 after a reboot.Transfer
T
3

Ubuntu 20.04

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

Ubuntu 24.04

As suggested by other people's comments, for my most recent installation of an Ubuntu 24.04, executing the apt-get install and the sudo reboot commands was sufficient

Threedimensional answered 11/5, 2021 at 6:16 Comment(1)
In 20.04, it was enough for me to do the apt install and reboot.Transfer
P
2

On Ubuntu 22.04 Server, (similar to @mwfearnley)'s comment on https://mcmap.net/q/651114/-how-can-i-get-hyper-v-to-detect-my-ubuntu-vm-39-s-ip-address, I only had to:

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

sudo reboot now
Posse answered 7/6, 2022 at 16:34 Comment(1)
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.Utterance
I
0

On Ubuntu 22.04 if you installed the kernel from HWE then you need to install

linux-cloud-tools-virtual-hwe-22.04

After you reboot it should work. At least this is what I have done.

Inlaid answered 23/1, 2024 at 11:9 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.