TransWikia.com

Libvirt guest hostnames DNS resolution from host and guests

Server Fault Asked by rosengrenen on December 20, 2020

I have set up multiple virtual machines with libvirt and kvm on Ubuntu server 20.04, which work just as expected. The only thing I cannot figure out at this point is how to make their hostnames resolvable between the guests and from the host, at the moment I can only access them via their ip addresses which I can get from virsh net-dhcp-leases default.

I’d like to access the virtual machines by their hostname or similar both from the host and from within the virtual machines, as relying on these ip addresses is a bit inconvenient, but am not sure how to achieve this. I have tried following articles such as this. If a host is named test I want it to be reachable by both test and test.example.com, while external.example.com is not resolved to an internal address, but an external one possibly somewhere else, which I think could be a problem with the solution in the article above. Would this be best achieved by adding entries manually in the hosts /etc/hosts or by something similar in the article above? I have tried adding entries to the /etc/hosts/ file but the entries have only worked on the host machine, but I assume that it is because I haven’t properly set up dnsmasq or something similar.

Any help will be appreciated, since I am very much a confused beginner and it is quite overwhelming.

One Answer

Libvirt provides a nss module which you can configure on the host, which uses the net-dhcp-leases information to provide host resolution https://libvirt.org/nss.html

Correct answer by DanielB on December 20, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP