Libvirt: Can host resolve guest by hostname

My host is Silverblue. With libvirtd and virt-manager, I create guests with default network settings.

Let’s say, one of the guest is a Fedora Workstation, and hostname is set by:
sudo hostnamectl set-hostname myguest

sudo systemctl enable sshd --now
then reboot.

At the host terminal, I tried to do
ssh myguest

Just got an error:
ssh: Could not resolve hostname myguest: Name or service not known

What I need to do to have guest hostnames resolved at the host ?

2 Likes

This works for me:
libvirt: Libvirt NSS module

3 Likes

Thank you very much!

2 Likes

After doing that, from host to guest hostname resolution is working.

Now, how about between the two guests?

like, inside guest-a: ping guest-b or ping guest-b.dummy

1 Like

I tested single-label hostnames and it works with OpenWrt guests.
Fedora guests require the following configuration:

sudo mkdir -p /etc/systemd/resolved.conf.d
sudo tee /etc/systemd/resolved.conf.d/00-custom.conf << EOF
[Resolve]
LLMNR=no
ResolveUnicastSingleLabel=yes
EOF
sudo systemctl restart systemd-resolved.service
2 Likes