大网数据广告活动
服务器运维问答

Libvirt guest hostnames DNS resolution from host and guests

· 52CE 我爱测

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 f…

问题原文

原帖链接 · rosengrenen · CC BY-SA 4.0

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.

已采纳解答

原帖链接 · DanielB · CC BY-SA 4.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-11-22)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。