Hyper-V guest hostname doesn't resolve in local network

4

2

My Hyper-V host is Windows 10 Enterprise x64. I only have one guest running: archlinux.

The guest is connected to all NICs:

  • WiFi
  • Ethernet (physical)

Occasionally, I will SSH into the guest from either the host system or any other PC on my local network. No PC in my local network has a static IP, including the guest system.

The problem is that after booting the host (and thus booting the guest), the guest's IP is dynamically set and unknown. Only after connecting to the guest and performing ip addr, I can use the IP address for SSH connections (root@192.168.0.*).

I want to access the guest system by the hostname so that I don't have to retrieve the IP every time. Here is the problem:

Let's say the archlinux guest was assigned the IP 192.168.0.24. The arch hostname is configured as Hyper-al. I can ping every (Windows) PC in my network by their hostname (e.g. ping DESKTOP-XXXXX) and their IP. Pinging the guest using it's IP works just fine. However, the hostname Hyper-al does not resolve.

So when I for example try to connect to the guest using PuTTY, I can do so just fine with the IP. When I however try with the hostname, it does not resolve. The hostname is properly configured within arch in both /etc/hostname and /etc/hosts and recognized by e.g. PuTTY after logging in using the IP.

How can I access the arch guest by it's hostname? I've had success doing this with ubuntu server guests, so I imagine it would have to work.

mınxomaτ

Posted 2016-09-17T19:59:07.443

Reputation: 191

The connecting 'from' machine (the PuTTy machine) needs to have a IP > Hostname binding as well. – linuxdev2013 – 2016-09-29T11:51:05.133

Answers

4

archlinux needs samba to broadcast a hostname using the netbios protocol that Windows clients use.

Install and configure samba in the guest:

pacman -Sy samba
nano /etc/samba/smb.conf

put

workgroup = WORKGROUP
netbios name = Hyper-al

WORKGROUP is the default and sufficient if the guest doesn't need to join a WG.

Enable the services:

systemctl enable smbd.service
systemctl enable nmbd.service

Reboot.

mınxomaτ

Posted 2016-09-17T19:59:07.443

Reputation: 191

1

For those who are on Ubuntu, here are instructions that worked for me

First install Samba,

sudo apt-get install samba

Second, configure the hostname wanted (this can be different from actually Ubuntu hostname)

Edit Samda's configuration file, sudo vi /etc/samba/smb.conf

Under the line that contains workgroup = WORKGROUP add a new line with netbios name = NameOfHost

Finally, restart samba

systemctl restart smbd

Tom

Posted 2016-09-17T19:59:07.443

Reputation: 377